What is Bootloader? how could we implement it? what is relation between the bootloader and startup code?

What is Bootloader? how could we implement it? what is relation between the bootloader and startup code?

Q1)

Bootloader is a piece of code that allows us to update firmware, burn new applications, or even burn multiple applications in the same flash memory through a communication interface without the need for an external programmer by using a flash driver peripheral and any suitable communication protocol.

Bootloader is usually placed in the flash memory and takes up a small space in the flash. The less the bootloader code size the more available space for the burned application code so it is better to reduce the bootloader code size as much as possible.

After burning the application in the flash, the bootloader gives control to the application code to run in normal operation mode.

As we said we can burn new updates with any communication protocol (not only SWD or JTAG...). It is a huge benefit that allows us to update all the car ECUs by sniffing to the bus with the same common protocol and sending our update to all ECUs using the same protocol.

Notes :

1- We can use the bootloader burning method if and only if the microcontroller has a flash driver peripheral without it we shall use another burning method like on-chip programming or any other method but we cannot use the bootloader method.

2- We can implement bootloader code based on any suitable communication protocol for example USART. In this case, it is called USART Bootloader.

3- You can implement your bootloader code with any feature you need like :

-Burning the new update during the app running.

-Check for updates in a while during booting if there are no updates the bootloader jumps to the original application. etc...

It all depends on the business's needs

Q2)

The simplest bootloader contains two parts (main bootloader code and parsing code). Parsing code is mandatory code to understand the dex records which already been sent to the flash drive to be burned on the flash, in this code we parse all the records, and depending on each record type we take a suitable action with the record.

Q3)

We should understand that the bootloader code is normal so it includes its startup code to initialize code so it includes its startup code to initialize memory sections and call its entry point. But the common factor between them is that both of them seem like they work at the beginning of the program but the sequence goes like below.

1- Bootloader start-up code runs first

2- The bootloader main code runs after it is called from the bootloader startup code.

3- We jump to the application code

4- Application start-up code runs

5- The application main code runs after it is called from the application startup code

#bootloader #embeddedsoftware #embeddeddeveloper #automotive #firmware #ebgineering