You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.adoc
+37-6Lines changed: 37 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10217,12 +10217,10 @@ then on the second shell:
10217
10217
./run-gdb --arch arm --baremetal interactive/prompt --no-continue
10218
10218
....
10219
10219
10220
-
and now we are left at the very first executed instruction of our tiny bootloader: link:baremetal/lib/arm.S[]
10220
+
and now we are left at the very first executed instruction of our tiny <<baremetal-bootloaders>>.
10221
10221
10222
10222
Then just use `stepi` to when jumping into main to go to the C code in link:baremetal/interactive/prompt.c[].
10223
10223
10224
-
The bootloader is used to put the hardware in its main operating mode before we run our main payload on it.
10225
-
10226
10224
You can also find executables that don't use the bootloader at all under `baremetal/arch/<arch>/no_bootloader/*.S`, e.g.:
10227
10225
10228
10226
....
@@ -10231,8 +10229,6 @@ You can also find executables that don't use the bootloader at all under `bareme
10231
10229
10232
10230
The cool thing about those examples is that you start at the very first instruction of your program, which gives more control.
10233
10231
10234
-
However, those examples tend to be less portable, so we use examples with the bootloader for the most part.
10235
-
10236
10232
Alternatively, skip directly to the C program main function with:
10237
10233
10238
10234
....
@@ -10253,6 +10249,33 @@ and on another shell:
10253
10249
10254
10250
`aarch64` GDB step debug is broken as mentioned at: <<gem5-gdb-step-debug-kernel-aarch64>>.
10255
10251
10252
+
=== Baremetal bootloaders
10253
+
10254
+
As can be seen from <<baremetal-gdb-step-debug>>, all examples under link:baremetal/[], with the exception of `baremetal/arch/<arch>/no_bootloader`, start from our tiny bootloaders:
10255
+
10256
+
* link:baremetal/lib/arm.S[]
10257
+
* link:baremetal/lib/aarch64.S[]
10258
+
10259
+
Out simplistic bootloaders basically setup up just enough system state to allow calling:
10260
+
10261
+
* C functions such as `exit` from the assembly examples
10262
+
* the `main` of C examples itself
10263
+
10264
+
The most important things that we setup in the bootloaders are:
10265
+
10266
+
* the stack pointer
10267
+
* NEON: <<aarch64-baremetal-neon-setup>>
10268
+
* TODO: we don't do this currently but maybe we should setup BSS
10269
+
10270
+
The C functions that become available as a result are:
10271
+
10272
+
* Newlib functions implemented at link:baremetal/lib/syscalls.c[]
10273
+
* non-Newlib functions implemented at link:common.c[]
10274
+
10275
+
It is not possible to call those C functions from the examples that don't use a bootloader.
10276
+
10277
+
For this reason, we tend to create examples with bootloaders, as it is easier to write them portably.
10278
+
10256
10279
=== Semihosting
10257
10280
10258
10281
Semihosting is a publicly documented interface specified by ARM Holdings that allows us to do some magic operations very useful in development.
@@ -10512,7 +10535,7 @@ output:
10512
10535
10513
10536
==== ARM multicore
10514
10537
10515
-
TODO get working: CPU 1 not waking up:
10538
+
TODO get working on QEMU, CPU 1 not waking up. gem5 works:
0 commit comments