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

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

https://github.com/raspberrypi/firmware/wiki
https://github.com/raspberrypi/firmware/wiki/_pages

ghans

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:

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

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 :

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

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)

-> http://macload1.frogcp.com

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

Re: bare metal resources

Posted: Sun Jan 11, 2015 8:19 am
by novellus
A couple C based bare metal examples
https://github.com/novellus/Bare-Metal- ... -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

http://www.valvers.com/open-software/ra ... 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: http://elinux.org/VideoCore_IV_3D_Archi ... 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:

viewtopic.php?f=72&t=126891

Re: Bare Metal resources

Posted: Fri Dec 18, 2015 9:37 pm
by ausppc
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.

Re: Bare Metal resources

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

https://ultibo.org

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

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

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

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

.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