14

I am working on Embedded Linux for TX6U-8010 based on Freescale imx6.

I am trying to compile dtb using the device tree compiler (dtc). However when I use the command:

dtc -O dtb -o imx6dl-tx6u-801x.dtb imx6dl-tx6u-801x.dts

...I get the following error:

Error: imx6dl-tx6u-801x.dts:13.1-9 syntax error
FATAL ERROR: Unable to parse input tree

Lines 12,13,14 are:-

/dts-v1/;
#include "imx6dl.dtsi"
#include "imx6qdl-tx6.dtsi"

The kernel version that I am using is linux-3.18.5 and dtc version is DTC 1.4.0.

CJBS
  • 15,147
  • 6
  • 86
  • 135
mkpeker
  • 173
  • 1
  • 1
  • 5

2 Answers2

34

https://linux-sunxi.org/Device_Tree#Compiling_the_Device_Tree

Device tree sources in the kernel deviate from the regular syntax, by using the cpp preprocessor for includes and substitution. This proceeds as follows:

IDE=<your-device-name>
SRC=$IDE.dts
TMP=$IDE.tmp.dts
DST=$IDE.dtb

cpp -nostdinc -I include -undef -x assembler-with-cpp $SRC > $TMP
dtc -O dtb -b 0 -o $DST $TMP
rm $TMP
Anonymous
  • 341
  • 3
  • 2
  • 1
    This should be the accepted answer. Great piece of information. – Naveen Jul 24 '19 at 14:46
  • This answer (how includes are processed) is what helped me identify my issues recently. I had a missing semicolon (d'oh) but when I fixed it, I kept getting errors -- on an include line. Realizing that there wasn't much that could go wrong with that, I kept digging. This answer cleared that up for me. – bvarner Jan 12 '21 at 23:29
  • 1
    This worked, thanks. For extra clarity, maybe you can make it in the form INCLUDEDIR=/dir/to/include cpp -nostdinc -I $INCLUDEDIR -undef -x assembler-with-cpp $SRC > $TMP – Janne Paalijarvi May 28 '22 at 22:26
17

You can use the Makefile file provided with the kernel source to handle all the issues for you.

From the kernel code root directory, simply run:

make ARCH=arm CROSS_COMPILE=arm-none-eabi- imx_v6_v7_defconfig
make ARCH=arm CROSS_COMPILE=arm-none-eabi- dtbs

Just make sure to replace the CROSS_COMPILE value with the right prefix.

CJBS
  • 15,147
  • 6
  • 86
  • 135
tkgk
  • 291
  • 2
  • 6
  • Perfect. I ran this from the Android source tree to recompile the dts files that had includes. The commands I used were: `cd ~/AOSP/kernel_imx` / ``export CROSS_COMPILE=`pwd`/../prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi- `` / `make imx_v6_v7_defconfig` / `make dtbs` – CJBS Jun 16 '15 at 23:26