Recently, we have received the STM32 Nucleo-144 board. We thought of providing a Tutorial Series that explains How to design and write our own bootloader for STM32 Devices. Before start writing the code, we must know about what is the bootloader, why it is required. This post will give you a basics understanding of the bootloader (Bootloader Basics).
The bootloader is a very important component in any operating system. A bootloader, also known as a boot program or bootstrap loader. It is special operating system software that loads into the working memory of a computer after start-up. So, you must be clear that this is also a software like an application. The term bootloader is a shortened form of the words “bootstrap loader”.
How does the bootloader work?
To understand the operations of the bootloader, you don’t need to be an expert in the embedded systems. If you have used Windows operating system, then that is fair enough.
Have you noticed some text comes before the windows logo comes when you turn on the system? At the time of booting, if you press the Shift key or F12 key, then you may see one blue color screen with some options. Yes, that is the bootloader. It will do some operations based on the need. Once it has done its work, then it will give control to the OS. Then OS will take care of the system running. You can take any OS including Mac, Linux. All OS has the bootloader which will run initially.
What is a Bootloader in Embedded systems?
Like a normal OS, the bootloader in a microcontroller also serves the same purpose. This is the first piece of code that runs when you press the reset button if you have a bootloader. If you don’t have a bootloader, then directly an application will start running. We have already discussed, what happens when we press the reset button if the bootloader is not present in STM32 (Cortex M4).
If you have a bootloader, then before application, this bootloader starts running and does some process. Once it is done with the operations, the bootloader job is done. So, it gives control to the application. Now, the application does its job based on our product or project.
What is the need for Bootloader in Microcontroller?
Is it really useful? Why do we need this? Still, I am using a project which doesn’t have a bootloader. I will try to answer the questions.
I agree that when you don’t have a bootloader, it is very simple. We are not complicating by writing an extra bootloader. Only application is enough. But when you are planning to sell your products to the customers, what will do if you want to update the application/firmware in the device that you sold already? Every time go to the field and connect the JTAG/J-LINK and flash the firmware or application? It is not possible, right? So, If you have your bootloader, then you don’t need to worry about that. You can update the firmware or application without connecting any debugger or flasher.
When you have the product which has to be secured, then what will you do when someone overwrites the application or firmware with their customized firmware to hack your product? How do you find it? In this case, we can use the bootloader to check whether the firmware is valid or not. If it is valid, then only we give control to the firmware or application.
In our next post, we will design our custom bootloader for the STM32 devices.
You can also read the below tutorials.