Re: Some questions about UEFI

Pete Batard <pete@...>

Hi Elena, hi Leif,

I'll add the following comments:

1. Right now, the RPi3 firmware is set not to boot SD/USB by default, but boot into the UEFI Shell always. Therefore, if you want a /efi/boot/bootaa64.efi bootloader residing on an SD card to launch by default, you first have to go to Boot Maintenance Manager → Boot Options → Change Boot Order and then alter the setting to that SD/MMC is the first entry. Alternatively, you can also manually invoke the executable from the Shell (e.g. Navigate to fs0: and then launch /efi/boot/bootaa64.efi).

Obviously, since we agree this is not a very intuitive behaviour, there is a patch lined up (that has not yet been applied) to alter the above and make sure SD/MMC becomes the default for boot, as we reckon most users are likely to be thrown off by the current behaviour.

2. If it helps, please be aware that there exists a in the edk2-platforms RPi3 directory where, for instance, the installation of Ubuntu 18.04 LTS on a Pi 3 Model B is described. See

I haven't tested Raspbian (I believe this is designed specifically to use the default Pi bootloader, so, even if it's targetted for Pi, it might not be the best distribution to install when using the UEFI firmware) but you might be interested to know that I'm currently in the process of adding detailed information on how to install of *vanilla* Debian 10.0 ARM64 on a Pi 3 Model B+, and I am hoping to submit a patch to update with these instructions some time next week.

In case you are interested, I am copy/pasting my current rough draft below.




[Debian 10]( has been tested and
confirmed to work, on a Raspberry 3 Model B+, including the installation process.

Below are the steps you can follow to install Debian 10 onto SD:
* Partition the media as MBR and create a ~300 MB FAT32 partition on it with MBR type `0x0c`
* Copy the UEFI firmware files (`RPI_EFI.fd`, `bootcode.bin`, `fixup.dat` and `start.elf`)
as well as an appropriate `config.txt` onto the FAT partition. If needed you can download
the non UEFI binary files from
If you are using a model B+, don't forget to copy the relevant `.dtb` and reference it in
your `config.txt`.
* Download [`debian-10.0.0-arm64-netinst.iso`](
* Extract the full content of the ISO onto the partition you created.
* Delete `EFI\boot\bootaa64.efi` and rename `EFI\boot\grubaa64.efi` to `EFI\boot\bootaa64.efi`
* Insert the media and power up the Raspberry Pi device.
* On the GRUB menu select `Install`
* Before selecting the language press <kbd>Alt</kbd>-<kbd>F2</kbd> and press <kbd>Enter</kbd>
to activate a console.
* Issue the commands:
mkdir /cdrom
mount -t vfat /dev/mmcblk0p1 /cdrom
This is needed as the Debian installer does not currently know how to detect SD based install
* Go back to the main consolde (<kbd>Alt</kbd>-<kbd>F1</kbd>) and select your language and
keyboard as needed and proceed with the guide prompt with the rest of the installation.
The installer script should properly detect and set up your networking.
Continue until you get to `Partition disks`
* For `Partitioning method` select `Manual`

MMC/SD card #1 (mmcblk0) - 16.0 GB SD 2WCGO
#1 primary 314.6 MB fat16
pri/log FREE SPACE

- Select `#1 primary` and change `Use as:` to `EFI System Partition` then select
`Done setting the partition`.
- Select `FREE SPACE` &rarr; `Create a new partition` and create a `1 GB` swap partition.
- Select `FREE SPACE` &rarr; `Create a new partition` and allocate the rest to an `ext4`
root partition.
After doing this, your partition report should look like this:
MMC/SD card #1 (mmcblk0) - 16.0 GB SD 2WCGO
#1 primary 314.6 MB B K ESP
#2 primary 1.0 GB f swap swap
#3 primary 14.7 GB f ext4 /

* Select `Finish partitioning and write changes to disk` and let the installer continue.
* `Configure the package manager` and `Select and install software` appear to be broken
at this stage, so you should ignore them (you can configure them later).
* Select `Install the GRUB boot loader on a hard disk`
* When the system displays the message `Installation is complete, so it is time to boot into your new system (...)`
go to the other console *<kbd>Alt</kbd>-<kbd>F2</kbd>) and issue the following
(provided that Linux root is your 3rd partition, else you should change `mmcblk0p3`
to the proper value. Note that the first command might not be needed if the installer
still had `/target` properly mounted):
mount -t ext4 /dev/mmcblk0p3 /target
mount -o bind /dev /target/dev
chroot /target /sbin/fdisk /dev/mmcblk0
Then press <kbd>t</kbd>, <kbd>1</kbd>, <kbd>c</kbd> and <kbd>w</kbd> to change the
1st partition type to FAT32. This is needed because the hardcoded bootloader on the
CPU die does not handle type `0xef` (ESP) partitions for boot (but we needed to set
an ESP to keep the Debian installer happy).
* Go back to the installer and reboot the system. You should get the GRUB prompt and
the system should book into the installed Linux. If you don't see the multicoloured
screen when booting the Pi, it's probably because you didn't properly change the
type of the FAT partition back to `0xC`.
* You may want to edit `/etc/apt/sources.list` to:
deb buster main contrib non-free
deb buster-updates main contrib non-free
deb buster/updates main contrib non-free
* At this stage, you should be able to install additional software such as `openssh`
(which is not installed by default) or anything else you need.


On 2019.07.19 10:15, Elena WILLIS wrote:
Hi Leif and Pete,
My answers in blue.
Best regards,
-----Original Message-----
From: Leif Lindholm <leif.lindholm@...>
Sent: vendredi 19 juillet 2019 11:11
To:; Elena WILLIS <elena.willis@...>
Cc: Pete Batard <pete@...>
Subject: Re: [edk2-discuss] Some questions about UEFI
Hi Elena, (+cc Pete)
On Thu, Jul 18, 2019 at 11:54:38AM +0000, Elena WILLIS wrote:

> I am using EDK2 on a Raspberry PI
3B model.

> Installation went fine and I can access the UEFI Shell interface,
where the commands work.


> But I'm now stuck and have a few questions :


> -          Do you have a simple .efi script that I could use to test

> -          my setup ?
.efi indicated an application (or driver), as opposed to a script.
My go-to test case is a standalone GRUB executable.
Generated with grub-mkstandalone -O arm64-efi -o grubstand.efi
Ok I will try this, thank you !

> -          Once I am on the UEFI interface, I can't seem to boot

> -          back onto my OS (Raspbian). Could you please explain how

> -          to do this?
Does 'exit' bring you back to a "BIOS" menu system where you can select boot options?
Yes, it does, but from there I can't get back onto my OS either. :(
Best Regards,

Join { to automatically receive all group messages.