设备树编译器无法识别包含文件的 C 语法 [英] Device tree compiler not recognizes C syntax for include files

查看:30
本文介绍了设备树编译器无法识别包含文件的 C 语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想手动编译我的电路板设备树.我已经从其官方 dtc>source,但是当我尝试运行以下命令时,出现错误提示我将所有 #include 指令更改为 /include/ 等等对于 #define

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

我的主板是 Khadas Vim,其核心是 amlogic S905x SoC.所有包含文件都存在,错误是:

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

第8行是:

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

#include 更改为 /include/ 将抑制错误!

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

如果您知道设备树语言"的一些参考资料(U-boot 文档除外),请介绍.

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

推荐答案

这不是 Device Tree 语法问题,您只需使用 C 预处理器 cpp 对 .dts 文件进行预处理,以获得文件可以由设备树编译器按原样消化.

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"

验证 kvim1.dtb 是否已构建:

Verifying kvim1.dtb was built:

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

有关官方设备树规范,请参阅其官方网站及其git 存储库.

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

这篇关于设备树编译器无法识别包含文件的 C 语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