bootstd regression from distro_bootcmd for removable EFI boot and weird return codes for fs
Da Xue
da at libre.computer
Mon Jul 24 18:48:57 CEST 2023
On Mon, Jul 24, 2023 at 11:48 AM Da Xue <da at lessconfused.com> wrote:
>
> I forgot to attach some additional details:
>
> ```
> sudo fdisk -l /dev/sda
> Disk /dev/sda: 58.24 GiB, 62534975488 bytes, 122138624 sectors
> Disk model: STORAGE DEVICE
> Units: sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disklabel type: dos
> Disk identifier: 0x00000000
>
> Device Boot Start End Sectors Size Id Type
> /dev/sda1 * 2048 524287 522240 255M ef EFI (FAT-12/16/32)
> ```
>
> The image was generated via buildroot using genimage:
>
> ```
> image boot.vfat {
> vfat {
> file EFI/BOOT/BOOTAA64.EFI {
> image = "Image"
> }
> extraargs = "-F32" # tried with and without this flag,
> same issue.
> }
> size = 255M
> }
>
> image sdcard.img {
> hdimage {
> }
> partition bootloader {
> in-partition-table = false
> offset = 512
> image = "u-boot.bin"
> }
> partition rootfs {
> partition-type = 0xEF
> bootable = "true"
> image = "boot.vfat"
> offset = 1M
> }
> }
> ```
>
> bootflow -la without the debug messages:
>
> ```
> => bootflow scan -la
> Scanning for bootflows in all bootdevs
> Seq Method State Uclass Part Name Filename
> --- ----------- ------ -------- ---- ------------------------
> ----------------
> Scanning global bootmeth 'efi_mgr':
> 0 efi_mgr base (none) 0 <NULL> <NULL>
> Scanning bootdev 'mmc at 74000.bootdev':
> 1 efi media mmc 0 mmc at 74000.bootdev.whole <NULL>
> 2 extlinux media mmc 0 mmc at 74000.bootdev.whole <NULL>
> 3 script media mmc 0 mmc at 74000.bootdev.whole <NULL>
> Scanning bootdev 'mmc at 72000.bootdev':
> 4 efi media mmc 0 mmc at 72000.bootdev.whole <NULL>
> 5 extlinux media mmc 0 mmc at 72000.bootdev.whole <NULL>
> 6 script media mmc 0 mmc at 72000.bootdev.whole <NULL>
> 7 efi file mmc 1 mmc at 72000.bootdev.part_1
> efi/boot/bootaa64.efi
> 8 extlinux fs mmc 1 mmc at 72000.bootdev.part_1
> /boot/extlinux/extlinux.conf
> 9 script fs mmc 1 mmc at 72000.bootdev.part_1
> /boot/boot.scr
> a efi media mmc 2 mmc at 72000.bootdev.part_2 <NULL>
> b extlinux media mmc 2 mmc at 72000.bootdev.part_2 <NULL>
> c script media mmc 2 mmc at 72000.bootdev.part_2 <NULL>
> d efi media mmc 3 mmc at 72000.bootdev.part_3 <NULL>
> e extlinux media mmc 3 mmc at 72000.bootdev.part_3 <NULL>
> f script media mmc 3 mmc at 72000.bootdev.part_3 <NULL>
> 10 efi media mmc 4 mmc at 72000.bootdev.part_4 <NULL>
> 11 extlinux media mmc 4 mmc at 72000.bootdev.part_4 <NULL>
> 12 script media mmc 4 mmc at 72000.bootdev.part_4 <NULL>
> 13 efi media mmc 5 mmc at 72000.bootdev.part_5 <NULL>
> 14 extlinux media mmc 5 mmc at 72000.bootdev.part_5 <NULL>
> 15 script media mmc 5 mmc at 72000.bootdev.part_5 <NULL>
> 16 efi media mmc 6 mmc at 72000.bootdev.part_6 <NULL>
> 17 extlinux media mmc 6 mmc at 72000.bootdev.part_6 <NULL>
> 18 script media mmc 6 mmc at 72000.bootdev.part_6 <NULL>
> 19 efi media mmc 7 mmc at 72000.bootdev.part_7 <NULL>
> 1a extlinux media mmc 7 mmc at 72000.bootdev.part_7 <NULL>
> 1b script media mmc 7 mmc at 72000.bootdev.part_7 <NULL>
> 1c efi media mmc 8 mmc at 72000.bootdev.part_8 <NULL>
> 1d extlinux media mmc 8 mmc at 72000.bootdev.part_8 <NULL>
> 1e script media mmc 8 mmc at 72000.bootdev.part_8 <NULL>
> 1f efi media mmc 9 mmc at 72000.bootdev.part_9 <NULL>
> 20 extlinux media mmc 9 mmc at 72000.bootdev.part_9 <NULL>
> 21 script media mmc 9 mmc at 72000.bootdev.part_9 <NULL>
> 22 efi media mmc a mmc at 72000.bootdev.part_a <NULL>
> 23 extlinux media mmc a mmc at 72000.bootdev.part_a <NULL>
> 24 script media mmc a mmc at 72000.bootdev.part_a <NULL>
> 25 efi media mmc b mmc at 72000.bootdev.part_b <NULL>
> 26 extlinux media mmc b mmc at 72000.bootdev.part_b <NULL>
> 27 script media mmc b mmc at 72000.bootdev.part_b <NULL>
> 28 efi media mmc c mmc at 72000.bootdev.part_c <NULL>
> 29 extlinux media mmc c mmc at 72000.bootdev.part_c <NULL>
> 2a script media mmc c mmc at 72000.bootdev.part_c <NULL>
> 2b efi media mmc d mmc at 72000.bootdev.part_d <NULL>
> 2c extlinux media mmc d mmc at 72000.bootdev.part_d <NULL>
> 2d script media mmc d mmc at 72000.bootdev.part_d <NULL>
> 2e efi media mmc e mmc at 72000.bootdev.part_e <NULL>
> 2f extlinux media mmc e mmc at 72000.bootdev.part_e <NULL>
> 30 script media mmc e mmc at 72000.bootdev.part_e <NULL>
> 31 efi media mmc f mmc at 72000.bootdev.part_f <NULL>
> 32 extlinux media mmc f mmc at 72000.bootdev.part_f <NULL>
> 33 script media mmc f mmc at 72000.bootdev.part_f <NULL>
> 34 efi media mmc 10 mmc at 72000.bootdev.part_10 <NULL>
> 35 extlinux media mmc 10 mmc at 72000.bootdev.part_10 <NULL>
> 36 script media mmc 10 mmc at 72000.bootdev.part_10 <NULL>
> 37 efi media mmc 11 mmc at 72000.bootdev.part_11 <NULL>
> 38 extlinux media mmc 11 mmc at 72000.bootdev.part_11 <NULL>
> 39 script media mmc 11 mmc at 72000.bootdev.part_11 <NULL>
> 3a efi media mmc 12 mmc at 72000.bootdev.part_12 <NULL>
> 3b extlinux media mmc 12 mmc at 72000.bootdev.part_12 <NULL>
> 3c script media mmc 12 mmc at 72000.bootdev.part_12 <NULL>
> 3d efi media mmc 13 mmc at 72000.bootdev.part_13 <NULL>
> 3e extlinux media mmc 13 mmc at 72000.bootdev.part_13 <NULL>
> 3f script media mmc 13 mmc at 72000.bootdev.part_13 <NULL>
> 40 efi media mmc 14 mmc at 72000.bootdev.part_14 <NULL>
> 41 extlinux media mmc 14 mmc at 72000.bootdev.part_14 <NULL>
> 42 script media mmc 14 mmc at 72000.bootdev.part_14 <NULL>
> 43 efi media mmc 15 mmc at 72000.bootdev.part_15 <NULL>
> 44 extlinux media mmc 15 mmc at 72000.bootdev.part_15 <NULL>
> 45 script media mmc 15 mmc at 72000.bootdev.part_15 <NULL>
> 46 efi media mmc 16 mmc at 72000.bootdev.part_16 <NULL>
> 47 extlinux media mmc 16 mmc at 72000.bootdev.part_16 <NULL>
> 48 script media mmc 16 mmc at 72000.bootdev.part_16 <NULL>
> 49 efi media mmc 17 mmc at 72000.bootdev.part_17 <NULL>
> 4a extlinux media mmc 17 mmc at 72000.bootdev.part_17 <NULL>
> 4b script media mmc 17 mmc at 72000.bootdev.part_17 <NULL>
> 4c efi media mmc 18 mmc at 72000.bootdev.part_18 <NULL>
> 4d extlinux media mmc 18 mmc at 72000.bootdev.part_18 <NULL>
> 4e script media mmc 18 mmc at 72000.bootdev.part_18 <NULL>
> 4f efi media mmc 19 mmc at 72000.bootdev.part_19 <NULL>
> 50 extlinux media mmc 19 mmc at 72000.bootdev.part_19 <NULL>
> 51 script media mmc 19 mmc at 72000.bootdev.part_19 <NULL>
> 52 efi media mmc 1a mmc at 72000.bootdev.part_1a <NULL>
> 53 extlinux media mmc 1a mmc at 72000.bootdev.part_1a <NULL>
> 54 script media mmc 1a mmc at 72000.bootdev.part_1a <NULL>
> 55 efi media mmc 1b mmc at 72000.bootdev.part_1b <NULL>
> 56 extlinux media mmc 1b mmc at 72000.bootdev.part_1b <NULL>
> 57 script media mmc 1b mmc at 72000.bootdev.part_1b <NULL>
> 58 efi media mmc 1c mmc at 72000.bootdev.part_1c <NULL>
> 59 extlinux media mmc 1c mmc at 72000.bootdev.part_1c <NULL>
> 5a script media mmc 1c mmc at 72000.bootdev.part_1c <NULL>
> 5b efi media mmc 1d mmc at 72000.bootdev.part_1d <NULL>
> 5c extlinux media mmc 1d mmc at 72000.bootdev.part_1d <NULL>
> 5d script media mmc 1d mmc at 72000.bootdev.part_1d <NULL>
> No more bootdevs
> --- ----------- ------ -------- ---- ------------------------
> ----------------
> (94 bootflows, 0 valid)
> ```
>
> ls return 1
>
> ```
> => ls mmc 1 /efi/boot
> ./
> ../
> 51806720 BOOTAA64.EFI
>
> 1 file(s), 2 dir(s)
>
> => echo $?
> 0
> => ls mmc 1 /efi/boot/bootaa64.efi
> => echo $?
> 1
> => ls mmc 1 /EFI/boot/BOOTAA64.EFI
> => echo $?
> 1
> => ls mmc 1 /
> EFI/
>
> 0 file(s), 1 dir(s)
>
> => ls mmc 1 /EFI/
> ./
> ../
> BOOT/
>
> 0 file(s), 3 dir(s)
>
> => ls mmc 1 /EFI/BOOT/BOOTAA64.EFI
> => echo $?
> 1
> => ls mmc 1 /EFI/BOOT
> ./
> ../
> 51806720 BOOTAA64.EFI
The issue ended up being the memory allocation. The file was too big
(50MB). `bootflow scan -lae mmc1`
In boot/bootmeth_efi.c, bootmeth_alloc_file is set to a pre-defined
32MB so bootefi cannot boot anything larger than that even if you have
CONFIG_SYS_MALLOC_LEN set to something larger.
Hope this helps someone.
>
> 1 file(s), 2 dir(s)
>
> => ls mmc 1 /EFI/BOOT/nonexist
> => echo $?
> 1
> ```
>
> On Mon, Jul 24, 2023 at 11:35 AM Da Xue <da at libre.computer> wrote:
> >
> > Hi,
> >
> > I switch to bootstd and I am experiencing an issue with bootstd not
> > detected EFI bootable file in /EFI/BOOT/BOOTAA64.EFI in certain image,
> > buildroot specifically. The same setup works fine with distro_bootcmd.
> > I have attached the logs. I have tried the following:
> >
> > 1) Directory and filename case upper and lower
> > 2) FAT32 and FAT16 filesystem
> > 3) Changing the size of the filesystem
> >
> > I noticed some particular weirdness with u-boot's return code for
> > functions dealing with fs_exists that might be related.
> >
> > 1) FAT/FAT32 driver uses fs_ls_generic. When you do `ls mmc 1
> > /filename`, it returns 1 if the file exists and returns 1 when the
> > file doesn't exist.
> > 2) This issue follows fs_exists. Is this a bug or intended behavior?
> >
> > Best,
> > Da
More information about the U-Boot
mailing list