Skip to content

Hello world!

Victor Correal Ramos edited this page May 2, 2020 · 9 revisions

In this section, the first objective is to display a Hello world missatge through UART communication. The working directory is here.

In order to achieve this objective, is needed to understand all the necessary code.

Booting process

There are a few important files to perform a boot:

  • boot.S : Is the first code to be runned, here be need to prepare some parameters and setups.
  • 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

For detailed reference, read the booting process section.

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 GPIO interface

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);

The UART module

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 and other calls to perform reading and writting to the UART channel we're added to the uart.c file.

Emulating & Debugging

In this section, there are some realted information about the Qemu and gdb-multiarch using.There are some important facts to take care about.

All together

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.

Clone this wiki locally