Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Device tree compiler not recognizes C syntax for include files

I want to compile my board device tree manually. I have downloaded the latest version of dtc from its official source, but when I try to run the following command, I get an error advising me to change all #include directives to /include/ and so on for #define , etc.

dtc -I dts -O dtb -p 0x1000 meson-gxl-s905x-khadas-vim.dts -o kvim1.dtb

My board is Khadas Vim with an amlogic S905x SoC in its heart. All include files are present and the error is:

Error: meson-gxl-s905x-khadas-vim.dts:8.1-9 syntax error
FATAL ERROR: Unable to parse input tree

The 8th line is:

#include <dt-bindings/input/input.h>

Changing the #include to /include/ will suppress the error!

If you know some reference for device tree 'language' (except U-boot documentations) , introduce it please.

like image 765
Saleh Avatar asked Jun 02 '18 15:06

Saleh


1 Answers

This is not a Device Tree syntax issue, you just have to pre-process the .dts file with the C preprocessor, cpp, in order to obtain a file that can be digested by the Device Tree Compiler as is.

In your specific case, assuming your current directory would be the kernel root directory, you would have to use the two following commands:

cpp -nostdinc -I include -I arch  -undef -x assembler-with-cpp  arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dts meson-gxl-s905x-khadas-vim.dts.preprocessed

dtc -I dts -O dtb -p 0x1000 meson-gxl-s905x-khadas-vim.dts.preprocessed -o kvim1.dtb

kvim1.dtb: Warning (unit_address_vs_reg): Node /scpi/clocks/scpi_clocks@0 has a unit name, but no reg property
kvim1.dtb: Warning (unit_address_vs_reg): Node /soc/bus@c8100000/pinctrl@14 has a unit name, but no reg property
kvim1.dtb: Warning (unit_address_vs_reg): Node /soc/periphs@c8834000/rng has a reg or ranges property, but no unit name
kvim1.dtb: Warning (unit_address_vs_reg): Node /soc/periphs@c8834000/pinctrl@4b0 has a unit name, but no reg property
kvim1.dtb: Warning (unit_address_vs_reg): Node /soc/periphs@c8834000/eth-phy-mux has a reg or ranges property, but no unit name
kvim1.dtb: Warning (unit_address_vs_reg): Node /gpio-keys-polled/button@0 has a unit name, but no reg property
kvim1.dtb: Warning (simple_bus_reg): Node /soc/bus@c8100000/pinctrl@14 missing or empty reg/ranges property
kvim1.dtb: Warning (simple_bus_reg): Node /soc/periphs@c8834000/rng simple-bus unit address format error, expected "0"
kvim1.dtb: Warning (simple_bus_reg): Node /soc/periphs@c8834000/pinctrl@4b0 missing or empty reg/ranges property
kvim1.dtb: Warning (simple_bus_reg): Node /soc/periphs@c8834000/eth-phy-mux simple-bus unit address format error, expected "55c"

Verifying kvim1.dtb was built:

ls -ail kvim1.tdb
4359446 -rw-rw-r-- 1 user user 27568 Jun  2 12:05 kvim1.dtb

For the official Device Tree specification, please refer to its official web site and its git repository.

like image 155
Frant Avatar answered Sep 21 '22 15:09

Frant