Skip to content
David Garriou edited this page Apr 13, 2016 · 3 revisions

Port in progress

Raspberry Pi 2 Bare Metal Programming

The purpose of this application is to understand the behavior of the [Raspberry Pi 2] rpi2 for a bare metal application. You can find useful information in the [forum] rpi2forum dedicated to [bare metal] rpi2forumbaremetal applications for Raspberry Pi boards. The application tests the starting mode of the Raspberry Pi 2 and then switch to SYS mode. This application will blink both leds () using an IRQ and call an exception (svc) one time inside which it will increment a variable.

Overview

Approach

Our objective is to launch a simple bare metal application able to :

  • Run standalone,
  • Trigger interrupts,
  • Trigger exceptions such as Supervisor Call (SVC) used for calling OS services,
  • Run in User space and Supervisor space (for OS services).

We will see in the [description of the Raspberry Pi 2] (#rpi2) that this board is not so easy to use ofr bare metal programming. We will need a bootloader in order not to save a lot of time plugging and unplugging the sdcard of the board.

The bootloader will offer services for :

  • Download a software through UART,
  • Launch a software,
  • Observe memory.

Description of material

Cortex-A7 processor

The Cortex-A7 processor implements the ARMv7-A architecture. It can have up to 4 processors in a single device.

Modes

Security Extension

Boot sequence

The Cortex-A7 starts in Supervisor mode in the Secure state [Technical Reference Manual, §3.4.1] TecRefMan.

Broadcom BCM2836

Raspberry Pi 2

The Raspberry Pi 2 uses a [Broadcom chip BCM2836] bcm2836 which is a quad-core Cortex-A7 cluster. You must have a look to both BCM2836 processor and BCM2835 processor documentations for peripherals. Indeed you'll find a lot of information into the documentation of the BCM2835 for peripherals that are the same for BCM2836. The only difference is the base address for peripherals.

I/O Peripherals

  • BCM2835

    • VC CPU Bus Address = 0x7E000000
    • ARM Physical Addresse = 0x20000000
  • BCM2836

    • VC CPU Bus Address = 0x7E000000
    • ARM Physical Address = 0x3F000000

The physical peripherals' base address for BCM2835 is 0x, and virtual corresponding address is 0x7e200000.

The physical peripherals' base address for BCM2836 is 0x3F000000, and virtual corresponding address is 0x7e000000.

Boot sequence

Peripherals

Bootloader

Application setting up

Startup code

References

Raspberry

[Raspberry Pi 2] rpi2

[Documentation for Raspberry Pi 2] rpi2Doc

[Documentation for Raspberry Pi] rpiDoc

[Raspberry Pi forum] rpi2forum

[Raspberry Pi forum section Programming, Bare metal] rpi2forumbaremetal

ARM

[Cortex™-A7 MPCore™ Technical Reference Manual Revision: r0p5] TecRefMan

[ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition Issue C] ArcRefMan

Broadcom

[Documentation for BCM2836] bcm2836

[Documentation for BCM2835] bcm2835

Other web references