Where to put DTB file for UEFI support on ARM

E Shattow lucent at gmail.com
Wed Jun 12 17:12:16 CEST 2024


Hi Leith,

On Wed, Jun 12, 2024 at 5:50 AM Leith Bade <leith at bade.nz> wrote:
>
> Hi all,
>
> I have a BananaPi BPI-R3 board that I am setting up to boot Ubuntu or
> Debian. After figuring out the required config options I have managed to
> get Uboot to boot the Ubuntu USB installer, and also boot off an SD card
> once I installed Ubuntu there.
>
> I set up the bootmeth/bootdev/bootflow stuff so that the auto boot menu
> works nicely with SD card. For USB I have to drop to console and do manual
> "usb start" etc, but good enough for running the installer. It was a bit
> difficult as there seems to be a lot of older documentation or Google
> results related to using UEFI before the bootflow stuff was added. Also it
> took me a while to figure out that a board/mediatek/mt7986.env file is now
> needed as some of the config options set #define values that are not
> included in /include/configs/mt7986.h board headers - due to .env files
> replacing those #defines. It would be nice to have a default .env file for
> this board that sets sensible defaults for the various memory loading
> addresses as it took a bit of effort to come up with all the hex values.
>
> However I am struggling to work out where to place the device tree DTB file
> for the Linux kernel. For this board I need a different DTB for
> U-boot (which is included in the u-boot.bin and fip.bin) and the kernel as
> U-boot's drivers do not like the Linux upstream device tree.
>
> I can see in the UEFI bootmeth code that it searches a location /dtb/ for a
> file named in the $fdtfile environment variable. I tried putting the .dtb
> file at /dtb/mt7986a-bananapi-bpi-r3.dtb on the SD card's FAT32 partition
> that Ubuntu created, however it doesn't seem to load this and the U-boot
> boots with the u-boot.bin DTB which means kernel doesn't start If I
> manually load the correct .dtb file to $fdt_addr_r then the correct DTB is
> used and the kernel starts.

Correct, this is a limitation and the fix is not yet released with
U-Boot;  It is now queued up for U-Boot -next, but only for EFI
bootmanager (not the global EFI boot).

>
> What is the correct location for the .dtb file when using UEFI?

In theory you could just load it from the target Linux OS root
filesystem at /usr/lib/linux-image-... but when I try this there's no
support to read that filesystem within EFI bootmanager;  the files
referenced by EFI bootmanager are however accessible if on the EFI
System Partition. Perhaps I am missing some option to support loading
from partitions other than the EFI System Partition but I don't know
how.

>
> Is there a recommended way of putting the kernel DTB into the NAND or NOR
> chip when using UEFI? That way if the SD card gets wiped U-boot can still
> boot the USB drive. I don't fully understand how the MTD partitions, FIT
> files, UBI files all fit into the picture to have U-boot load the kernel
> DTB from flash.

U-Boot has its own internal FDT (firmware devicetree) which you note
may or may not work well enough to boot Linux kernel and have a
working OS userspace. It is ambiguous if a Linux OS kernel dtb of a
specific board hardware target belongs in any of NAND or NOR flash
since they tend to be tied to specific versions of the Linux kernel,
as things are today. There's no consensus that I've read anywhere on
how this should be done - again not specific to U-Boot.

I can just say from experience that if it would be able to be loaded
from the same rootfs that the Linux kernel resides then there is still
the trouble of not knowing which exact Linux kernel version that the
user will decide to load that boot cycle.

>
> Thanks,
> Leith Bade
> leith at bade.nz

-E Shattow


More information about the U-Boot mailing list