Embedded Systems/Bootloaders and Bootsectors

To simplify many tasks, programmers for many systems will often employ a generic piece of software called a bootloader that will set some system settings (such as enabling protected mode), and then will be used to load the kernel, and then transfer control to the kernel for system operation. In embedded systems particularly, bootloaders are useful when doing work on the kernel: the kernel can be altered and tested, and the bootloader will automatically load each new version into memory.

To further simplify the process, the programmer can employ a tool called a bootmenu, which is essentially a bootloader that allows the user to select which kernel to load, from a list of possibilities. This is useful when multiple kernels are being compared, or when different versions of the same kernel are being debugged.

Bootloaders are used on many microcontrollers. A bootloader is often the fastest way to update a program in a microcontroller with small changes. That makes the edit-compile-download-test cycle a little bit faster.

The microcontroller can also have minimal hard-coded silicon dedicated to a simpler programming interface, which needs an expensive programmer socket. A vendor can then put a tiny program in Flash which reads the real program through the interface-du-jour, be it RS-232, I²C, wireless, or USB.

Bootloaders are traditionally written in pure assembly language, although it is possible to write a bootloader almost entirely in C.[1] Many bootloaders accept pre-compiled executable machine code bytes, often the output of a C compiler. A few bootloaders accept Forth source code and compile it on-the-fly.[2][3][4]

Further reading

edit
  1. "Compile and link a bootloader using SDCC"
  2. "One Laptop per Child: FORTH". "Forth is at the core of Open Firmware, the boot-loader for the XO-1."
  3. "The Boot Process (FreeBSD)". "the FreeBSD ... boot loader provides a FORTH-based environment".
  4. Wikipedia: Open Firmware.