Wednesday, August 6, 2014

Quick Note - Raspberry Pi - Bare Metal Programming

For a while I have wanted to give bate metal programming a go on on of the development boards I have.  Back in college one of my favorite courses was assembler.  Back then I was programming on a PDP 11/34 that supported multiple users with fewer resources than a Raspberry Pi.  Over the past weekend the weather and my todo list cooperated and I decided to give it a try.

Thanks to the wonderful Raspberry Pi community there is no shortage of resources to get you started.

These include:

An excellent complete online course called Baking Pi – Operating Systems Development on the University of Cambridge’s website.  This course walks you through 11 exercises with very good explanation and full examples.  The code is in assembler and uses the GNU Toolchain.

A series of three articles on www.valvers.com website that walk you through bare metal programming in C.  Again the content is excellent with step by step instructions and examples.

A wiki page on OSDev.org titled ARM Raspberry Pi Tutorial C gives more involved example in C that produces text output on the console port.

Another resource I found useful was Embedded Programming with the GNU Toolchain  This document is more general in nature but also helps to drive home a number of salient points including detail on the C startup and memory initialization process.

I was successfully able to download and install the GNU toolchain from launchpad.net on to my Windows 7 Pro desktop, successfully compile the examples in the www.valvers.com set of articles and the OSDev.org wiki page and copy them to an SD card where I had rename kernel.img to kernel.old and substituted my program.  When I inserted the sd card into my Raspberry Pi and turned the power on all the programs successfully ran.

For the OSDev.org wiki example I used a USB BUB connected to pins 13 – 15 on the Raspberry PI GPIO connector and putty running on my desktop to display the output

No comments: