12

I've read numerous times that the raspberry pi doesn't support grub. I've not been able to find any specifics about the incompatibility. I've only found rather blunt statements of the form "it's not supported".

I would like to understand exactly what the issue is and what would need to be re-written to make it work.

What I have found so far is that the stage 3 bootloader reads start.elf which in turn reads the kernel image. To my mind, if grub were to work it would replace (entirely) start.elf. I've looked at the format of UEFI bootloaders and discovered that they use a PE format executable. So my first hypothesis is that the incompatibility is (only) that grub is compiled as a PE and stage 3 only reads ELF.

Have I missed some other major incompatibility? Have I missed some other major task of start.elf which would be lost if it were replaced by grub?

Philip Couling
  • 508
  • 2
  • 5
  • 16

2 Answers2

6

Actually, if you want to install Ubuntu with a generic kernel on your Raspberry Pi, you have to use grub2, as described here.

The only compatibility quirk is that grub2 may set the EFI flag on the boot partition, and the RPi bootloader will refuse to boot off a partition with an EFI flag set. The flag can be manually cleared by any partition editor, making both RPi bootloader and grub2 recognize the partition correctly.

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
3

The Raspberry Pi is special that the primary (on-chip ROM) , secondary (bootcode.bin) and third bootloader (start.elf) are executed on its GPU, one chainloading the other. The instruction set is not properly documented and start.elf itself top-secret.

What can be done (as SuSE and Microsoft have demonstrated) is to replace kernel.img at will - even with a custom version of TianoCore (an open-source UEFI implementation) or U-Boot. This can then be used to start an UEFI-compatible GRUB2 or BOOTMGR binary.

flakeshake
  • 6,235
  • 1
  • 14
  • 33
  • Indeed. The Raspberry Pi 3 actually has a mature UEFI firmware now, and work is ongoing to bring the same for the Pi 4. With this, you can easily install vanilla Linux distributions and use GRUB as your bootloader. An example of vanilla Debian install with GRUB can be found here for instance. – Akeo Jan 14 '20 at 17:51