Raspberry Pi Bare Bones: Difference between revisions

[unchecked revision][unchecked revision]
Line 246:
</source>
 
The GPU bootloader passes arguments to the kernel via r0-r2 and the boot.S makes sure to preserve those 3 registers. They are the first 3 arguments in a C function call. The argument r0 contains a code for the device the rpiRPi was booted from. This is generally 0 but its actual value depends on the firmware of the board. r1 contains the 'ARM Linux Machine Type' which for the rpiRPi is 3138 (0xc42) identifying the bcm2708BCM2708 cpuCPU. A full list of ARM Machine Types is available from [http://www.arm.linux.org.uk/developer/machines/ here]. r2 contains the address of the ATAGs.
 
Notice how we wish to use the common C function strlen, but this function is part of the C standard library that we don't have available. Instead, we rely on the freestanding header <stddef.h> to provide size_t and we simply declare our own implementation of strlen. You will have to do this for every function you wish to use (as the freestanding headers only provide macros and data types).
 
The addresses for the GPIO and UART are offsets from the peripheral base address, which is 0x20000000 for raspi1Raspberry Pi 1 and 0x3F000000 for raspi2Raspberry Pi 2 and raspi3Raspberry Pi 3. You can find the addresses of registers and how to use them in the bcm2835BCM2835 manual.
 
Compile using:
Anonymous user