There are some fundamental things that must happen for C code to run.For example, some variables need to be initialised to certain values, and some variables need to be initialised to 0.
For the Raspberry-Pi 2 we know that the architecture is different.
The GCC ARM Embedded project on Launchpad gives us a GCC toolchain to use for ARM compilation on either Windows or Linux.
I suggest you install it (on Windows I would install it somewhere without spaces in the file path) so that you have it in your path.
The compiler converts C statements into assembler and performs optimisation of the assembly instructions. The C compiler then implicitly calls the assembler to assemble that file (usually a temporary) into an object file.
This will have relocatable machine code in it along with symbol information for the linker to use.
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.So where the start of a C program is the main symbol, in assembler we need to refer to it as it’s assembler version which is _main.All of the source in the tutorials is available from the Github repo.However, they don’t create an OS as purported and they start from assembler rather than C.I will simply mimic their tutorial here, but using C instead of assembler.The settings are gleaned from the GCC ARM options page.