Anonymous user
Raspberry Pi Bare Bones: Difference between revisions
Updates QEMU information and notes addresses for raspi2 emulation.
[unchecked revision] | [unchecked revision] |
(Fixed minor bug where delays register could underflow. Marking the register used as an output register fixes it.) |
(Updates QEMU information and notes addresses for raspi2 emulation.) |
||
Line 129:
{
// The GPIO registers base address.
GPIO_BASE = 0x20200000, // 0x3F200000 for raspi2 and raspi3
// The offsets for reach register.
Line 140:
// The base address for UART.
UART0_BASE = 0x20201000, // 0x3F201000 for raspi 2 and raspi3
// The offsets for reach register for the UART.
Line 249:
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 raspi1 and 0x3F000000 for raspi2 and raspi3. You can find the addresses of registers and how to use them in the bcm2835 manual.
Compile using:
Line 380 ⟶ 382:
=== Testing your operating system (QEMU) ===
QEMU supports emulating raspberry pi 2 with the machine type "raspi2". At the time of writing this feature is not available in most package managers but can be found in the latest qemu source found here: https://github.com/qemu/qemu
Check that your qemu install has qemu-system-arm and that it supports the option "-M raspi2". When testing in QEMU, be sure to use the raspi2 base addresses noted in the source code.
With qemu you do not need to objcopy the kernel into a plain binary; QEMU also supports ELF kernels:
<source lang=text>
$YOURINSTALLLOCATION/bin/qemu-system-arm -kernel kernel.elf
</source>
== See Also ==
|