Difference between revisions of "Raspberry Pi"

From Embedded Xinu
Jump to navigation Jump to search
(Added some command line info from Linux)
 
(16 intermediate revisions by 2 users not shown)
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 [http://www.raspberrypi.org/ 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)
+
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].
  
= Hardware =
+
== Acquiring the hardware ==
  
You will need the device itself.  As of mid-March 2012, this can be ordered for ~$40 from [http://www.newark.com/ Newark/element14] or [http://www.rs-online.com/ RS Components] and only includes the board itself (no power supply, cables, or case).
+
=== Model A vs. Model B ===
  
== Power Supply ==
+
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 [[XinuPi]] is very lightweight and only uses a small amount of the available memory, the difference in memory is mostly irrelevant.
  
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. [http://elinux.org/RPi_Hardware_Basic_Setup#Power_Supply Embedded Linux source]
+
=== Hardware accessories ===
  
== Serial 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:
  
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.
+
* 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, [[XinuPi]] has no SD card driver; therefore, when running [[XinuPi]] the SD card is only used for bootingUseful tip:  Since the SD card can easily be removed, it is trivial to have different SD cards and swap them out when neededThis 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 [http://www.adafruit.com/products/954 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]].
  
== SD Card ==
+
Other useful hardware and accessories include the following:
  
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 Amazon8 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.
+
* Serial cable for text input/output to/from the Raspberry Pi, such as [http://www.adafruit.com/products/954 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 PiWhile 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.
  
= Software =
+
[[File:Raspberry Pi in case with USB and Ethernet cables.jpg|thumb|Raspberry Pi Model B in a case with USB and Ethernet cables attached.]]
 +
[[File:RaspberryPi in case with Ethernet cable.jpg|thumb|Another shot of a Raspberry Pi Model B in a case.]]
  
Xinu is, of course, the target operating system for the RPi platform.  However, there are some steps to take before we get there.
+
== Booting ==
  
== Network Boot ==
+
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.
  
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.
+
The following binary blobs (created by Broadcom, but freely distributable, at least when using them on Raspberry Pis) must exist:
  
It looks like the grub bootloader should be able to support network booting [http://wiki.linuxmce.org/index.php/GRUB_PXE_network_boot Grub PXE network boot].  This is probably the most viable option, but other options may exist and work better for the RPi.
+
* "bootcode.bin" is a first-stage bootloader[[https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin Download link]].
 +
* "loader.bin" is a second-stage bootloaderApparently, this file is no longer required.
 +
* "start.elf" is the GPU firmware.[[https://github.com/raspberrypi/firmware/raw/master/boot/start.elf Download link]].
  
= Command Line Information =
+
The following text files are optional:
  
== <tt>cat /proc/cpuinfo</tt> ==
+
* "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.
  
<syntaxhighlight lang="bash">
+
Finally, the actual kernel:
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
+
* "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 [https://github.com/mrvn/raspbootin/blob/master/README.md its documentation] for more information.
Revision : 0000
 
Serial : 0000000014xxxxxx
 
</syntaxhighlight>
 
  
== <tt>cat /proc/meminfo</tt> ==
+
There are a couple ways you can actually achieve the final result of a properly set up SD card:
  
<syntaxhighlight lang="bash">
+
* 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.)
MemTotal:        186540 kB
+
* 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.
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
 
</syntaxhighlight>
 
 
 
= Platform =
 
 
 
* [http://www.broadcom.com/products/BCM2835 BCM2835] SoC
 
** Contains ARM 1176JZF-S processor ([http://infocenter.arm.com/help/topic/com.arm.doc.ddi0301h/DDI0301H_arm1176jzfs_r0p7_trm.pdf technical reference manual]; implements [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0419c/index.html ARMv6] instruction set, you'll need to register with ARM for the PDF.)
 
** [[File:BCM2835-Peripherals.pdf|Peripheral guide]] should cover making the serial port work
 
* [http://www.smsc.com/index.php?tid=300&pid=135 SMSC LAN9512] USB Hub and 10/100 Ethernet
 

Latest revision as of 22:37, 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 XinuPi 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, XinuPi has no SD card driver; therefore, when running XinuPi 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.