Dr. MK Singh
Dr. MK Singh

Reputation: 1

How to create, compile and link a bootloader?

I am making a small operating system and written a working kernel in c for it. But how will I create a bootloader to call the kernel and compile and link the kernel and bootloader. I am using gcc and yasm. I can also use nasm if required.

Upvotes: 0

Views: 526

Answers (1)

Syed Waris
Syed Waris

Reputation: 1074

Basically there are 2 steps (highly simplified) during boot (specifically related to ARM based Embedded Linux boards):

  1. When the power is supplied, the processor wakes up and its ROM code is executed. This code is hardcoded into the chip provided by the manufacturer. This ROM code after doing basic harware preparation and sanity checks calls the bootloader. You need to look into the docs as to where (which address) this initial code looks for the bootloader. If it find the bootloader, it relinquishes its control and the control passes over to the bootloader.

  2. Again the bootloader looks for few pre-specified memory locations for the kernel binary (compiled image). It (bootloader) then relinquishes its control and passes control to the kernel (with few arguments and also sometimes the memory location of device tree).

AFAIK, the kernel and bootloader are not "compiled/linked" together usually. It is a process of one stage completely relinquishing itself and passing control to another (as explained in above 2 steps).

Upvotes: 1

Related Questions