33.2. Baremetal bootloaders
As can be seen from Baremetal GDB step debug, all examples under baremetal/, with the exception of baremetal/arch/<arch>/no_bootloader
, start from our tiny bootloaders:
Out simplistic bootloaders basically setup up just enough system state to allow calling:
-
C functions such as
exit
from the assembly examples -
the
main
of C examples itself
The most important things that we setup in the bootloaders are:
-
the stack pointer
-
TODO: we don’t do this currently but maybe we should setup BSS
The C functions that become available as a result are:
-
Newlib functions implemented at baremetal/lib/syscalls.c
-
lkmc_
non-Newlib functions implemented at lkmc.c
It is not possible to call those C functions from the examples that don’t use a bootloader.
For this reason, we tend to create examples with bootloaders, as it is easier to write them portably.