Chain booting on the Balloon board
Why chain booting?
Originally, the Balloon boot process looked like this:
- PXA270 reads bootldr from NOR Flash and runs it
- bootldr reads kernel (zImage) from yaffs filesystem in NAND Flash (/boot partition) and runs it
- kernel mounts root yaffs filesystem in NAND Flash (/root partition) and boots
This works fine, but has a number of deficiencies:
- Both bootldr and kernel have to understand the same partition structure in NAND Flash, and there's no way for one to inform the other about partition settings so they have to be compiled in. This is ugly and inflexible.
- Both bootldr and kernel need to have the same version of yaffs. This hasn't been the case for several years, which has meant that the /boot partition is effectively read-only as far as the kernel is concerned. This makes kernel upgrades unnecessarily hard.
- bootldr isn't smart enough to handle booting from anything other than Flash memory. This means we can't boot from USB sticks, MMC cards, networks or any other media.
We'd like to improve on this.
What is chain booting?
The ability exists in bootldr to load and run a kernel from NOR Flash. We have been using this to boot the 'recovery' kernel/initramfs, which is useful for installing and manipulating the root filesystem. Usefully, the Linux kernel has the ability to load another kernel and run it, which leads to another boot possibility: chain booting. It looks like this:
- PXA270 reads bootldr from NOR Flash and runs it
- bootldr reads recovery kernel from NOR Flash and runs it, setting a 'boot script' for the kernel which tells it to chain boot
- Recovery kernel loads another kernel from some other filesystem (could be NAND Flash using any filesystem, USB stick, and so on) and runs it.
- Main kernel mounts root filesystem of its choice and boots.
Note that now the bootldr doesn't need to know anything about any filesystems: it just has to read the recovery kernel from NOR Flash. All the intelligence is left to the recovery and main kernels.
The recovery kernel is still available for system administration tasks, and can be instructed not to chain boot by a simple command in bootldr. In fact, the recovery kernel might be thought of as a kind of super-bootldr.
How to implement chain booting
Chain booting is supported by the software in trunk since April 2011.
Instructions for building and installing this are on the BalloonDevelopment page.