Difference between revisions of "RPi Software"

From eLinux.org
Jump to: navigation, search
(Adding template)
(typo)
 
(19 intermediate revisions by 14 users not shown)
Line 4: Line 4:
  
 
==Overview==
 
==Overview==
The Rpi is a full fledged ARM computer, so it should be able to run about everything compiled for ARM (within system requirements). The boards do not have any on board storage, so everything is on the SD card. If you just want a working system, buy a preformatted SD card from the Foundation, or give [http://www.raspberrypi.org/forum/projects-and-collaboration-general/picard-gui-sd-preparation-tool/page-11 PiCard] a try, a GUI SD preparation tool made by Liam Frazer.
 
  
==BootRom==
+
If you just want a working system, all that is required is a correctly formatted SD card. For details on how to create or get one, please see the [[RPi_Hardware_Basic_Setup#Prepared_Operating_System_SD_Card|Hardware Basic Setup]] page.
  
The boards do not include NAND or NOR storage - everything is on the SD card, which has a FAT32 partition with GPU firmware and a kernel image, and an EXT2 partition with the rootfs.
+
In order to understand the software components in the RPi, you should first understand how it boots up. At power-up, the CPU is offline, and a small RISC core on the GPU is responsible for booting the SoC, therefore most of the boot components are actually run on the GPU code, not the CPU.
  
We're not currently using a bootloader - we actually boot via the GPU, which contains a proprietary RISC core (wacky architecture). The GPU mounts the SD card, loads GPU firmware and brings up display/video/3d, loads a kernel image, resets the SD card host and starts the ARM.
+
The boot order and components are as follows:
 +
* '''First stage bootloader''' - This is used to mount the FAT32 boot partition on the SD card so that the second stage bootloader can be accessed. It is programmed into the SoC itself during manufacture of the RPi and cannot be reprogrammed by a user.
 +
* '''Second stage bootloader''' (bootcode.bin) - This is used to retrieve the GPU firmware from the SD card, program the firmware, then start the GPU.
 +
* '''GPU firmware''' (start.elf) - Once loaded, this allows the GPU to start up the CPU. An additional file, fixup.dat, is used to configure the SDRAM partition between the GPU and the CPU. At this point, the CPU is release from reset and execution is transferred over.
 +
* '''User code''' - This can be one of any number of binaries. By default, it is the Linux kernel (usually named kernel.img), but it can also be another bootloader (e.g. U-Boot), or a bare-bones application.
  
You could replace the kernel image with a bootloader image, and that would work fine.
+
Prior to 19th October 2012, there was previously also a third stage bootloader (loader.bin) but this is no longer required. <ref>https://github.com/raspberrypi/firmware/commit/c57ea9dd367f12bf4fb41b7b86806a2dc6281176</ref>
  
==Distributions==
+
Raspbian Linux image (others?) available on the foundation's website ([http://www.raspberrypi.org/downloads]) also contains cut-down versions of the above files (fixup_cd.dat, start_cd.elf). These are used when GPU memory is set to 16 MB, which in result disables some GPU features. More info [http://www.raspberrypi.org/phpBB3/viewtopic.php?p=198420#p198420 here]. In addition, there are also testing versions of the above files (fixup_x.dat, start_x.elf), which enable potentially unstable/not-fully-tested/hacky functionality - currently, using these files instead of the usual fixup.dat/start.elf will cause extra video codecs to become available.
  
Source code and binaries for Raspberry Pi will be available at various places from launch, including pre-built Linux distributions.
+
Because of this boot process, use of an SD card to boot the RPi is mandatory. This does however mean that you cannot 'brick' the device.
  
Ubuntu is currently listed as the default distribution on the Raspberry Pi website, but the Ubuntu developers have now stated they will not be supporting the ARMv6 architecture, so Ubuntu is likely to be dropped.
+
==GPU bootloaders==
  
Eben says (regarding default distribution): "Either Ubuntu or Fedora; the main point in Fedora’s favour is their ongoing support for ARMv6 architectures."
+
Currently all of the GPU software and firmware is supplied in binary format. For Raspbian the latest stable release is included in the image and can be updated with apt-get (see the [[Add_software|adding software page]]). The latest bleeding edge version can be downloaded from the [https://github.com/raspberrypi/firmware/tree/master/boot RPI firmware section on GitHub]. At this time, the source code is not available.
  
''Main page: [[RPi Distributions]]''
+
[https://github.com/Hexxeh/rpi-update rpi-update] is also available as an easier way of updating the firmware and kernel. Please note, as this firmware is bleeding edge, it really should only be used by advanced users and could potentially still have bugs and be incompatible with existing images.
  
==Development environments==
+
==Distributions==
 +
''Main page: [[RPi_Distributions|Distributions]]''
  
Instead of just using compiler + editor, you can use "development tool chains" which integrate compiler, build system, packaging tools etc. in one tool chain.
+
SD card images of a number of pre-built distributions including Raspbian (the RPi official distribution based on Debian),
 +
Arch Linux ARM, and RISC OS are available from the [http://www.raspberrypi.org/downloads Raspberry Pi foundation website].
 +
Pre-loaded SD cards are also available from [http://thepihut.com/collections/sd-cards The Pi Hut].
  
==Kernel==
+
Several other Distributions  made RPI Images as well. See at http://www.raspberrypi.org/phpBB3/viewforum.php?f=18 
  
The initial patches ([[Media:Rpi-linux-patches-3.1.9.tgz]]) are released against the 3.1.9 kernel - but may also work against later kernels.
+
Raspbian is the recommended distribution.
  
The kernel is now also available on https://github.com/raspberrypi/linux
+
==Kernel==
 +
''Main page: [[RPi_Kernel_Compilation|RPi Kernel Compilation]]''
  
See [[rpi kernel compilation]] (unfinished) for how to compile the kernel.
+
The kernel is sources can be obtained from the [https://github.com/raspberrypi/linux RPI linux section on GitHub]
 
 
(left here until new page is created:) TODO: Explain how to apply these patches and correctly obtain a default configured kernel.
 
  
 
==Compiler==
 
==Compiler==
Line 44: Line 49:
 
===ARM===
 
===ARM===
  
There is broad compiler support including gcc - please see [http://www.elinux.org/ARMCompilers ARM Compilers]
+
There is broad compiler support for the ARM processor including GCC - please see [[ARMCompilers|ARM Compilers]].
 +
There are also a number of cross-compiler toolchains - please see [[Toolchains|toolchains]].
  
The ARM is capable of around 500 BOGOMIPS <ref>http://www.raspberrypi.org/?p=78#more-78</ref>, 5400 LINPACK KFLOPS with software floating point and 22000 KFLOPS with softfp hardware floating point<ref>http://www.raspberrypi.org/?page_id=43&mingleforumaction=viewtopic&t=266.0</ref>.
+
The gcc compiler flags which will produce the most optimal code for the RPi are:
 +
<pre>-Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s</pre>
 +
<tt>-Ofast</tt> may produce compile errors for some programs. In this case, <tt>-O3</tt> or <tt>-O2</tt> should be used instead.
 +
Note that <tt>-mcpu=arm1176jzf-s</tt> can be used in place of <tt>-march=armv6zk -mtune=arm1176jzf-s</tt>.
 +
 
 +
If you want to generate a relatively up-to-date compiler that uses the optimal flags by default, you can roll your own version of Linaro GCC - see [[RPi_Linaro_GCC_Compilation|RPi Linaro GCC Compilation]].
  
 
===GPU===
 
===GPU===
 
The GPU provides APIs for Open GL ES 2.0, hardware-accelerated OpenVG, and 1080p30 H.264 high-profile decode.
 
The GPU provides APIs for Open GL ES 2.0, hardware-accelerated OpenVG, and 1080p30 H.264 high-profile decode.
  
The GPU is capable of 1Gpixel/s, 1.5Gtexel/s or 24 GFLOPs of general purpose compute and features a bunch of texture filtering and DMA infrastructure - the Raspberry Pi team are looking at how they can make this available to application programmers.
+
The GPU is capable of 1Gpixel/s, 1.5Gtexel/s or 24 GFLOPs of general purpose compute and features a bunch of texture filtering and DMA infrastructure - the Raspberry Pi team are looking at how they can make this available to application programmers. For the documentation on some Broadcom APIs exposed to control the GPU, see [[RPi VideoCore APIs]].
  
 
The GPU blob is an 18MB elf file, including libraries. It does an awful lot. <ref>http://www.raspberrypi.org/?page_id=43&mingleforumaction=viewtopic&t=247</ref>
 
The GPU blob is an 18MB elf file, including libraries. It does an awful lot. <ref>http://www.raspberrypi.org/?page_id=43&mingleforumaction=viewtopic&t=247</ref>
Line 58: Line 69:
  
 
There is a DSP, but there isn't currently a public API (Liz thinks the BC team are keen to make one available at some point).
 
There is a DSP, but there isn't currently a public API (Liz thinks the BC team are keen to make one available at some point).
 
==Other software==
 
 
===Flash===
 
 
From Eben:
 
"We'll have to take a look. We support hardware-accelerated OpenVG, and have had Flash Lite running incredibly fast. Personally, I'd like to get the official hardware-accelerated Flash 10 going on there, running against OpenGL ES 2.0, but that's something to think about after the launch."
 
 
==Software hints==
 
 
This section collects hints, tips & tricks for various software components.
 
  
 
==Performance==
 
==Performance==
  
[[RaspberryPiPerformance|Performance Page]]
+
A large number of benchmark results are available on the [[RaspberryPiPerformance|performance page]].
  
 
==Programming==
 
==Programming==
 +
A number of development environments are available depending on which language you are writing - see the [[RPi_Programming|programming]] page.
  
Raspberry Pi plans to support Python and C as primary teaching languages, but expect to have some sort of BASIC on there too. Perhaps even BBC BASIC or SuperBASIC depending on copyright issues.
+
==Emulation==
 
+
The ARM processor on the RPi can be emulated using QEMU. See [http://cronicasredux.blogspot.co.uk/2011/09/installing-and-running-debian-armel-on.html emercer's tutorial], and also [http://www.raspberrypi.org/forum/projects-and-collaboration-general/emulating-a-raspi-on-windows this discussion].
 
 
''See main page [[RPi Programming]] for more detail.''
 
  
 
==References==
 
==References==

Latest revision as of 01:06, 18 March 2014


Back to the Hub.


Software & Distributions:

Software - an overview.

Distributions - operating systems and development environments for the Raspberry Pi.

Kernel Compilation - advice on compiling a kernel.

Performance - measures of the Raspberry Pi's performance.

Programming - programming languages that might be used on the Raspberry Pi.


Overview

If you just want a working system, all that is required is a correctly formatted SD card. For details on how to create or get one, please see the Hardware Basic Setup page.

In order to understand the software components in the RPi, you should first understand how it boots up. At power-up, the CPU is offline, and a small RISC core on the GPU is responsible for booting the SoC, therefore most of the boot components are actually run on the GPU code, not the CPU.

The boot order and components are as follows:

  • First stage bootloader - This is used to mount the FAT32 boot partition on the SD card so that the second stage bootloader can be accessed. It is programmed into the SoC itself during manufacture of the RPi and cannot be reprogrammed by a user.
  • Second stage bootloader (bootcode.bin) - This is used to retrieve the GPU firmware from the SD card, program the firmware, then start the GPU.
  • GPU firmware (start.elf) - Once loaded, this allows the GPU to start up the CPU. An additional file, fixup.dat, is used to configure the SDRAM partition between the GPU and the CPU. At this point, the CPU is release from reset and execution is transferred over.
  • User code - This can be one of any number of binaries. By default, it is the Linux kernel (usually named kernel.img), but it can also be another bootloader (e.g. U-Boot), or a bare-bones application.

Prior to 19th October 2012, there was previously also a third stage bootloader (loader.bin) but this is no longer required. [1]

Raspbian Linux image (others?) available on the foundation's website ([1]) also contains cut-down versions of the above files (fixup_cd.dat, start_cd.elf). These are used when GPU memory is set to 16 MB, which in result disables some GPU features. More info here. In addition, there are also testing versions of the above files (fixup_x.dat, start_x.elf), which enable potentially unstable/not-fully-tested/hacky functionality - currently, using these files instead of the usual fixup.dat/start.elf will cause extra video codecs to become available.

Because of this boot process, use of an SD card to boot the RPi is mandatory. This does however mean that you cannot 'brick' the device.

GPU bootloaders

Currently all of the GPU software and firmware is supplied in binary format. For Raspbian the latest stable release is included in the image and can be updated with apt-get (see the adding software page). The latest bleeding edge version can be downloaded from the RPI firmware section on GitHub. At this time, the source code is not available.

rpi-update is also available as an easier way of updating the firmware and kernel. Please note, as this firmware is bleeding edge, it really should only be used by advanced users and could potentially still have bugs and be incompatible with existing images.

Distributions

Main page: Distributions

SD card images of a number of pre-built distributions including Raspbian (the RPi official distribution based on Debian), Arch Linux ARM, and RISC OS are available from the Raspberry Pi foundation website. Pre-loaded SD cards are also available from The Pi Hut.

Several other Distributions made RPI Images as well. See at http://www.raspberrypi.org/phpBB3/viewforum.php?f=18

Raspbian is the recommended distribution.

Kernel

Main page: RPi Kernel Compilation

The kernel is sources can be obtained from the RPI linux section on GitHub

Compiler

The Broadcom processor on Raspberry Pi contains an ARM v6 general purpose processor and a Broadcom VideoCore IV GPU. No data is currently available on other cores (if any) available in the BCM2835.

ARM

There is broad compiler support for the ARM processor including GCC - please see ARM Compilers. There are also a number of cross-compiler toolchains - please see toolchains.

The gcc compiler flags which will produce the most optimal code for the RPi are:

-Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s

-Ofast may produce compile errors for some programs. In this case, -O3 or -O2 should be used instead. Note that -mcpu=arm1176jzf-s can be used in place of -march=armv6zk -mtune=arm1176jzf-s.

If you want to generate a relatively up-to-date compiler that uses the optimal flags by default, you can roll your own version of Linaro GCC - see RPi Linaro GCC Compilation.

GPU

The GPU provides APIs for Open GL ES 2.0, hardware-accelerated OpenVG, and 1080p30 H.264 high-profile decode.

The GPU is capable of 1Gpixel/s, 1.5Gtexel/s or 24 GFLOPs of general purpose compute and features a bunch of texture filtering and DMA infrastructure - the Raspberry Pi team are looking at how they can make this available to application programmers. For the documentation on some Broadcom APIs exposed to control the GPU, see RPi VideoCore APIs.

The GPU blob is an 18MB elf file, including libraries. It does an awful lot. [2]

DSP

There is a DSP, but there isn't currently a public API (Liz thinks the BC team are keen to make one available at some point).

Performance

A large number of benchmark results are available on the performance page.

Programming

A number of development environments are available depending on which language you are writing - see the programming page.

Emulation

The ARM processor on the RPi can be emulated using QEMU. See emercer's tutorial, and also this discussion.

References