zephyrproject-rtos / python-devicetree

Python devicetree library
15 stars 4 forks source link

Facing issue while parsing DTSi files with header files included #1

Closed Manoj1063 closed 2 years ago

Manoj1063 commented 2 years ago

Goal :

Parsing the DTS file and get all the node attributes details. Get list of all the nodes name and node details part of DTS and DTSi files.

Issue Description :

Able to parse and get the node details as excepted for DTS file which included DTSi files and in DTSI file no files has been included like header files, but case where the DTSi file included some header files then getting below parse error.

Error : parse error: expected '/' or label reference (&foo)

DTSI File image

Header File image

My Observation :

DTSI file which include the header file has not been in standard DTS file format. Hence, getting the above-mentioned parse error. Any ways to neglect parser not included the header file mentioned, goal is to get the node attributes details of DTS and DTSi files only. Please advise me on this.

Code Reference - https://github.com/zephyrproject-rtos/python-devicetree/blob/main/src/devicetree/dtlib.py#L255

galak commented 2 years ago

@Manoj1063 curious what you are using this parser for.

mbolivar-nordic commented 2 years ago

I'm having a hard time understanding the steps to reproduce. The python-devicetree code can't handle C preprocessor directives like #define or #include -- you need to run the C preprocessor first, then parse the devicetree.

Manoj1063 commented 2 years ago

@Manoj1063 curious what you are using this parser for.

@galak , We are developing product to simplify the DTS files editing/modifying through an user interface. So trying to parse the list of DTS/DTSI files under the project to get the list of nodes and node attributes details.

Manoj1063 commented 2 years ago

I'm having a hard time understanding the steps to reproduce. The python-devicetree code can't handle C preprocessor directives like #define or #include -- you need to run the C preprocessor first, then parse the devicetree.

@mbolivar-nordic , Tried the below command, getting the errors not able to parse successfully and get the data. Can you please provide the steps to run C preprocessor for the DTS files??

cpp -nostdinc -I include -I arch  -undef -x assembler-with-cpp  <dts_filename>.dts <dts_filename>.dts.preprocessed

dtc -I dts -O dtb -p 0x1000 <dts_filename>.dts.preprocessed -o <dts_filename>.dtb 
mbolivar-nordic commented 2 years ago

Can you please provide the steps to run C preprocessor for the DTS files??

Sorry, but this question is not in scope for this library.