Although the Raspberry-Pi comes with a good Linux distribution, the Pi is about software development, and sometimes we want a real-time system without an operating system.I decided it’d be great to do a tutorial outside of Linux to get to the resources of this great piece of hardware in a similar vein to the [Cambridge University Tutorials]( which are excellently written.Lets compile and link the following program: There are build “scripts” for each of the different types of Raspberry-pi under the part-1/armc-00 directory of the tutorials source code.There are three types, the original which is targeted with built.bat/sh, the B which has the extended IO connector and fixing holes but it still a V1 RPi which is targeting using build-rpi-bplus.bat/sh and finally the V2 board which features a quad core processor and also has the extended IO connector and fixing holes which is targeted with build-rpi-2.bat/sh.The linker will resolve symbols to addresses when it has arranged all the objects according to the rules in the linker script.What we’re getting close to here is that a C program isn’t just the code we type.
All of the source in the tutorials is available from the Github repo.
The V1 boards are fitted with the Broadcom BCM2835 (ARM1176) and the V2 board uses the BCM2836 (ARM Cortex A7).
Because of the processor difference, we use different build commands to build for V1 or V2 boards, hence the different scripts for building: So with our one-line command above we’re invoking the C compiler, the assembler and the linker. In our case, we are our own OS at we’re the only thing running, and in fact we will never exit so we do not need to really worry about it.
It generally sets up a stack pointer, and it always includes a call to _main.
Here’s an important note: symbols present in C code get prepended with an underscore in the generation of the assembler version of the code.