Tuesday, 31 January 2012

Joggler: Trying debian-installer

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

Now that I've compiled a GRUB binary that works on the Joggler, I can try booting debian-installer. Being able to run this would be nice, since it means that instead of preparing the system on another machine using debootstrap, you can just install it the usual way. I'm going to be trying to install wheezy, the current testing release; it's too late to fix any issues that come up during a stable install. The development version of debian-installer also has several features that are helpful.

I usually use netboot images to install Debian, though I don't actually boot them from the network. You can boot the netboot kernel and initrd from any existing Linux bootloader, and as long as your network interface is supported by the drivers included, the rest of the install can proceed directly from a Debian mirror, with no need to download an ISO. To try this, you need four things:
  1. A USB stick with a small FAT16 partition.
  2. An EFI GRUB binary built with the patch from my previous post.
  3. The linux and initrd.gz from the d-i daily builds archive, and a grub.cfg which will load them (you don't need any command line arguments).
  4. The firmware for the Joggler's wireless interface: download the firmware archive here and extract the firmware-ralink udeb.

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 :)

Saturday, 28 January 2012

Joggler: Debian kernel doesn't boot

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

Now that the Joggler is booting rEFIt with a functioning keyboard, experimenting with things to boot is easy. The ideal thing to boot would be the standard Debian kernel. If that works, then pretty much any stock Linux distribution kernel should also work. In order to boot it you need an EFI GRUB. I grabbed a premade binary from the Joggler wiki for now (we'll come back to this later).

Unfortunately, while the GRUB binary worked fine, the kernel doesn't boot, with no indication of why. This is tricky to debug; since the Joggler doesn't have standard VGA, you don't get any console messages on the screen until it's booted far enough to activate efifb, the framebuffer driver which talks to the EFI video output system. It also doesn't have a serial port (at least, not that anyone has found) so you can't get the log messages out that way either, and after experimenting with netconsole (sending console messages over UDP) I concluded that it was failing before initialising networking as well. The only other early boot debugging system that Linux explicitly supports is a weird host-to-host USB debug interface that I don't have and isn't cheap.

So, I grabbed a working Joggler kernel config from one of the Joggler Ubuntu images available on the forum, and built Debian's kernel sources using that configuration. That worked fine, so I bisected the interesting differences between the kernel configurations until I tracked down the single configuration option which stopped it from working: CONFIG_PHYSICAL_ALIGN. This one is going to take some explaining. :)

UPDATE: this is now fixed, see my post here.

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.

Joggler: How it boots

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

Okay, so the first thing that's important in running something other than the stock software is understanding exactly how the device boots normally, and at what points in that process you can easily/safely interfere.

The Joggler is mostly just a PC in a weird box: it has an Atom processor that runs normal x86 code. However, unlike most x86 computers, it doesn't have a traditional PC-compatible BIOS: it uses EFI. Some very modern PCs boot with EFI, but they generally have BIOS compatibility code that allows them to run traditional bootloaders and operating systems, and EFI is not widely used to actually boot on them just yet. The only platforms I know of where this is already used by large numbers of users are the x86-based Macs.

This means that the early stages of boot proceed very differently to the usual process on a PC, and to make things more annoying, the Joggler doesn't bother to display any hints as to what it's actually doing; the screen just displays a static logo on poweron (either the OpenPeak logo or the O2 logo, depending exactly which hardware variant you have) and leaves it there until the OS has booted far enough to take control of the display and display its own boot animation. As far as I know there's nothing you can press/do to see any actual boot progress; the logo is all you get.

Fortunately, other people already figured out pretty much everything it does during boot, though not all the details seem to be well-explained in the same place. To try and help out with that, here's my explanation of how it boots its factory-shipped OS. I've included notes that compare this to PC BIOS booting in red and notes on how you can encourage it to deviate from the normal boot sequence in blue.

Tuesday, 24 January 2012

Project intro: Joggler

This is the most recent project I've started working on: I bought a Joggler a couple of weeks ago. It's a weird device that looks like a rather thick digital photo frame, but contains a reasonably complete Atom computer, with the only peripherals being a touchscreen, a single USB port, wifi, ethernet and audio out. It was sold as a "lifestyle organiser", with the intention that it would serve as a hub for a family who used their O2 mobile phones to organise their lives. Nobody was interested, and they ended up selling the remainder of the stock off cheap before abandoning it. Their software is kinda crappy (written in Flash running on Linux) and many of the backend services are broken at this point, so it's not particularly useful running the factory software.

I originally bought it with various random purposes vaguely in mind, but by the time it actually arrived I'd thought of better ways to accomplish several of those things, so right now I'm just fiddling with it for fun.

They are pretty easy to repurpose; there's no secure boot system or anything else protecting the device, so you can just boot your own OS on it. What does "protect" the device is the obscure way in which it boots; more about that in a future post, but it's been worked around by others already, so it's not a real barrier.

These devices are quite popular to use to run other Linux-y stuff, so there's a pretty good community out there (mostly around this wiki, as far as I can tell) who have ported various distributions and applications to run on the device. However, most of the available software distributions for it are based on various collections of patches, nonstandard configurations, and occasionally odd binaries with unclear origins; a standard Linux distribution doesn't quite run on it out of the box. I get irritated by that kind of thing, so my first goal is to get Debian (my preferred distribution for non-desktop uses) running correctly on it with no local modifications. This looks like it will involve submitting various interesting changes to Debian and other upstream projects, so I'm volunteering myself to do that. :)

I have a Trello board here for my tasks to get this to work. I've already made some progress in getting it working with less hackery, as you can see there, and I'll blog about the parts I've done before considering them finished.

insert blog here

I'm going to try blogging about some of the software and gadget-hacking projects I've been working on, instead of just talking about them on IRC. So, this is that.

Over the next couple of days/weeks/months (depending on motivation) I'll talk a bit about the projects I'm currently working on, and then going forward cover stuff that's interesting as I do it.

Hope to get some interesting feedback!