WARNING: The documentation for XinuPi (Embedded Xinu on the Raspberry Pi) is currently under construction. Furthermore, as of this writing there is nowhere public to download XinuPi or its source code (which we will make available soon), so don't look for it until this notice is removed.
The Raspberry Pi is an inexpensive credit-card sized computer designed for educational use. This page gives an overview of the port of Embedded Xinu to the Raspberry Pi, or XinuPi. XinuPi provides a simple, lightweight operating system for the Raspberry Pi that contains several orders of magnitude fewer lines of code than the Linux-based software stacks that normally run on the device. Its purpose is to provide an inexpensive, convenient platform for various areas of computer science education at a University level, including operating systems, embedded systems, networking, and programming languages. Another goal of XinuPi is to document some of the Raspberry Pi's hardware that has, until this point, been poorly documented or even undocumented. This includes the documentation on this Wiki as well as the XinuPi source code and the documentation generated from comments in it.
General Raspberry Pi information
This section provides some important details about the Raspberry Pi in the context of those interested in running Embedded Xinu on it. Readers unfamiliar with the Raspberry Pi are advised to also see other sources such as the Raspberry Pi foundation's website.
Acquiring the hardware
Model A vs. Model B
The Raspberry Pi Model A costs $25, whereas the Raspberry Pi Model B costs $35. Since Embedded Xinu is very lightweight, differences in memory are essentially irrelevant. However, we recommend the Model B because it includes an Ethernet port and 2 USB ports, as opposed to the Model A which merely has 1 USB port.
One way the cost of the Raspberry Pi was kept down was increasing modularity. A consequence of this is that a Raspberry Pi board by itself is useless until at least two additional components have been added:
- SD card. To boot, the Raspberry Pi requires an appropriately formatted SD card containing certain boot files as well as the operating system or kernel to run. Note: as of this writing, Embedded Xinu has no SD card driver; therefore, when running Embedded Xinu the SD card is only used for booting. Useful tip: Since the SD card can easily be removed, it is trivial to have different SD cards and swap them out when needed. This trick can be used to easily use the same Raspberry Pis for different purposes.
- Power source. The Raspberry Pi requires 700 mA at 5V, delivered either through the microUSB port or through the GPIO pins. For the microUSB port, most cell phone chargers should work. For the GPIO pins, a useful trick is that a USB to TTL Serial converter, such as this one, can double as a power source as well as a serial connection to the Raspberry Pi over which the console runs. We have primarily used the latter method while developing Embedded Xinu.
Other useful hardware and accessories include the following:
- Monitor or TV to show graphics output. While important for Linux, this is less important for Embedded Xinu, which is primarily intended to produce text output over a serial connection. However, Embedded Xinu does support a framebuffer console and a turtle graphics application for those interested.
- USB devices, such as mouse and keyboard. Note: as of this writing, Embedded Xinu does not have working mouse and keyboard drivers, so the serial connection remains the only way to send input to XinuPi.
- Case to enclose the Raspberry Pi in. This protects the board and adds aesthetic value; otherwise it has no purpose.
The Raspberry Pi can only boot from its SD card, not from any external devices, and it requires several files in order to do so. Several boot files, which are not distributed with Embedded Xinu, must be placed in the root directory of a FAT-formatted partition of the SD card.
The following binary blobs (created by Broadcom, but freely distributable, at least when using them on Raspberry Pis) must exist:
- "bootcode.bin" is a first-stage bootloader. [Download link].
- "loader.bin" is a second-stage bootloader. Apparently, this file is no longer required.
- "start.elf" is the GPU firmware.[Download link].
The following text files are optional:
- "config.txt" is parsed by the GPU firmware and is used to set various hardware parameters. Xinu runs fine with the default parameters, so "config.txt" need not exist.
- "cmdline.txt" is used to pass a command line to the Linux kernel. This file need not exist for the Xinu kernel, which does not take command line parameters.
Finally, the actual kernel:
- "kernel.img" must exist and is loaded as raw data at physical memory address 0x8000 by the GPU firmware. The ARM begins execution at the very first instruction in this loaded image. "kernel.img" can be a Xinu kernel (rename "xinu.boot" to "kernel.img"), a Linux kernel, or other bare-metal code such as the "raspbootin" bootloader. "raspbootin" has been helpful in the initial stages of porting Xinu to the Raspberry Pi; see its documentation for more information.
There are a couple ways you can actually achieve the final result of a properly set up SD card:
- Follow the installation instructions for a Linux distribution supported on the Raspberry Pi, such as Raspbian or Arch Linux ARM. This will leave the appropriate boot files. To switch to Embedded Xinu, simply replace "kernel.img" on the FAT partition with "xinu.boot". (Perhaps rename "kernel.img" to "linux.img" to save a backup first.)
- Manually partition the SD card and create a FAT filesystem, then copy the boot files to the filesystem. The binary blobs can be downloaded using the links provided above.
This section provides an overview of XinuPi (the port of Embedded Xinu to the Raspberry Pi) and links to relevant articles.
- The core of XinuPi provides a preemptive multitasking operating system for the Raspberry Pi. See Preemptive Multitasking (ARM) for more details about how Embedded Xinu implements preemptive multitasking on ARM-based platforms such as the Raspberry Pi; this includes information about thread creation and context switching. Also see BCM2835 System Timer for the timer on the Raspberry Pi that XinuPi uses to implement preemptive multitasking.
- Interrupt handling on the Raspberry Pi, required for the timer interrupt as well as many other devices, is described in Interrupt handling (Raspberry Pi).
- USB support was added to Embedded Xinu partly because of its important role in the Raspberry Pi, including to attach the Ethernet Controller on the Raspberry Pi Model B. See USB for general information about USB, or Synopsys DesignWare High-Speed USB 2.0 On-The-Go Controller for information specifically about the USB controller the Raspberry Pi provides.
- See SMSC LAN9512 for information about the built-in USB Ethernet Adapter on the Raspberry Pi Model B, and XinuPi's driver for it.
TODO: sound, graphics, keyboard support