Monday, 30 January 2012

Joggler: Improving GRUB

This is part of my series on running an unmodified Debian on the Joggler. See here for other posts on the same topic.

As explained in my last post, the problem with running a standard Debian kernel (or most other prebuild modern Linux kernels) is that GRUB loads them at the "wrong" address - that is, the address that older versions of the Linux kernel boot protocol expected. Because of the Joggler's weird (and possibly broken) EFI memory map, the kernel needs to be loaded using the new boot protocol 2.10, so that GRUB can choose a correctly aligned address that doesn't overlap any of the EFI mapped areas. However, GRUB 1.99 doesn't support this.

I spoke to Matthew Garrett about this problem, who knows a great deal about EFI booting (and about hideous workarounds for broken hardware). He had a patch in progress already to add this support to GRUB, which I experimented with and gave a few tweaks until it worked on the Joggler. I gave him the modified patch back and hopefully he'll be able to get it tested on more platforms and integrated into GRUB proper, but until then, it does work on the Joggler.

So, if you want to build a GRUB that works on the Joggler right now, just grab the GRUB 1.99 tarball and apply my version of Matthew's patch to it. You don't need any other patches; the Joggler GRUB patch on other sites is used to add EFI GOP video support, which is already included in 1.99.

With this patch, a normal modern kernel which requests 16MB alignment and is relocatable will be loaded at 32MB, to avoid the area at 16MB which is in use by EFI. This is aligned, so the kernel won't attempt to move itself at start, but it won't be the address the kernel is compiled to run at so there will be a tiny (seriously, very tiny) amount of time spent at boot applying the relocations to make it run from 32MB. The standard Debian kernel used to run the installer works fine, and if you also include one of the installer initrd images then the installer boots. There are several problems with trying to actually use the installer, however, so while it boots and you can get to a shell to explore the device, I haven't run out of problems to address yet.

So, as far as GRUB is concerned, if this patch (or a derivative of it) can get into the GRUB tree, then future versions of GRUB (including, say, Debian prebuilt binary packages) will work just fine on the Joggler without any special preparation.

UPDATE: This has now happened, see my post here :)