User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 15100
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

STICKY: Bare Metal resources

Sun Mar 16, 2014 5:48 pm

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.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 15100
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

bare metal resources

Sun Mar 16, 2014 5:52 pm

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:
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

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 15100
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: bare metal resources

Sun Mar 16, 2014 5:55 pm


ghans
Posts: 7893
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Docs for BCM283X and firmware

Fri Mar 28, 2014 7:57 pm

Information for the Raspberry Pi / BCM2835 Information for the Raspberry Pi 2 / BCM2836
Information for the BCM2837 (Raspberry Pi 3) NEW ! Information for the BCM2711 (Raspberry Pi 4)
Communicating with the GPU via Mailboxes

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

ghans
Posts: 7893
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

USB and GPU information

Thu May 15, 2014 1:42 pm

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
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


ghans
Posts: 7893
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: bare metal resources

Sat May 24, 2014 8:24 am

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
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

macload1
Posts: 21
Joined: Mon Jul 07, 2014 6:50 am

Re: bare metal resources

Mon Jul 07, 2014 6:54 am

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

krom
Posts: 61
Joined: Wed Dec 05, 2012 9:12 am

Re: bare metal resources

Thu Dec 11, 2014 10:37 am

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
Last edited by krom on Wed Jan 21, 2015 3:42 am, edited 1 time in total.

novellus
Posts: 1
Joined: Sun Jan 11, 2015 8:16 am

Re: bare metal resources

Sun Jan 11, 2015 8:19 am

A couple C based bare metal examples
https://github.com/novellus/Bare-Metal- ... -Pi-Kernel

mrvn
Posts: 58
Joined: Wed Jan 09, 2013 6:50 pm

LEDs (plural) on the Raspberry Pi / Pi2

Sat Feb 28, 2015 6:11 pm

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.

turboscrew
Posts: 174
Joined: Sat Jan 18, 2014 1:50 pm
Location: Nokia (town), Finland

Re: bare metal resources

Thu Mar 12, 2015 10:47 am

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.
De-bugging is for sissies - real men do de-monstrations.

User avatar
rpdom
Posts: 22784
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: bare metal resources

Thu Mar 12, 2015 2:07 pm

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.

sheroy
Posts: 47
Joined: Fri Jun 14, 2013 5:34 pm

Re: bare metal resources

Fri May 22, 2015 7:22 am

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/

rascol
Posts: 13
Joined: Sat May 30, 2015 1:48 pm

Re: bare metal resources

Sat Jun 13, 2015 1:44 pm


User avatar
Akane
Posts: 59
Joined: Tue May 27, 2014 1:20 pm
Location: Tsukuba, Japan

Re: Bare Metal resources

Mon Nov 23, 2015 9:19 am

VideoCore IV 3D Architecture Reference Guide errata: http://elinux.org/VideoCore_IV_3D_Archi ... ide_errata

User avatar
Akane
Posts: 59
Joined: Tue May 27, 2014 1:20 pm
Location: Tsukuba, Japan

Re: Bare Metal resources

Mon Nov 23, 2015 9:31 am


27troadster
Posts: 25
Joined: Sun Apr 12, 2015 12:10 pm

Re: Bare Metal resources

Wed Nov 25, 2015 12:59 am

Coprocessor register values upon boot to bare metal:

viewtopic.php?f=72&t=126891

ausppc
Posts: 18
Joined: Sat Apr 21, 2012 8:51 pm

Re: Bare Metal resources

Fri Dec 18, 2015 9:37 pm

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.

User avatar
Ultibo
Posts: 173
Joined: Wed Sep 30, 2015 10:29 am
Location: Australia

Re: Bare Metal resources

Thu Feb 04, 2016 2:45 am

Full featured Raspberry Pi bare metal in Free Pascal

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!

User avatar
sharpcoder
Posts: 39
Joined: Tue Mar 12, 2013 9:07 pm
Location: Seattle, WA

Re: Bare Metal resources

Wed Oct 12, 2016 3:48 am

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.

User avatar
dickon
Posts: 2516
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, in Tiffield

Re: Bare Metal resources

Wed Nov 16, 2016 12:33 pm

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.

colinh
Posts: 123
Joined: Tue Dec 03, 2013 11:59 pm

Re: STICKY: Bare Metal resources

Mon Aug 14, 2017 5:09 pm

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/)

fredkerr
Posts: 2
Joined: Fri Feb 02, 2018 11:32 pm

Re: STICKY: Bare Metal resources

Thu Feb 15, 2018 3:55 pm


Arikania
Posts: 18
Joined: Tue Sep 11, 2018 6:44 am

Divisions on 32-bit ARM that has no DIV instructions

Sun Dec 16, 2018 1:02 pm

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

.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

Return to “Bare metal, Assembly language”