Raspberry Pi

From Embedded Xinu
Revision as of 23:09, 31 May 2012 by Michael (talk | contribs) (→‎Boot: Added more boot time info.)
Jump to navigation Jump to search
A freshly unpacked Raspberry Pi with additional SDHC card.

The Raspberry Pi (RPi) does exist, but while waiting for it to be delivered here are some notes to make it easier to begin porting Xinu to the platform. (Work in Progress)

Hardware

You will need the device itself. As of mid-March 2012, this can be ordered for ~$40 from Newark/element14 or RS Components and only includes the board itself (no power supply, cables, or case).

Power Supply

The RPi uses a fairly standard USB micro-B connector for power (only the power pins are physically present). It needs 700 mA at 5 V, so most computers or cell phone chargers should work. Embedded Linux source

Serial Port

The shipped RPi board doesn't come with a serial port attached (no surprise there). But it does have an expansion header that includes pin outs for a serial port (and more). The details can be found on the Embedded Linux RPi page. You will probably just want to solder on the full 2x13 pin header then deal with the outputs later incase you want to take advantage of the other pins.

SD Card

You will want at least a Class 6 or above SD card (lower class cards have been known to have read failures). I (Michael) ordered two Kingston 8 GB Class 4 SDHC memory cards from Amazon. 8 GB is probably excessive, but they only cost ~$7 each, and if you intend to have a full Linux install available it might not be a bad idea to go for > 4 GB.

Software

Xinu is, of course, the target operating system for the RPi platform. However, there are some steps to take before we get there.

Booting

Sadly the RPi does not come with a standard bootloader. Instead it simply boots off the SD card (and only the SD card) when power is applied, so a straight from the network boot is not an option. However, SD cards are low cost so you should be able to install a bootloader on the SD card that enables a network boot. It may "taint" the environment, but it shouldn't be horrible or worse than a typical boot loader.

It looks like the grub bootloader should be able to support network booting Grub PXE network boot. This is probably the most viable option, but other options may exist and work better for the RPi.

The boot process seems to be as follows[1]:

  • Power applied to the Raspberry Pi
  • Graphic Processor Unit (GPU) begins executing a stage 1 bootloader found in ROM on the chip
  • The stage 1 bootloader reads the SD card and loads stage 2 (/boot/bootcode.bin) into on-chip cache (L2)
  • GPU executes stage 2 bootloader which enables SDRAM and reads a stage 3 bootloader (/boot/loader.bin) into SDRAM
  • GPU executes stage 3 bootloader which understands how to read ELF files and reads the GPU firmware bootloader (/boot/start.elf)
  • /boot/start.elf reads /boot/config.txt, /boot/cmdline.txt, and /boot/kernel.img
  • /boot/kernel.img is essentially the Linux zImage (i.e. ARM code), it contains some parameters in the first 32k but the rest is zImage proper

The bootcode.bin, loader.bin, and start.elf files are all opaque to ARM programmers because they are GPU code files meaning we cannot change them. For Linux the kernel.img file is loaded starting at 0x00000000, which puts the start of Linux code (head.S) at 0x00008000[2]. This file is built by the mkimage[3] tool associated with the Raspberry Pi distribution. It *should not* be needed for non-Linux code because it only attaches some special code that is used for Linux kernel parameter passing so the kernel doesn't need extra modifications[4]. As an example: HaikuOS does not use the mkimage tool to get their kernel to boot.

As mentioned above, to get a network boot working we should be able to make a new kernel.img file that enables serial port access and network access then copies and jumps to a known offset for execution. As a starting point dwelch67 has something like this on github (though it seems to be very specific and not network oriented).

Command Line Information

cat /proc/cpuinfo

Processor	: ARMv6-compatible processor rev 7 (v6l)
BogoMIPS	: 697.95
Features	: swp half thumb fastmult vfp edsp java tls 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xb76
CPU revision	: 7

Hardware	: BCM2708
Revision	: 0000
Serial		: 0000000014xxxxxx

cat /proc/meminfo

MemTotal:         186540 kB
MemFree:          130592 kB
Buffers:            9552 kB
Cached:            29360 kB
SwapCached:            0 kB
Active:            18404 kB
Inactive:          29176 kB
Active(anon):       9108 kB
Inactive(anon):        4 kB
Active(file):       9296 kB
Inactive(file):    29172 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:             0 kB
HighFree:              0 kB
LowTotal:         186540 kB
LowFree:          130592 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                24 kB
Writeback:             0 kB
AnonPages:          8680 kB
Mapped:            10476 kB
Shmem:               448 kB
Slab:               5648 kB
SReclaimable:       2816 kB
SUnreclaim:         2832 kB
KernelStack:         568 kB
PageTables:          688 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:       93268 kB
Committed_AS:      94416 kB
VmallocTotal:     188416 kB
VmallocUsed:         896 kB
VmallocChunk:     186708 kB

Platform