New Raspberry Pi bootloader (rpi-boot)
Posted: Sun Feb 24, 2013 4:13 pm
I've recently obtained a RPi and have been playing with porting my OS to it. As a side effect of my experiments with it I've come up with a small second stage bootloader that I've released under a MIT licence in the hope that it may prove useful.
Its main selling point is that it provides the loaded kernel with 'BIOS-like' functions to aid debugging and hardware access during early kernel initialisation. Specifically, it provides a printf() function for writing text to the framebuffer, read-only filesystem access and timer support. Note that all the drivers are not optimised and are designed to be replaced by OS ones once the OS is more fully loaded. For example the block devices use synchronous PIO calls only, the filesystem drivers do not perform caching, the console driver is slow to scroll (as making it quicker would involve using up one of the RPi's DMA channels which the kernel itself may want to use).
It supports parsing a command file (/boot/rpi-boot.cfg) loaded from the SD card and can load kernels from both ext2 and FAT partitions. It currently supports loading Multiboot compliant kernels in ELF or a.out format and standard ELF kernels.
In Multiboot mode it supports loadable kernel modules, providing a list of devices and a memory map ala E820 (but actually interpreted from the ATAGs supplied by the first stage bootloader).
Currently unsupported features:
- USB support (work in progress)
- Network boot (requires USB)
- Interactive boot (requires USB)
- Ability to ask for a particular framebuffer mode in the Multiboot header (work in progress)
For the source see here, precompiled binaries and a test kernel are available here and further documentation is available at README and MULTIBOOT-ARM.
Please note this is a work in progress and bug reports are most welcome either on this thread or via email. In particular the ext2 code has only been tested in an emulator (but no SD writes are made so will not damage your filesystem).
Regards,
John
Its main selling point is that it provides the loaded kernel with 'BIOS-like' functions to aid debugging and hardware access during early kernel initialisation. Specifically, it provides a printf() function for writing text to the framebuffer, read-only filesystem access and timer support. Note that all the drivers are not optimised and are designed to be replaced by OS ones once the OS is more fully loaded. For example the block devices use synchronous PIO calls only, the filesystem drivers do not perform caching, the console driver is slow to scroll (as making it quicker would involve using up one of the RPi's DMA channels which the kernel itself may want to use).
It supports parsing a command file (/boot/rpi-boot.cfg) loaded from the SD card and can load kernels from both ext2 and FAT partitions. It currently supports loading Multiboot compliant kernels in ELF or a.out format and standard ELF kernels.
In Multiboot mode it supports loadable kernel modules, providing a list of devices and a memory map ala E820 (but actually interpreted from the ATAGs supplied by the first stage bootloader).
Currently unsupported features:
- USB support (work in progress)
- Network boot (requires USB)
- Interactive boot (requires USB)
- Ability to ask for a particular framebuffer mode in the Multiboot header (work in progress)
For the source see here, precompiled binaries and a test kernel are available here and further documentation is available at README and MULTIBOOT-ARM.
Please note this is a work in progress and bug reports are most welcome either on this thread or via email. In particular the ext2 code has only been tested in an emulator (but no SD writes are made so will not damage your filesystem).
Regards,
John