我想手动编译我的主板设备树。我已经从官方source下载了最新版本的dtc,但是当我尝试运行以下命令时,出现错误消息,建议我将所有#include伪指令更改为/include/,以此类推,以便更改#define等。

dtc -I dts -O dtb -p 0x1000 meson-gxl-s905x-khadas-vim.dts -o kvim1.dtb
我的电路板是Khadas Vim,其心脏是amlogic S905x SoC。所有包含文件都存在,并且错误是:
Error: meson-gxl-s905x-khadas-vim.dts:8.1-9 syntax error
FATAL ERROR: Unable to parse input tree
第八行是:
#include <dt-bindings/input/input.h>
#include更改为/include/将抑制该错误!
如果您知道设备树“语言”的某些引用(U-boot文档除外),请进行介绍。

最佳答案

这不是设备树语法问题,您只需要使用C预处理程序cpp预处理.dts文件,即可获取可以由设备树编译器按原样消化的文件。

在您的特定情况下,假设您的当前目录是内核根目录,则必须使用以下两个命令:

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"

验证kvim1.dtb是否已构建:
ls -ail kvim1.tdb
4359446 -rw-rw-r-- 1 user user 27568 Jun  2 12:05 kvim1.dtb

有关官方的设备树规范,请引用其official web sitegit repository

关于linux - 设备树编译器无法识别包含文件的C语法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50658326/

10-11 18:09