Wednesday 25 January 2012

Joggler: Installing rEFIt

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

In the last part I explained how the Joggler boots its retail firmware, and the ways in which the boot process can be interfered with. The first step to getting somewhere is to get a proper bootloader on there; one that can give you access to an EFI shell and tools, and can boot other things without fiddly editing of scripts or pressing ESC repeatedly.

rEFIt is a Mac EFI bootloader which gives you a nice graphical menu of possible EFI programs to boot, and comes with a shell and tools. It's not the ideal bootloader for Linux since it can't directly load a Linux kernel, but it can load an EFI GRUB binary for that. I don't want to rely on rEFIt permanently because I don't know how to build it or where to obtain a binary of guaranteed provenance; this defeats the point of the "booting stock Debian" exercise; but it's a useful tool while messing around with the boot configuration.


The rEFIt binaries available from the project itself don't work on the Joggler; Apple invented a "fat" EFI binary format that supports both 32-bit and 64-bit x86, but this isn't in the EFI spec and non-Mac implementations don't support it. Compiling rEFIt from source is also difficult; the toolchain provided by Intel runs on Windows as part of Visual Studio, and the free toolchains that run on Linux are not fully compatible and can't compile rEFIt, at least not with the default configuration.

Since I only intend for this to be temporary, I'm just using binaries made for the Joggler by someone else, available here. The setup instructions there are a pain, though, as they assume you have already hacked the Joggler's original firmware to have SSH access. So, what I did:
  1. Pull the "efi" directory out of the tarball and put it on a FAT-formatted USB stick.
  2. Power up the joggler and hammer on ESC until it stops booting and drops to the invisible builtin shell.
  3. Launch rEFIt directly from the USB stick by typing, blindly:
    • fs1:
    • cd efi\refit
    • refit
  4. Pick "Start EFI Shell", then hit ESC to stop that shell from executing startup.nsh (which would just boot the original firmware).
  5. Copy rEFIt onto the internal eMMC:
    • cp -r fs1:\efi fs0:
  6. Add a boot manager entry, before the default one, which launches rEFIt from the internal eMMC:
    • bcfg boot add 01 fs0:\efi\refit\refit.efi
Now, when it powers on, it will boot rEFIt (always, no matter what's on any inserted USB device) and offer the choice of all the EFI binaries found on any connected device; at minimum, the boot.efi on the internal eMMC which boots the original firmware (which will still work if selected; nothing has been replaced). You can now start GRUB or elilo or any other EFI program you like directly from the USB stick without needing to create a startup.nsh or boot.nsh for it, and get to the EFI shell (primarily to be able to change the boot manager config) any time. This is a pretty handy setup for further boot experimentation, and when I've sorted out a "real" Linux bootloader I can replace rEFIt with it using the same procedure.

No comments:

Post a Comment