Page 1 of 2

STICKY: Bare Metal resources

Posted: Sun Mar 16, 2014 5:48 pm
by mahjongg
Links to resources for Bare Metal programming go here.

Please do not post comments/discussions here, just links to info.
Post "contaminating" the sticky will be deleted.
For these use the normal threads.

bare metal resources

Posted: Sun Mar 16, 2014 5:52 pm
by mahjongg
headers from the Broadcom GPU source code
  • SD - for SDRAM
  • L1 - for Level 1 cache
  • L2 - for Level 2 cache
  • H264 - for the H264 encoder/devoder i assume
  • FPGA - ?
The generated html page is here: ... sters.html

The full project including the scripts which were used to generate it can be found here:

Re: bare metal resources

Posted: Sun Mar 16, 2014 5:55 pm
by mahjongg

Docs for BCM283X and firmware

Posted: Fri Mar 28, 2014 7:57 pm
by ghans
Information for the Raspberry Pi / BCM2835 Information for the Raspberry Pi 2 / BCM2836
NEW ! Information for the BCM2837 (Raspberry Pi 3) Communicating with the GPU via Mailboxes


USB and GPU information

Posted: Thu May 15, 2014 1:42 pm
by ghans
The USB Controller on the Pi has no official publicly available documentation.
As USB was envisaged as the main way of connecting a keyboard plus mouse AND getting an
internet connection, this might be unfortunate for everybody who writes their own OS.
Currently information on the controller has to be gleaned from open drivers.
The one of the embedded Xinu project might be a good starting point: ... Controller

Otherwise , have a look at the USPi project of R. Stange , which
is ready for integration in your open-source projects (GPLv3) : ... 72&t=92579

GPU Documentation / VideoCore® IV 3D Architecture Reference Guide

More documentation for the GPU (reverse-engineered) :

Documentation for the LAN9512 chip of the Model B (an USB hub with an integrated USB Network card): ... c/9512.pdf


Re: bare metal resources

Posted: Tue May 20, 2014 10:37 am
by mahjongg

Re: bare metal resources

Posted: Sat May 24, 2014 8:24 am
by ghans
David Welchs bare metal examples :

Also includes code which illustrates how to load new
kernels over a serial connection
, so you don't need to
constantly swap the SD card from the Pi to your dev machine
and back.

Baking Pi : ... orials/os/

A nice tutorial on writing bare-metal assembly for the Pi.


Re: bare metal resources

Posted: Mon Jul 07, 2014 6:54 am
by macload1
Link to an example of Raspberry Pi running FreeRTOS and µGFX as GUI using the framebuffer (output on HDMI or composite)


Re: bare metal resources

Posted: Thu Dec 11, 2014 10:37 am
by krom
Here are some Bare Metal Raspberry Pi examples that use very minimal & simple ARM Assembly only:

Here is what you will find:
LZSS & Huffman Decompression: ... r/Compress
GB Z80 Emulator with minimal hardware attached to run some GameBoy ROMs: ... MU/GameBoy
Hello World console text output demos, using the CPU or DMA with Stride: ... HelloWorld
GPIO Input demos using a SNES or NES Controller, & the SNES Mouse: ... ster/Input
Sound Playback demos using the PWM: ... /Sound/PWM
TAGS Channel demo which prints all Raspberry Pi Mailbox TAGS information to the screen: ... agsChannel
V3D demos to show howto initialize the V3D (Rasperry Pi GPU) & prints all V3D information to the screen, & howto display a control list to show a Clear Color & Triangles: ... master/V3D
VFP demos to display a static Mandelbrot fractal using Raspberry Pi ARM Floating point (FPU) instructions, & an animated Julia fractal: ... FP/Fractal

You will not find a simpler suite of assembly source for bare metal programming on the Raspberry Pi, I recommend you check out my github repository if you like programming in ARM assembly.
I hope you all have fun with this stuff!

P.S I would like to say a special thanks to DexOS who helped me get my 1st pixel on the screen, & made all this possible =D

Re: bare metal resources

Posted: Sun Jan 11, 2015 8:19 am
by novellus
A couple C based bare metal examples ... -Pi-Kernel

LEDs (plural) on the Raspberry Pi / Pi2

Posted: Sat Feb 28, 2015 6:11 pm
by mrvn
Raspberry Pi
The Raspberry Pi has 5 LEDs on the board: Power, Activity, Full Douplex, Link and 100Mbit. The last 3 I assume are connected directly to the ethernet chip. I'm unsure about the power LED. The activity LED though is connected to GPIO pin 16 and configured for output on boot. One can simply set/clr the pin to make the LED react.

Note: peripheral base in 0x20000000 which makes the GPIO base 0x20200000.

