Difference between revisions of "Raspberry Pi"

From Embedded Xinu
Jump to navigation Jump to search
m (git branch was merged)
(Moving XinuPi info to external page)
Line 1: Line 1:
 
[[File:RaspberryPi.jpg|200px|right|thumb|A freshly unpacked Raspberry Pi with additional SDHC card.]]
 
[[File:RaspberryPi.jpg|200px|right|thumb|A freshly unpacked Raspberry Pi with additional SDHC card.]]
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.
+
The '''Raspberry Pi''' is an inexpensive credit-card sized computer designed for educational use.  This page provides information about the Raspberry Pi in the context of those looking to run [[XinuPi]] on it.  Readers unfamiliar with the Raspberry Pi are advised to also see other sources such as the [http://www.raspberrypi.org/ Raspberry Pi foundation's website].
 
 
= General Raspberry Pi information =
 
 
 
This section provides some important details about the Raspberry Pi in the context of those interested in running XinuPi on it.  Readers unfamiliar with the Raspberry Pi are advised to also see other sources such as the [http://www.raspberrypi.org/ Raspberry Pi foundation's website].
 
  
 
== Acquiring the hardware ==
 
== Acquiring the hardware ==
Line 53: Line 49:
 
* 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 XinuPi, simply replace "kernel.img" on the FAT partition with "xinu.boot".  (Perhaps rename "kernel.img" to "linux.img" to save a backup first.)
 
* 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 XinuPi, 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.
 
* 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.
 
= XinuPi =
 
 
This section provides an overview of the XinuPi software and links to relevant articles.
 
 
== Downloading and compiling XinuPi ==
 
 
XinuPi is currently only available in source code form and only in the [http://github.com/xinu-os/xinu Embedded Xinu git repository].  To obtain the code, install [http://git-scm.com/ git] and run:
 
 
git clone https://github.com/xinu-os/xinu
 
cd xinu
 
 
Note that this in fact the code for "Embedded Xinu" and not for "XinuPi" specifically.  That is, the Raspberry Pi is one of several platforms that Embedded Xinu supports (and builds targeting it are referred to as "XinuPi").
 
 
To compile XinuPi, run:
 
 
make -C compile PLATFORM=arm-rpi
 
 
PLATFORM=arm-rpi is necessary to instruct the build system to target the Raspberry Pi.  Additional arguments can be passed to ''make'', such as the COMPILER_ROOT to specify the location of a GCC compiler targeting ARM (defaults to "arm-none-eabi-", meaning that no explicit setting is needed if "arm-none-eabi-gcc" and the corresponding binutils are already on the shell $PATH).  See compile/README.compiling for more details; for example, details about cross compilers.
 
 
The compilation process produces a file "compile/xinu.boot", which can be copied to "kernel.img" on the SD card of a Raspberry Pi to run it (see [[#Booting]]).
 
 
XinuPi is licensed under a BSD-style license; see the copyright information in the source distribution for more details.
 
 
== XinuPi features and implementation ==
 
 
* 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.
 
 
<span style="color: red">TODO:  sound, graphics, keyboard support</span>
 

Revision as of 22:33, 11 September 2013

A freshly unpacked Raspberry Pi with additional SDHC card.

The Raspberry Pi is an inexpensive credit-card sized computer designed for educational use. This page provides information about the Raspberry Pi in the context of those looking to run XinuPi 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. We generally 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. Also, currently the Model B has more memory (512 MiB) than the Model A (256 MiB), but since Embedded Xinu is very lightweight and only uses a small amount of the available memory, the difference in memory is mostly irrelevant.

Hardware accessories

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 XinuPi.

Other useful hardware and accessories include the following:

  • Serial cable for text input/output to/from the Raspberry Pi, such as this one. This is very important for XinuPi because this is its primary way to interact with a human. Furthermore, as noted above, such a serial cable can double as a power source. However, eventually a keyboard-and-monitor setup will be supported as well, providing an alternative to a serial cable when human interaction with the system is desired.
  • Monitor or TV to display graphics output from the Raspberry Pi. While important for Linux, this is less important for XinuPi, which is primarily intended to produce text output over a serial connection as described above. However, XinuPi does support a framebuffer console and a turtle graphics application for those interested.
  • USB devices can be plugged in and recognized, but the device driver support for specific devices is extremely limited at this point. Support for USB keyboards as an input method is in development.
  • Ethernet cable to take advantage of the networking support.
  • Case to enclose the Raspberry Pi in. This protects the board and adds aesthetic value; otherwise it has no purpose.
Error creating thumbnail: Unable to save thumbnail to destination
Raspberry Pi Model B in a case with USB and Ethernet cables attached.
Error creating thumbnail: Unable to save thumbnail to destination
Another shot of a Raspberry Pi Model B in a case.

Booting

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 XinuPi, 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. XinuPi 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 XinuPi 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 XinuPi 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 developing XinuPi; 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 XinuPi, 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.