What are bootloaders?

When the computer is first turned on it has a clear state. Meaning there are no programs in it’s memory and it’s incapable of accessing its components (storage ,I/O devices etc)

So the first step that is required is to enable the computer to gain access to them. For this purpose as soon as the computer starts it runs a bootloader that bootstraps the startup process.

Bootloaders initialize the hardware and pass on the control to the kernel which proceeds to initialize the operating system. That’s all they do.

Since bootloaders sit between hardware and software they give booting choices to users. They can let us

  1. Choose from different operating systems

  2. Boot operating system into safe mode for recovery.

  3. Choose different versions of operating systems.

  4. Or boot directly into a program without starting the operating system first. (This is used for example in many game consoles,if you have a game disc inserted when you start the console.it can take you right into the game rather than a welcome screen)

For PCs the ROM contains BIOS (or EFI) that looks for a bootloader at a certain location and execute it [1]

As you might have guessed there are stages to a bootloader. The bootloader is read from a ROM and executed. At the end of this process I/O components and storage components are ready.

The computer has changed its state from passive just a powered in CPU, to active a device can use different parts. It can now use these components.

The last thing that remains for the first stage bootloader to do is find the second stage bootloader so that the control may be passed on to the operating system.

Now most of the times the second stage bootloader is located on a storage within a device itself. Some place in a hard disk. The first stage bootloader knows about this location and hence finds and executes the second stage loader.

From there on the OS kernel is loaded followed by os itself.

As it often happens at the time of a new purchase a hard disk,there may not actually be a boot record for the bootloader. Therefore the first stage bootloader allows the user to specify boot locations. Most modern bootloaders allow you to boot from

  1. CD/DVD

  2. USB stick

  3. Network disk

In case of storage medium like CD and USB, the devices are formatted so that the first stage bootloader can find the boot record on it.

For network booting a boot image is placed on a known location on a server. This image is downloaded and executed on the machine.

Most of the time the interaction with the bootloader is rather minimal. It’s only when you want to install a new operating system. Or want to diagnose problems with your existing ones/use a different os, is the time when you take the trouble of going to the boot menu.

But understanding the boot process is important if you want to learn how computers work.

All electronic devices are turned on in the same way. Whether it’s your mobile, your laptop, your gaming consoles or your PC. They all boot the same way.

But some devices use the concept of a boot image on a flash. In such devices that kernel and the bootloader is packed into a single file and written onto the flash. This approach is quite common in smart phones like Android and in devices like wifi routers. [2]

Packing the kernel and bootloader into a single image does not change the boot process in anyway however. A bootloader still initializes the hardware and then passes the control to the kernel which will initialize the operating system.

However packing the bootloader with the kernel makes it difficult for the user to make changes to the device the way he wants. ROMs need to be packaged in exactly the same way as the device expects it to. And running multiple OS is more difficult because now there is no separation between the kernel and the bootloader.

Switching an Android operating system for instance is not quite as straightforward as switching the os in PC. And impossible if the bootloader is locked (as it is in many phones)

Still because embedded systems have a lot less room than PCs it makes sense to pack things together.

Types of bootloader and UBOOT

Since there are many types of computer architectures and many operating systems it’s natural that the bootloaders are specific to architecture and operating systems. This means that are many, many bootloaders on the market. Often they are proprietary and incompatible with each other. However open source applications like DAS U Boot are standardizing the process.

https://en.m.wikipedia.org/wiki/Das_U-Boot

DAS U BOOT works on almost all the system architectures and provides both first stage and second stage bootloading. It can also be packed into an image consisting both the Linux kernel as well as a bootloader in a package.

References

[1]https://askubuntu.com/questions/173248/where-is-the-bootloader-stored-in-rom-ram-or-elsewhere

[2]https://android.stackexchange.com/questions/29706/can-somebody-explain-the-boot-process-of-an-android-device/29738#29738

[3] A presentation on the boot process

https://www.cs.tau.ac.il/telux/lin-club_files/linux-boot/slide0000.htm

workrockin@gmail.com

Leave a comment

Design a site like this with WordPress.com
Get started