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.
- mahjongg
- Forum Moderator
- Posts: 15100
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
bare metal resources
headers from the Broadcom GPU source code
https://rawgithub.com/msperl/rpi-regist ... sters.html
The full project including the scripts which were used to generate it can be found here:
https://github.com/msperl/rpi-registers
- SD - for SDRAM
- L1 - for Level 1 cache
- L2 - for Level 2 cache
- H264 - for the H264 encoder/devoder i assume
- FPGA - ?
https://rawgithub.com/msperl/rpi-regist ... sters.html
The full project including the scripts which were used to generate it can be found here:
https://github.com/msperl/rpi-registers
- mahjongg
- Forum Moderator
- Posts: 15100
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: bare metal resources
BCM2835-ARM-Peripherals:
http://www.raspberrypi.org/wp-content/u ... herals.pdf
and its errata info
http://elinux.org/BCM2835_datasheet_errata
GPIO-Pads-Control:
http://www.scribd.com/doc/101830961/GPIO-Pads-Control2
ARM1176JZFS technical documentation:
http://infocenter.arm.com/help/topic/co ... p7_trm.pdf
bare metal programming WiKi:
http://en.wikibooks.org/wiki/Bare-metal ... rogramming
http://www.raspberrypi.org/wp-content/u ... herals.pdf
and its errata info
http://elinux.org/BCM2835_datasheet_errata
GPIO-Pads-Control:
http://www.scribd.com/doc/101830961/GPIO-Pads-Control2
ARM1176JZFS technical documentation:
http://infocenter.arm.com/help/topic/co ... p7_trm.pdf
bare metal programming WiKi:
http://en.wikibooks.org/wiki/Bare-metal ... rogramming
Docs for BCM283X and firmware
Information for the Raspberry Pi / BCM2835
https://github.com/raspberrypi/firmware/wiki
https://github.com/raspberrypi/firmware/wiki/_pages
ghans
- ARMv6-M Architecture Reference Manual ("ARM ARM" , DDI 0419C)
https://c4everyone.com/pub/ARM/DDI0419C.pdf - ARM1176JZF-S Technical Reference Manual
http://infocenter.arm.com/help/topic/co ... p7_trm.pdf - Peripherials documentation
http://www.raspberrypi.org/wp-content/u ... herals.pdf
- Peripherials documementation
https://www.raspberrypi.org/documentati ... rev3.4.pdf - ARM Cortex-A7 Technical Reference Manual ("ARM TRM" , DDI 0464F)
http://infocenter.arm.com/help/index.js ... index.html - ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition ("ARM ARM" , DDI 0406C)
http://infocenter.arm.com/help/index.js ... index.html
- Peripherials documementation (same as Raspberry Pi 2)
https://www.raspberrypi.org/documentati ... rev3.4.pdf - ARM Cortex-A53 MPCore Processor Technical Reference Manual
http://infocenter.arm.com/help/topic/co ... p2_trm.pdf - ARMv8 Architecture Reference Manual
https://people.mozilla.org/~sstangl/arm ... Manual.pdf
- Peripherials documementation
https://datasheets.raspberrypi.org/bcm2 ... herals.pdf - ARM Cortex-A72 MPCore Processor Technical Reference Manual
https://documentation-service.arm.com/s ... b61?token= - ARMv8 Architecture Reference Manual
https://people.mozilla.org/~sstangl/arm ... Manual.pdf
https://github.com/raspberrypi/firmware/wiki
https://github.com/raspberrypi/firmware/wiki/_pages
ghans
Last edited by ghans on Thu Jun 10, 2021 6:57 am, edited 16 times in total.
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
USB and GPU information
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:
http://xinu.mscs.mu.edu/Synopsys_Design ... Controller
Otherwise , have a look at the USPi project of R. Stange , which
is ready for integration in your open-source projects (GPLv3) :
http://www.raspberrypi.org/forums/viewt ... 72&t=92579
GPU Documentation / VideoCore® IV 3D Architecture Reference Guide
https://docs.broadcom.com/docs/12358545
More documentation for the GPU (reverse-engineered) :
https://github.com/hermanhermitage/videocoreiv
Documentation for the LAN9512 chip of the Model B (an USB hub with an integrated USB Network card):
http://ww1.microchip.com/downloads/en/D ... c/9512.pdf
ghans
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:
http://xinu.mscs.mu.edu/Synopsys_Design ... Controller
Otherwise , have a look at the USPi project of R. Stange , which
is ready for integration in your open-source projects (GPLv3) :
http://www.raspberrypi.org/forums/viewt ... 72&t=92579
GPU Documentation / VideoCore® IV 3D Architecture Reference Guide
https://docs.broadcom.com/docs/12358545
More documentation for the GPU (reverse-engineered) :
https://github.com/hermanhermitage/videocoreiv
Documentation for the LAN9512 chip of the Model B (an USB hub with an integrated USB Network card):
http://ww1.microchip.com/downloads/en/D ... c/9512.pdf
ghans
Last edited by ghans on Mon May 15, 2017 7:05 am, edited 17 times in total.
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Re: bare metal resources
David Welchs bare metal examples :
https://github.com/dwelch67/raspberrypi
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 :
http://www.cl.cam.ac.uk/projects/raspbe ... orials/os/
A nice tutorial on writing bare-metal assembly for the Pi.
ghans
https://github.com/dwelch67/raspberrypi
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 :
http://www.cl.cam.ac.uk/projects/raspbe ... orials/os/
A nice tutorial on writing bare-metal assembly for the Pi.
ghans
Last edited by ghans on Mon Apr 13, 2015 9:50 am, edited 2 times in total.
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Re: bare metal resources
Link to an example of Raspberry Pi running FreeRTOS and µGFX as GUI using the framebuffer (output on HDMI or composite)
-> http://macload1.frogcp.com
-> http://macload1.frogcp.com
Re: bare metal resources
Here are some Bare Metal Raspberry Pi examples that use very minimal & simple ARM Assembly only:
https://github.com/PeterLemon/RaspberryPi
Here is what you will find:
LZSS & Huffman Decompression: https://github.com/PeterLemon/Raspberry ... r/Compress
GB Z80 Emulator with minimal hardware attached to run some GameBoy ROMs: https://github.com/PeterLemon/Raspberry ... MU/GameBoy
Hello World console text output demos, using the CPU or DMA with Stride: https://github.com/PeterLemon/Raspberry ... HelloWorld
GPIO Input demos using a SNES or NES Controller, & the SNES Mouse: https://github.com/PeterLemon/Raspberry ... ster/Input
Sound Playback demos using the PWM: https://github.com/PeterLemon/Raspberry ... /Sound/PWM
TAGS Channel demo which prints all Raspberry Pi Mailbox TAGS information to the screen: https://github.com/PeterLemon/Raspberry ... 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: https://github.com/PeterLemon/Raspberry ... master/V3D
VFP demos to display a static Mandelbrot fractal using Raspberry Pi ARM Floating point (FPU) instructions, & an animated Julia fractal: https://github.com/PeterLemon/Raspberry ... 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
https://github.com/PeterLemon/RaspberryPi
Here is what you will find:
LZSS & Huffman Decompression: https://github.com/PeterLemon/Raspberry ... r/Compress
GB Z80 Emulator with minimal hardware attached to run some GameBoy ROMs: https://github.com/PeterLemon/Raspberry ... MU/GameBoy
Hello World console text output demos, using the CPU or DMA with Stride: https://github.com/PeterLemon/Raspberry ... HelloWorld
GPIO Input demos using a SNES or NES Controller, & the SNES Mouse: https://github.com/PeterLemon/Raspberry ... ster/Input
Sound Playback demos using the PWM: https://github.com/PeterLemon/Raspberry ... /Sound/PWM
TAGS Channel demo which prints all Raspberry Pi Mailbox TAGS information to the screen: https://github.com/PeterLemon/Raspberry ... 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: https://github.com/PeterLemon/Raspberry ... master/V3D
VFP demos to display a static Mandelbrot fractal using Raspberry Pi ARM Floating point (FPU) instructions, & an animated Julia fractal: https://github.com/PeterLemon/Raspberry ... 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
Last edited by krom on Wed Jan 21, 2015 3:42 am, edited 1 time in total.
Re: bare metal resources
A couple C based bare metal examples
https://github.com/novellus/Bare-Metal- ... -Pi-Kernel
https://github.com/novellus/Bare-Metal- ... -Pi-Kernel
LEDs (plural) on the Raspberry Pi / Pi2
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.
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.
-
- Posts: 174
- Joined: Sat Jan 18, 2014 1:50 pm
- Location: Nokia (town), Finland
Re: bare metal resources
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.
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.
De-bugging is for sissies - real men do de-monstrations.
Re: bare metal resources
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
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
http://www.valvers.com/open-software/ra ... g-in-cpt1/
This is a bit higher by using c but essentially instead of writing in assembly one can write in c
http://www.valvers.com/open-software/ra ... g-in-cpt1/
Re: bare metal resources
A VideoCoreIV assembler: http://maazl.de/project/vc4asm/doc/index.html
Re: Bare Metal resources
VideoCore IV 3D Architecture Reference Guide errata: http://elinux.org/VideoCore_IV_3D_Archi ... ide_errata
Re: Bare Metal resources
- qpu-trivial-assembler -- An assembler for VideoCore IV QPU: https://github.com/Terminus-IMRC/qpu-trivial-assembler
- mailbox -- Library for accessing the Mailbox Interface on VideoCore IV: https://github.com/Terminus-IMRC/mailbox
- mailboxinfo -- Print information from the Mailbox Interface of VideoCore IV: https://github.com/Terminus-IMRC/mailboxinfo
- libvc4v3d -- Library for accessing VideoCore IV V3D: https://github.com/Terminus-IMRC/libvc4v3d
- libvc4vec -- Library for vector calculations on VideoCore IV QPU: https://github.com/Terminus-IMRC/libvc4vec
- qpuinfo -- Print information from VideoCore IV V3D: https://github.com/Terminus-IMRC/qpuinfo
- vpu_cpuid -- Print cpuid of VideoCore IV VPU: https://github.com/Terminus-IMRC/vpu_cpuid
-
- Posts: 25
- Joined: Sun Apr 12, 2015 12:10 pm
Re: Bare Metal resources
From https://en.wikipedia.org/wiki/Raspberry_Pi
CPU for models A, A+, B, B+, CM & Pi Zero : ARM1176JZF-S
Links to useful reference material: https://en.wikipedia.org/wiki/ARM11#External_links
CPU for Pi 2 : ARM Cortex-A7
No useful links.
CPU for models A, A+, B, B+, CM & Pi Zero : ARM1176JZF-S
Links to useful reference material: https://en.wikipedia.org/wiki/ARM11#External_links
CPU for Pi 2 : ARM Cortex-A7
No useful links.
Re: Bare Metal resources
Full featured Raspberry Pi bare metal in Free Pascal
https://ultibo.org
Includes threading, networking, filesystems, USB, MMC/SD and more.
https://ultibo.org
Includes threading, networking, filesystems, USB, MMC/SD and more.
Ultibo.org | Make something amazing
https://ultibo.org
Threads, multi-core, OpenGL, Camera, FAT, NTFS, TCP/IP, USB and more in 3MB with 2 second boot!
https://ultibo.org
Threads, multi-core, OpenGL, Camera, FAT, NTFS, TCP/IP, USB and more in 3MB with 2 second boot!
- sharpcoder
- Posts: 39
- Joined: Tue Mar 12, 2013 9:07 pm
- Location: Seattle, WA
Re: Bare Metal resources
complete c++ kernel for the raspberry pi: https://github.com/SharpCoder/rpi-kernel
And the guide on how to compile it: https://rpidev.wordpress.com
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.
And the guide on how to compile it: https://rpidev.wordpress.com
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
This may be of use to some: Cypress have bought Broadcom's wifi business and released all the docs. They're at http://www.cypress.com/search/all?f%5B0 ... s%3A110101 with the Pi3's wifi / BT controller at http://www.cypress.com/documentation/da ... _documents.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.
Re: STICKY: Bare Metal resources
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 http://www.peter-cockerell.net/aalp/html/frames.html
The full book as a single (zipped) pdf file is at: http://peter-cockerell.net/aalp/resources/pdf/all.zip
(History at http://www.peter-cockerell.net/aalp/)
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

Pete has kindly made it available for free at http://www.peter-cockerell.net/aalp/html/frames.html
The full book as a single (zipped) pdf file is at: http://peter-cockerell.net/aalp/resources/pdf/all.zip
(History at http://www.peter-cockerell.net/aalp/)
Re: STICKY: Bare Metal resources
Raspberry Pi 3 Model B JTAG and ARMv8 OpenOCD fork:
https://github.com/daniel-k/rpi3-aarch64-jtag
https://github.com/daniel-k/openocd
https://github.com/daniel-k/rpi3-aarch64-jtag
https://github.com/daniel-k/openocd
Divisions on 32-bit ARM that has no DIV instructions
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.
This routine, in Thumb-2 code, is tested and verified.
With regards,
Arikania
The details are in this post.
Code: Select all
.text
.balign 4
.type udiv, %function
.thumb_func
udiv:
# 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,
Arikania