Raspberry Pi2
The Raspbeery PI2 has only 2 LEDs on the board: Power and Activity. The RJ45 connector has 2 more LEDs but they will be controled by the ethernet chip for sure. The power LED is connected to GPIO pin 35 but configured at boot with pull up or pull down so it simply is on. Removing the pull up/down and reconfiguring the pin for output lets one control the LED via set/clr of the pin. The activity LED has moved compared to the Raspberry Pi and is now on GPIO pin 47. But it is still configured as output on boot and set/clr of the pin makes it react.

Note: peripheral base in 0x3F000000 which makes the GPIO base 0x3F200000.

Re: bare metal resources

Posted: Thu Mar 12, 2015 10:47 am
by turboscrew
How about Pi 2 USB?
I understand that for RasPi A, there is one USB: the Synopsys' module built into the VideoCore IV, that is directly connected to the USB-connector. In RasPi B, that same module is used, but connected to the integrated USB HUB in LAN9512, but how about Pi B+ and Pi 2? It has 4 USB ports, but they were not found in the schema.

Re: bare metal resources

Posted: Thu Mar 12, 2015 2:07 pm
by rpdom
The Pi 2 and B+ use a LAN9514 instead of a LAN9512. It's the same chip, but with 4 USB ports instead of 2.

Re: bare metal resources

Posted: Fri May 22, 2015 7:22 am
by sheroy
One more bare metal development link in c

This is a bit higher by using c but essentially instead of writing in assembly one can write in c ... g-in-cpt1/

Re: bare metal resources

Posted: Sat Jun 13, 2015 1:44 pm
by rascol

Re: Bare Metal resources

Posted: Mon Nov 23, 2015 9:19 am
by Akane
VideoCore IV 3D Architecture Reference Guide errata: ... ide_errata

Re: Bare Metal resources

Posted: Mon Nov 23, 2015 9:31 am
by Akane

Re: Bare Metal resources

Posted: Wed Nov 25, 2015 12:59 am
by 27troadster
Coprocessor register values upon boot to bare metal:


Re: Bare Metal resources

Posted: Fri Dec 18, 2015 9:37 pm
by ausppc

CPU for models A, A+, B, B+, CM & Pi Zero : ARM1176JZF-S
Links to useful reference material:

CPU for Pi 2 : ARM Cortex-A7
No useful links.

Re: Bare Metal resources

Posted: Thu Feb 04, 2016 2:45 am
by Ultibo
Full featured Raspberry Pi bare metal in Free Pascal

Includes threading, networking, filesystems, USB, MMC/SD and more.

Re: Bare Metal resources

Posted: Wed Oct 12, 2016 3:48 am
by sharpcoder
complete c++ kernel for the raspberry pi:
And the guide on how to compile it:

The kernel was developed with a raspberry A. Though it should work on newer ones (as far as I am aware). The code is mostly pretty well commented and does its best to be as comprehensible as possible.

Re: Bare Metal resources

Posted: Wed Nov 16, 2016 12:33 pm
by dickon
This may be of use to some: Cypress have bought Broadcom's wifi business and released all the docs. They're at ... s%3A110101 with the Pi3's wifi / BT controller at ... _documents.

Re: STICKY: Bare Metal resources

Posted: Mon Aug 14, 2017 5:09 pm
by colinh
Peter Cockerell's ARM Assembly Language Programming book

This excellent book is a wonderful introduction to ARM assembler. It deals with the ancient ARM2 processor (as used in the original Acorn Archimedes computer - back when ARM was Acorn RISC machine :-) ) but almost all of it is still relevant.

Pete has kindly made it available for free at

The full book as a single (zipped) pdf file is at:

(History at

Re: STICKY: Bare Metal resources

Posted: Thu Feb 15, 2018 3:55 pm
by fredkerr

Divisions on 32-bit ARM that has no DIV instructions

Posted: Sun Dec 16, 2018 1:02 pm
by Arikania
This routine divides unsigned integers, and returns both the whole part and the remainder. I believe this to be the fastest routine possible on such processors.

The details are in this post.

Code: Select all

.balign 4
.type udiv, %function

  # r0		the enumerator
  # r1		the denominator

  @ at return:
  # r2		the whole part
  # r3		the remainder

  @ assumptions
  # the denominator is not 0
  # the function does not destroy its arguments or any register above r6

	# init
	movs	r2,#0
	movs	r3,r0

	# determine no. of leading bits in the denominator
	clz	r6,r1

10:	# trap 'division done'
	cmp	r3,r1

	it	lo
	bxlo	lr

	# determine preliminary shift size
	clz	r5,r3
	subs	r4,r6,r5

	# determine preliminary shifted denominator
	lsls	r5,r1,r4

	# adjust shift size and shifted denominator if the shifted denominator outranges the remainder
	cmp	r3,r5

	itt	lo
	sublo	r4,#1
	lsrlo	r5,#1

	# adjust results
	subs	r3,r5

	movs	r5,#1
	lsls	r5,r4
	orrs	r2,r5
	b	10b

This routine, in Thumb-2 code, is tested and verified.

With regards,