-
Notifications
You must be signed in to change notification settings - Fork 0
Hello world!
In this section, the first objective is to display a Hello world missatge through UART communication. The working directory is here. There are a few important files to perform a boot and send messages:
- boot.S : Is the first code to be runned, here be need to prepare some parameters.
- linker.ld : This file contains instructions for the compiler and define some memory regions.
- kernel.c : here it is the main method, called by the boot.S
With this files correctly programmed, the linker puts the boot.S at the address 0x0 and the CPU starts running this file. When the setup is completed, the boot.S jumps to the kernel.c main method and here it's possible to interact with the memory positions and peripherals.
The next step is a lecture of the ARM-peripherals manual and design some interface to work with the GPIO pins and the UART module.
For every GPIO pin there are some predefined function, designed by the GPIO function select register(pg. 91 ). Also, there are particular register for read the actual value of a pin and set/clear a pin. For this particular case, the interface I designed is:
void setfunctionGPIO(int pin, const int F);
void setPin(int pin);
void clrPin(int pin);
enum level {LVL_HIGH, LVL_LOW};
level levelPin(int pin);With this interface, configure the UART module, with the manual instructions is quite simple. The uart_init method configures the UART module to 115200 Bauds.
The latest qemu version can emule a the behavior of a real Raspberry Pi but with some differences with the real Raspberry pi:
- Some peripherals don't exists (like the GPIO pins)
- The starting address for the boot section is the 0x80000 while the real hardware uses the 0x80000.
- The time is not quite realistic For this reason, there is conditional compilation in some regions of code and a specific linker for the Qemu. A script is in all the working folders for running the Qemu with the specific flags and emulate the Raspberry Pi.
For debug the qemu, is necessary to compile with the -g flag and run the qemu with some flags. A script for a qemu debugging session (runDBG.sh) and a script for set the gdb debugger (gdbscript) with the qemu are written.
For use this code in the real Raspberry pi, is necessary to compile all the code (with a Makefile) and put in the SD booting area the kernel8.img file. This file is where the Raspberry Pi boot.
Finally, a printf, string and bool definitions were added for get a better environment development.
Powered by GreenTreeData