Difference between revisions of "Raspberry Pi"

From Embedded Xinu
Jump to navigation Jump to search
(References to the bottom)
(→‎Serial Port: Added details about my serial port setup)
Line 12: Line 12:
 
== Serial Port ==
 
== 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 [http://elinux.org/Rpi_Low-level_peripherals 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.
+
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 [http://elinux.org/Rpi_Low-level_peripherals Embedded Linux RPi] page. <strike>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.</strike> Turns out the board has the 2x13 header already soldered on (I guess it didn't add too much to the cost of production).
 +
 
 +
The computer I used does not have a serial port on it, so I ended up getting a serial to USB converter from [https://www.sparkfun.com/products/718 Sparkfun], along with some [https://www.sparkfun.com/products/8430 jumper wires].
 +
 
 +
{|
 +
|[[File:Raspi-before.jpg|thumb|400px|Raspberry Pi before connecting the serial port. The upper left corner is the 2x13 GPIO/serial/SPI header (the pins are 1 on the bottom and 2 on the top).]]
 +
|[[File:Raspi-after.jpg|thumb|400px|Raspberry Pi after connecting the serial port. Connections are to Raspi ground to serial ground, Raspi Tx to serial Rx, Raspi Rx to serial Tx.]]
 +
|}
 +
 
 +
Once the serial transceiver board is wired up to the Raspberry Pi, connect a host system and use a terminal emulator (I used the [[Downloads|Xinu console tools]] `tty-connect`) with a baud rate of 115,200, 8 data bits, no parity, 1 stop bit.  During the Raspberry Pi boot (of a Fedora kernel at least), you will be able to see kernel log messages emitted to the serial console.  There isn't anything too exciting in the boot messages, but on my install the first few lines look like:
 +
 
 +
<syntaxhighlight lang="text">
 +
[    0.000000] Initializing cgroup subsys cpuset
 +
[    0.000000] Initializing cgroup subsys cpu
 +
[    0.000000] Linux version 3.1.9 (mockbuild@cdot-panda-5-4) (gcc version 4.5.1 20101112 (Red Hat 4.5.1-5) (GCC) ) #1 PREEMPT Sat Mar 3 21:58:00 UTC 2012
 +
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
 +
[    0.000000] CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
 +
[    0.000000] Machine: BCM2708
 +
[    0.000000] Memory policy: ECC disabled, Data cache writeback
 +
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 48768
 +
[    0.000000] Kernel command line: dma.dmachans=0x3c bcm2708_fb.fbwidth=720 bcm2708_fb.fbheight=480 bcm2708.boardrev=0x0
 +
bcm2708.serial=0x14be9109 smsc95xx.macaddr=B8:27:EB:BE:91:09 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
 +
console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
 +
</syntaxhighlight>
  
 
== SD Card ==
 
== SD Card ==

Revision as of 03:13, 7 June 2012

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. Turns out the board has the 2x13 header already soldered on (I guess it didn't add too much to the cost of production).

The computer I used does not have a serial port on it, so I ended up getting a serial to USB converter from Sparkfun, along with some jumper wires.

Raspberry Pi before connecting the serial port. The upper left corner is the 2x13 GPIO/serial/SPI header (the pins are 1 on the bottom and 2 on the top).
Raspberry Pi after connecting the serial port. Connections are to Raspi ground to serial ground, Raspi Tx to serial Rx, Raspi Rx to serial Tx.

Once the serial transceiver board is wired up to the Raspberry Pi, connect a host system and use a terminal emulator (I used the Xinu console tools `tty-connect`) with a baud rate of 115,200, 8 data bits, no parity, 1 stop bit. During the Raspberry Pi boot (of a Fedora kernel at least), you will be able to see kernel log messages emitted to the serial console. There isn't anything too exciting in the boot messages, but on my install the first few lines look like:

[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.1.9 (mockbuild@cdot-panda-5-4) (gcc version 4.5.1 20101112 (Red Hat 4.5.1-5) (GCC) ) #1 PREEMPT Sat Mar 3 21:58:00 UTC 2012
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[    0.000000] CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] Machine: BCM2708
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 48768
[    0.000000] Kernel command line: dma.dmachans=0x3c bcm2708_fb.fbwidth=720 bcm2708_fb.fbheight=480 bcm2708.boardrev=0x0
bcm2708.serial=0x14be9109 smsc95xx.macaddr=B8:27:EB:BE:91:09 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

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

References