DTB modification on Xavier NX

I needed to modify the device tree, and followed the instructions to create an overlay and run the script to place it in /boot and modify extlinux.conf. It ran but then wouldn’t boot, so tried to boot all the provided dtb’s, and no luck - stopping at various points.

I dd’d the DTB partition and trimmed it to just the DTB bytes, and that was the only DTB file I could get to boot. That file didn’t match the size of any of the binaries in /boot etc, but when referenced from extlinux.conf it worked, and decompiling, modifying and recompiling also worked, so unblocked me.

Just wanted to put the note here to save someone else time trying to use the DTBs - it seems none of them match the one in the partition, and pointing to them from extlinux.conf didn’t work.

I’m sure going through the full process of building a kernel and flashing etc from another host would work, but for anyone in my position where you just need to make a small change, this may help.

For anyone who needs to do this, here is the code I used, from a stackoverflow post (linked below):

#copy the DTB partition to a file (use parted to list partition names to find it)
dd if=/dev/mmcblk0p4 of=recovery.PARTITION-second
sudo apt install binwalk
#Get offset of embedded DTB in recovery.PARTITION-second by searching for bytes D00DFEED
DTBOFFSET=$(binwalk -R “\xD0\x0D\xFE\xED” recovery.PARTITION-second | awk 'NR > 3 { print 1}' | head -n 1) #Get length of DTB in recovery.PARTITION-second this is next 4 bytes after D00DFEED DTBLEN=((16#(dd if=recovery.PARTITION-second bs=1 skip=(($DTBOFFSET + 4)) count=4 status=none | od -tx1 | head -n 1 | cut -d ’ ’ -f 2- | sed ‘s/ //g’ )))
#Now extract and create dtb file
dd if=recovery.PARTITION-second of=mybox.dtb bs=1 skip=$DTBOFFSET count=$DTBLEN

hello luke8,

please check the flashing logs.
you’ll found that several partitions were signed and encrypted before flashing to its partitions.
for example,

[ 459.4635 ] Writing partition kernel with boot_sigheader.img.encrypt
[ 459.5061 ] [................................................] 100%

[ 464.1538 ] Writing partition kernel-dtb with tegra194-p3668-all-p3509-0000_sigheader.dtb.encrypt
[ 464.1617 ] [................................................] 100%

you may also refer to developer guide, and please check CBoot session.
those binaries under /boot/ did not signed and encrypted, you may also load device tree by using extlinux.conf.
please specify a FDT entry in the configure file to have an alternative way to load the kernel-dtb binary file from FDT entry.