Monday 4 September 2017

Baking Pi Tutorial : Getting Started

Alex Chadwick at Cambridge University Computer Laboratory published a wonderful set of bare metal tutorials, some time around 2012 when RPi was first released.  After many years I decided to have a look at them.  I possess an RPi model B which the tutorials refer to which I will use for the tests.  I also have a dodgy SD card from a previous Jessie installation and I will use the FAT partition on that to load programs.

Unfortunately the compilation environment guidance wasn't very clear to me.  I wanted to use Windows for my program development but the downloads page suggested using YAGARTO (yet another GNU ARM toolchain) and MinGW (minimalist GNU for Windows) to achieve this, without providing guidance on how these should be setup for the cross-compiler.  YAGARTO development appeared to be completed or terminated in 2013 and instructions were minimal / unclear.  Although my MinGW installation was successful I couldn't (easily) get YAGARTO and MinGW to work together.

For initial testing I thought I would use a linux environment.  Clearly the obvious one to choose is an RPi!  Compiling on RPi means that we don't need a cross-compiler.  I used an RPI B+ running Stretch as my environment:
 Linux version 4.9.41+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG  crosstool-ng-1.22.0-88-g8460611) ) #1023 Tue Aug 8 15:47:12 BST 2017
I did need to install the library headers before programs would compile:
 apt-get install gcc-arm-none-eabi
I setup a BareMetal directory structure as directed and downloaded the template script for Makefile compilation.
I then typed in the small assembler program OK01 for Lesson 1 and ran make to build a standalone executable kernel.img.
I inserted my SDcard into my Windows computer copied kernel.img across, having renamed the old linux kernel.img.
Finally I inserted the SDcard in RPi model B, applied power and the LED lit as expected.

No comments:

Post a Comment