Reading from ISO9660 in U-Boot

Hi Heinrick & Bin,
I'd like to be able to figure out in U-Boot what OS is on a USB stick. For example, with the Ubuntu installer, I can boot it (through grub), but I cannot see how to read anything useful from the USB stick that would indicate that it is Ubuntu, what version it is, etc.
Does U-Boot need an ISO9660-filesystem driver for that? Is there any other way?
With Debian I can see the actual files (linux and initrd) , so it is a bit easier.
Regards, SImon

On 9/23/23 00:13, Simon Glass wrote:
Hi Heinrick & Bin,
I'd like to be able to figure out in U-Boot what OS is on a USB stick. For example, with the Ubuntu installer, I can boot it (through grub), but I cannot see how to read anything useful from the USB stick that would indicate that it is Ubuntu, what version it is, etc.
Does U-Boot need an ISO9660-filesystem driver for that? Is there any other way?
With Debian I can see the actual files (linux and initrd) , so it is a bit easier.
Regards, SImon
The format of the Ubuntu images depends on the architecture. Let's assume that you relate to amd64 (https://cdimage.ubuntu.com/daily-live/current/mantic-desktop-amd64.iso).
This is a hybrid image, which can be either read as ISO 9660 or as a GPT partitioned image. This is the gdisk output:
Number Start (sector) End (sector) Size Code Name 1 64 10049451 4.8 GiB 0700 ISO9660 2 10049452 10059487 4.9 MiB EF00 Appended2 3 10059488 10060087 300.0 KiB 0700 Gap1
You can mount partition 2 as FAT file system in Linux:
$ sudo kpartx mantic-desktop-amd64.iso -a -v [sudo] password for zfsdt: add map loop1p1 (252:4): 0 10049388 linear 7:1 64 add map loop1p2 (252:5): 0 10036 linear 7:1 10049452 add map loop1p3 (252:6): 0 600 linear 7:1 10059488
$ sudo mount /dev/mapper/loop1p2 /mnt
$ mount /dev/mapper/loop1p2 on /mnt type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
The problem is upstream U-Boot is that the partition drivers are scanned alphabetically: a_efi, dos, iso
If we change this to a_iso, b_efi, dos, we can read the ISO image:
=> host bind 0 /tmp/mantic-desktop-amd64.iso => part list host 0
Partition Map for HOST device 0 -- Partition Type: ISO
Part Start Sect x Size Type 1 3684 4 512 U-Boot 2 10049452 10036 512 U-Boot
=> ls host 0:2 EFI/
=> load host 0:2 $kernel_addr_r EFI/boot/bootx64.efi 960472 bytes read in 0 ms
Unfortunately the sandbox crashes when executing the EFI binary.
So let't try qemu-x86_64_defconfig:
qemu-system-x86_64 -m 3G -nographic -bios u-boot.rom \ -drive if=none,file=/tmp/mantic-desktop-amd64.iso,format=raw,id=VIRTIO1 \ -device virtio-blk,drive=VIRTIO1
And voilá your are in GRUB.
As it does not find the /boot directory let's go to the GRUB console:
grub> root=(cd0,gpt1) grub> linux /casper/vmlinuz root=/dev/vda1 efi=debug console=/dev/ttyS0 grub> initrd /casper/initrd grub> boot EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
I have no clue why it stops here.
Best regards
Heinrich

Hi Heinrich,
On Fri, 22 Sept 2023 at 19:02, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 9/23/23 00:13, Simon Glass wrote:
Hi Heinrick & Bin,
I'd like to be able to figure out in U-Boot what OS is on a USB stick. For example, with the Ubuntu installer, I can boot it (through grub), but I cannot see how to read anything useful from the USB stick that would indicate that it is Ubuntu, what version it is, etc.
Does U-Boot need an ISO9660-filesystem driver for that? Is there any other way?
With Debian I can see the actual files (linux and initrd) , so it is a bit easier.
Regards, SImon
The format of the Ubuntu images depends on the architecture. Let's assume that you relate to amd64 (https://cdimage.ubuntu.com/daily-live/current/mantic-desktop-amd64.iso).
This is a hybrid image, which can be either read as ISO 9660 or as a GPT partitioned image. This is the gdisk output:
Number Start (sector) End (sector) Size Code Name 1 64 10049451 4.8 GiB 0700 ISO9660 2 10049452 10059487 4.9 MiB EF00 Appended2 3 10059488 10060087 300.0 KiB 0700 Gap1
You can mount partition 2 as FAT file system in Linux:
$ sudo kpartx mantic-desktop-amd64.iso -a -v [sudo] password for zfsdt: add map loop1p1 (252:4): 0 10049388 linear 7:1 64 add map loop1p2 (252:5): 0 10036 linear 7:1 10049452 add map loop1p3 (252:6): 0 600 linear 7:1 10059488
$ sudo mount /dev/mapper/loop1p2 /mnt
$ mount /dev/mapper/loop1p2 on /mnt type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
The problem is upstream U-Boot is that the partition drivers are scanned alphabetically: a_efi, dos, iso
If we change this to a_iso, b_efi, dos, we can read the ISO image:
=> host bind 0 /tmp/mantic-desktop-amd64.iso => part list host 0
Partition Map for HOST device 0 -- Partition Type: ISO
Part Start Sect x Size Type 1 3684 4 512 U-Boot 2 10049452 10036 512 U-Boot
=> ls host 0:2 EFI/
=> load host 0:2 $kernel_addr_r EFI/boot/bootx64.efi 960472 bytes read in 0 ms
Unfortunately the sandbox crashes when executing the EFI binary.
So let't try qemu-x86_64_defconfig:
qemu-system-x86_64 -m 3G -nographic -bios u-boot.rom \ -drive if=none,file=/tmp/mantic-desktop-amd64.iso,format=raw,id=VIRTIO1 \ -device virtio-blk,drive=VIRTIO1
And voilá your are in GRUB.
As it does not find the /boot directory let's go to the GRUB console:
I'm not sure what is going on there, as for me 'bootflow scan -lb usb' boots automaticaly.
grub> root=(cd0,gpt1) grub> linux /casper/vmlinuz root=/dev/vda1 efi=debug console=/dev/ttyS0 grub> initrd /casper/initrd grub> boot EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
I have no clue why it stops here.
That's the efi_gop graphics bug. I sent a v2 patch for it[1]
Regards, Simon
[1] https://patchwork.ozlabs.org/project/uboot/patch/20230922153814.v2.1.I9f7f37...

On 9/23/23 00:13, Simon Glass wrote:
Hi Heinrich & Bin,
I'd like to be able to figure out in U-Boot what OS is on a USB stick. For example, with the Ubuntu installer, I can boot it (through grub), but I cannot see how to read anything useful from the USB stick that would indicate that it is Ubuntu, what version it is, etc.
Does U-Boot need an ISO9660-filesystem driver for that? Is there any other way?
With Debian I can see the actual files (linux and initrd) , so it is a bit easier.
Regards, SImon
U-Boot only needs to support reading the ESP to boot. GRUB comes with a 9660 driver.
On Ubuntu server installer images linux and initrd are in directory casper/ in the ISO9660 file-system.
There is also a file dists/mantic/Release
$ cat dists/mantic/Release Origin: Ubuntu Label: Ubuntu Suite: mantic Version: 23.10 Codename: mantic Date: Tue, 19 Sep 2023 23:07:01 UTC Architectures: amd64 i386 Components: main restricted Description: Ubuntu Mantic 23.10 Acquire-By-Hash: yes
Best regards
Heinrich

Hi Heinrich,
On Fri, 22 Sept 2023 at 19:38, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 9/23/23 00:13, Simon Glass wrote:
Hi Heinrich & Bin,
I'd like to be able to figure out in U-Boot what OS is on a USB stick. For example, with the Ubuntu installer, I can boot it (through grub), but I cannot see how to read anything useful from the USB stick that would indicate that it is Ubuntu, what version it is, etc.
Does U-Boot need an ISO9660-filesystem driver for that? Is there any other way?
With Debian I can see the actual files (linux and initrd) , so it is a bit easier.
Regards, SImon
U-Boot only needs to support reading the ESP to boot. GRUB comes with a 9660 driver.
Yes, but this is not about booting, it is about visibility into what is being booted. Perhaps Ubuntu could put some information in partition 2?
On Ubuntu server installer images linux and initrd are in directory casper/ in the ISO9660 file-system.
There is also a file dists/mantic/Release
$ cat dists/mantic/Release Origin: Ubuntu Label: Ubuntu Suite: mantic Version: 23.10 Codename: mantic Date: Tue, 19 Sep 2023 23:07:01 UTC Architectures: amd64 i386 Components: main restricted Description: Ubuntu Mantic 23.10 Acquire-By-Hash: yes
That would be useful info. Ideally we would have a standard format for this file across all distros, perhaps something that VBE can help with.
Regards, Simon

