agherzan / meta-raspberrypi

Yocto/OE BSP layer for the Raspberry Pi boards
https://www.yoctoproject.org/
MIT License
507 stars 397 forks source link

Netboot with Yocto and U-Boot for Pi 4b - DTB Issue #1210

Open KarolPWr opened 11 months ago

KarolPWr commented 11 months ago

I'm working on implementing netboot (via tftp) for Pi 4b using Yocto and U-Boot. Currently, I can successfully load the Image file with tftp and the rootfs with NFS. However, when I use the device tree (dtb) file from tmp/deploy, the boot crashes. The strange thing is that it works flawlessly when booting straight from the SD card, without using tftp.

After some research, I came across information stating that dtb files are patched during boot by the Raspberry Pi firmware, which is likely why they work from the SD card.

My setup currently looks like this:

server/nfsroot/ - filesystem extracted from deploy/images
server/tftpboot/ - Image.bin and bcm/dtb - Image and .dtb copied from deploy 

env set ipaddr <IP>; env set serverip <SRV_IP>;env set nfsroot /nfsroot;env set image Image.bin;env set fdt_file bcm.dtb
env set netload 'tftpboot ${loadaddr} ${image};tftpboot ${fdt_addr} ${fdt_file}'
env set netargs 'setenv bootargs 8250.nr_uarts=1 console=ttyS0,115200 rootwait rw root=/dev/nfs ip=${ipaddr} nfsroot=${serverip}:${nfsroot}'
env set netboot 'run netargs;run netload;booti ${loadaddr} - ${fdt_addr}'

Above will not work - kernel starts, and it mounts the NFS rootfs, but it fails during SD card initialization. Everything works when I don't use the .dtb from tftp and instead remove the line: tftpboot ${fdt_addr} ${fdt_file}. Even if I use the exact same .dtb that is on the SD card, it still does not work.

I'm looking for a proper way to implement fully flexible tftpboot with Image, dtb, and rootfs. How can this be done properly?

Relevant discussions on this topic: 1 2 3 4