按照 https://wiki.sipeed.com/soft/Lichee/zh/Nano-Doc-Backup/get_started/first_eat.html 教程来编译U-Boot时候出现的错误

错误信息

  LD      examples/standalone/libstubs.o
  LD      examples/standalone/hello_world
  OBJCOPY examples/standalone/hello_world.srec
  OBJCOPY examples/standalone/hello_world.bin
  LD      u-boot
  DTC     arch/arm/dts/suniv-f1c100s-licheepi-nano.dtb
Error: arch/arm/dts/.suniv-f1c100s-licheepi-nano.dtb.pre.tmp:54.1-10 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [scripts/Makefile.lib:329:arch/arm/dts/suniv-f1c100s-licheepi-nano.dtb] 错误 1
make[1]: *** [dts/Makefile:51:arch/arm/dts/suniv-f1c100s-licheepi-nano.dtb] 错误 2
make: *** [Makefile:877:dts/dt.dtb] 错误 2

检查得知生成的 .suniv-f1c100s-licheepi-nano.dtb.pre.tmp 最后一行出现转译符号。

...
&usbphy {
	usb0_id_det-gpio = <&pio 4 2 GPIO_ACTIVE_HIGH>; /* PE2 */
	status = "okay";
};
\#include "sunxi-u-boot.dtsi"  // 应该是#include "sunxi-u-boot.dtsi",多了一个 \ 导致语法错误

解决方法

修改 scripts/Makefile.lib 第 321 行

    quiet_cmd_dtc = DTC     $@
    # Modified for U-Boot
    # Bring in any U-Boot-specific include at the end of the file
    cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
----    (cat $<; $(if $(u_boot_dtsi),echo '\#include "$(u_boot_dtsi)"')) > $(pre-tmp); \
++++    (cat $<; $(if $(u_boot_dtsi),echo '#include "$(u_boot_dtsi)"')) > $(pre-tmp); \
	$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $(pre-tmp) ; \
	$(DTC) -O dtb -o $@ -b 0 \
		-i $(dir $<) $(DTC_FLAGS) \
		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)