Am 23. September 2023 16:36:32 MESZ schrieb Simon Glass sjg@chromium.org:
Hi Heinrich,
On Fri, 22 Sept 2023 at 19:38, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 9/23/23 00:13, Simon Glass wrote:
Hi Heinrich & Bin,
I'd like to be able to figure out in U-Boot what OS is on a USB stick. For example, with the Ubuntu installer, I can boot it (through grub), but I cannot see how to read anything useful from the USB stick that would indicate that it is Ubuntu, what version it is, etc.
Does U-Boot need an ISO9660-filesystem driver for that? Is there any other way?
With Debian I can see the actual files (linux and initrd) , so it is a bit easier.
Regards, SImon
U-Boot only needs to support reading the ESP to boot. GRUB comes with a 9660 driver.
Yes, but this is not about booting, it is about visibility into what is being booted. Perhaps Ubuntu could put some information in partition 2?
On Ubuntu server installer images linux and initrd are in directory casper/ in the ISO9660 file-system.
There is also a file dists/mantic/Release
$ cat dists/mantic/Release Origin: Ubuntu Label: Ubuntu Suite: mantic Version: 23.10 Codename: mantic Date: Tue, 19 Sep 2023 23:07:01 UTC Architectures: amd64 i386 Components: main restricted Description: Ubuntu Mantic 23.10 Acquire-By-Hash: yes
That would be useful info. Ideally we would have a standard format for this file across all distros, perhaps something that VBE can help with.
What problem do you want to solve? During installation you should know what you have downloaded.
Afterwards UEFI boot options should receive reasonable labels.
Best regards
Heinrich
Regards, Simon

Hi Heinrich,
On Sat, 23 Sept 2023 at 12:41, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Am 23. September 2023 16:36:32 MESZ schrieb Simon Glass sjg@chromium.org:
Hi Heinrich,
On Fri, 22 Sept 2023 at 19:38, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 9/23/23 00:13, Simon Glass wrote:
Hi Heinrich & Bin,
I'd like to be able to figure out in U-Boot what OS is on a USB stick. For example, with the Ubuntu installer, I can boot it (through grub), but I cannot see how to read anything useful from the USB stick that would indicate that it is Ubuntu, what version it is, etc.
Does U-Boot need an ISO9660-filesystem driver for that? Is there any other way?
With Debian I can see the actual files (linux and initrd) , so it is a bit easier.
Regards, SImon
U-Boot only needs to support reading the ESP to boot. GRUB comes with a 9660 driver.
Yes, but this is not about booting, it is about visibility into what is being booted. Perhaps Ubuntu could put some information in partition 2?
On Ubuntu server installer images linux and initrd are in directory casper/ in the ISO9660 file-system.
There is also a file dists/mantic/Release
$ cat dists/mantic/Release Origin: Ubuntu Label: Ubuntu Suite: mantic Version: 23.10 Codename: mantic Date: Tue, 19 Sep 2023 23:07:01 UTC Architectures: amd64 i386 Components: main restricted Description: Ubuntu Mantic 23.10 Acquire-By-Hash: yes
That would be useful info. Ideally we would have a standard format for this file across all distros, perhaps something that VBE can help with.
What problem do you want to solve? During installation you should know what you have downloaded.
Afterwards UEFI boot options should receive reasonable labels.
I want to show it in the U-Boot boot menu.
Regards, Simon
Best regards
Heinrich
Regards, Simon
participants (2)
-
Heinrich Schuchardt
-
Simon Glass