fm2606
Posts: 6
Joined: Sat Jun 22, 2019 5:19 pm

Choosing Kernel Address ??

Sat May 15, 2021 10:38 pm

I was futzing around on a Pi 4 and cobbled together a bare metal program that wrote Hello World on the screen using the UART and no OS. I did this all in assembly language and mainly from using other's code. There is a lot of code out there that starts with ASM but then ends up using C for their kernel. I wanted to see if I could get one going entirely in ASM, which I did, albeit tearing other's code down to the bare minimum.

Anyway, this article https://www.raspberrypi.org/documentati ... xt/boot.md states for 32-bit the kernel starts at 0x8000, by default and for a 64-bit system at 0x80000 by default.

Looking around github I see kernels starting in various locations. What determines where to put the code? Is there some sort of documentation or rule of thumb for this?

Just curious

Thanks
fm2606

cleverca22
Posts: 3752
Joined: Sat Aug 18, 2012 2:33 pm

Re: Choosing Kernel Address ??

Sat May 15, 2021 11:24 pm

kernel_address lets you force the firmware to load to a certain address
if your kernel starts out properly position independent, and turns on the MMU, then you can load anywhere, and the MMU can deal with the offset

fm2606
Posts: 6
Joined: Sat Jun 22, 2019 5:19 pm

Re: Choosing Kernel Address ??

Sun May 16, 2021 10:01 am

But what is the criteria for putting it in one memory location over another? Why do people choose something other than the default 0x8000 / 0x80000 location(s)?

LdB
Posts: 1689
Joined: Wed Dec 07, 2016 2:29 pm

Re: Choosing Kernel Address ??

Sun May 16, 2021 10:08 am

The default is simply that which was chosen by linux groups doing ARM port ... as that is the normal target for the Pi it defaults to that. As to the argument why it is that you would need to hit the ARM linux development forum.

fm2606
Posts: 6
Joined: Sat Jun 22, 2019 5:19 pm

Re: Choosing Kernel Address ??

Sun May 16, 2021 3:46 pm

Thanks for all the replies.

timanu90
Posts: 85
Joined: Sat Dec 24, 2016 11:54 am

Re: Choosing Kernel Address ??

Tue May 18, 2021 4:39 pm

One of the reasons you see different kernel entry addresses could be because some people place a bootloader on the 0x8000 or 0x80000, and they load the kernel elsewhere so they don't collide.

Return to “Bare metal, Assembly language”