Building kernel from source DTBs not correctly built

I have a question regarding building DTBs from source. I have been building kernels for Jetson TK1 and have never seen this issue so maybe it has to do with the 64 bit toolchain.

I compiled the TX1 kernel per RidgeRun documentation and I noticed something odd with the final DTBS. They are much much smaller than the ones included in the L4T driver package.

Size of tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb in L4T = 415kb

Size of tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb in custom kernel 245kb and does not boot FDT error on uboot.

What could possibly cause this? An outdated device-tree-compiler package in ubuntu 14.04?

Any help is appreciated ;)

You may find reverse compiling the two DTBs and then comparing to be useful. The reverse-compiled versions will strip comments and probably use a more uniform naming convention (likely comparing the two would be easier at that point…although losing comments and changing names may make it more difficult to match the kernel source lines). See if these versions differ. Also, beware that on R24.2+ there is the DTB from the initrd, plus the DTB in “/boot”. I’m uncertain about when (or if) the non-initrd version loads.

The reverse compile command is basically:

dtc -I dtb -O dts -o /tmp/extracted.dts /boot/the_firmware_in_extlinux.dtb

Btw, a device tree compiler known to work with that kernel source ships within the kernel source. However, I’ve found older DTC from multiple distributions ranging all the way up to the newest 4.x kernels works the same even on the oldest Jetson kernels.

Thanks for the input linuxdev as always. I love that I can count on you for answers my friend ;)

Can this be done in reverse to generate a DTB and compare sizes?

Yes, dtc is what is used during a kernel build, it works both to and from dtb format:

dtc -I dts -O dtb -o /tmp/new_binary_from_edit.dtb /tmp/your_modified_source.dts

…notice the “-I” is input format, the above now uses source as input…
…the “-O” is output format, and is not set as binary…
…the “-o” is file to output to and should reflect the “-O” format naming.

Well i tried it from the kernel dts directory and it looks like it cant find the dts includes:

FATAL ERROR: Unable to parse input tree - line 15

line 15 = #include “tegra210-xxx-dts”

Great info here I guess I could have googled ;)

http://www.wiki.xilinx.com/Build+Device+Tree+Blob

Same error with absolute directory in command hmmm:

arch/arm64/boot/dts/

FATAL ERROR: Unable to parse input tree

arch/arm64/boot/dts/tegra210-jetson-tx1-p2597-2180-a01-devkit.dts:17.1-2 syntax error
FATAL ERROR: Unable to parse input tree

line 17 = #include “tegra210-jetson-cv-base-p2597-2180-a00.dts”

These instructions should help:

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

Looks like we may have to edit the -I includes to include tegra210-platforms also but its still failing for me…

cpp -nostdinc -I include -I tegra210-platforms -undef -x assembler-with-cpp $SRC > $TMP

Your original solution does work when extracting and editing and then rebuilding the extracted dts

So far as the kernel based DTS build goes I don’t know specifics of your setup, but Kconfig has to be configured first, and I think include files require logic other than dtc (dtc only gets the final view). All of the cross compiler and other issues may still apply…if you can first configure a kernel as it currently runs and build that plus modules, then the “make dtbs” target has a good chance of working.

There’s a nice dts/dtb info page here:
http://elinux.org/Device_Tree_Reference