Proper way to pass a new DTB to l4t_initrd_flash.sh

This is my situation.

I have a custom board derived from the P3731-0005.

For this board I created a new kernel DTB derived from tegra234-p3737-0000+p3701-0005-nv.dts, let’s call that custom.dts that is compiled into custom_kernel.dtb, for now we can assume that the content of this DTB is the same as the one for the pristine p3701-0005.

For this board I also have a custom conf file, let’s call that custom.conf that is carrying some customizations, for example we can assume that the content of this file is:

source "${LDK_DIR}/jetson-agx-orin-devkit.conf";

CMDLINE_ADD="mminit_loglevel=4 console=ttyTCU0,115200 console=ttyAMA0,115200 firmware_class.path=/etc/firmware fbcon=map:2 nospectre_bhb video=efifb:off"

Now my question is: what is the correct way to force the build system to use my custom.dtb as kernel DTB instead of tegra234-p3737-0000+p3701-0005-nv.dtb?

Adding DTB_FILE=custom_kernel.dtb into custom.conf is not really working because the custom_kernel.dtb is not even copied in the MFI rootfs.

Looking into flash.sh it looks like there is another different variable called DTBFILE that we can use (equivalent of using the -d parameter for flash.sh), but again it is not clear if this is the correct way forward and if this DTB file is used by kernel, bootloader or both.

So, my general question is: what is the correct way to inject a custom kernel DTB into the build system to be used at MFI image generation time?

The MFI is created by BOARDSKU=0005 BOARDID=3701 FAB=500 ./tools/kernel_flash/l4t_initrd_flash.sh --no-flash --massflash custom mmcblk0p1

Will your custom.dtb get copied to rootfs if you use flash.sh instead of initrd flash tool?

Ok, I see what’s going on.

The custom.conf is sourcing jetson-agx-orin-devkit.conf that is basically overriding DTB_FILE as soon as update_flash_args_p3737_0000_p3701_0000() is called.

Now, in theory we want to source p3701.conf.common instead but we are going to lose important settings like PMIC_CONFIG.

So either we copy entirely jetson-agx-orin-devkit.conf over custom.conf and we make adjustments there or we set DTBFILE instead of DTB_FILE passing the location of the DTB file under kernel/dtb.

This is honestly quite confusing. Is there any drawback in using DTBFILE instead of DTB_FILE in the board configuration file?

I would suggest you just use DTB_FILE.

What you are playing is actually not validated very much. Those parameters have been in the flash tool for like a decade.
I don’t guarantee it would totally work as expected as in most of time we are using here is put the those XXX_FILE into board config file.