Finally figured it out! So, the main “thing” which will boot the device is the “bootm” magic command. I found this, doc/usage/cmd/bootm.rst · 36239d348ffdbf14c3792a2fc0b3f2ac7e6daffc · U-Boot / U-Boot · GitLab about some sub-commands which can be used to do the work step by step. So, the single “bootm $loadaddr#$bootconf#$bootconf_emmc#$bootconf_extra” can be replaced with these commands:
bootm start $loadaddr#$bootconf#$bootconf_emmc#$bootconf_extra
bootm loados
bootm ramdisk
bootm fdt
bootm prep
fdt set /chosen u-boot,bootconf $bootconf#$bootconf_emmc#$bootconf_extra
bootm go
I did not know why, but “bootm prep” sets the /chosen/u-boot,bootconf to a single 0x00 byte, which prevents the system from booting, but setting this up by hand fixes the issue, and the device came up perfectly fine.
On my device, the second partition on the eMMC (which was named “factory”) is empty, so that will be the perfect place to store the compiled overlay, which can be copied there with a simple dd, which can be loaded from U-boot with those commands:
part start mmc 0 factory devicetree_address
part size mmc 0 factory devicetree_sizeinblocks
mmc read 0x60000000 $devicetree_address $devicetree_sizeinblocks
My first concern is where to load this. The original FIT image will be loaded to 0x50000000, so I simply chose 0x60000000 for mine. I did not know if it’s okay, or not, but it works. The next thing will be to apply the overlay on the original devicetree with “fdt apply”.
The whole process will look like this:
bootm start $loadaddr#$bootconf#$bootconf_emmc#$bootconf_extra
bootm loados
bootm ramdisk
bootm fdt
part start mmc 0 factory devicetree_address
part size mmc 0 factory devicetree_sizeinblocks
mmc read 0x60000000 $devicetree_address $devicetree_sizeinblocks
fdt apply 0x60000000
bootm prep
fdt set /chosen u-boot,bootconf $bootconf#$bootconf_emmc#$bootconf_extra
bootm go
My next concern is around the size of the device tree binary. There is a command to resize the “container” of the devicetree (fdt resize: Device Tree Overlays — Das U-Boot unknown version documentation), but using it with even a small value (16384), the device will crash on the “bootm prep” stage. If I calculated correctly, just around ~8k is still free in the “original” space and because my compiled dtb is less than 1k I assume it’s safe to use without a resize.
The devicetree source can be compiled on the device if ‘dtc’ is installed.