Bootloader

Thread Starter

omac24

Joined Jun 22, 2021
2
Hello Everyone,
I am new to the bootloader concept and i really want to learn this. First of all i have some doubts regarding to the bootloader
1. How bootloader checks if there is any valid application is present or not?
2. Valid Application? What do you mean by Application, is it our code that we are going to flash or execute(our written code for particular project) or it is bootloader code
3. Where valid application gets stored? And if valid application is present then it will again flash the application or application once stored it will be there
always and if it is invalid then only it will flash again?
4. Bootloader code is stored in the flash. is there any way to change the bootloader code?

Thank You in advance, waiting for your replies....
 

Dave Lowther

Joined Sep 8, 2016
224
Are you considering a specific microcontroller or do you just want to know about bootloaders in general?
If the former please say which microcontroller.
 

Papabravo

Joined Feb 24, 2006
21,157
Hello Everyone,
I am new to the bootloader concept and i really want to learn this. First of all i have some doubts regarding to the bootloader
1. How bootloader checks if there is any valid application is present or not?
2. Valid Application? What do you mean by Application, is it our code that we are going to flash or execute(our written code for particular project) or it is bootloader code
3. Where valid application gets stored? And if valid application is present then it will again flash the application or application once stored it will be there
always and if it is invalid then only it will flash again?
4. Bootloader code is stored in the flash. is there any way to change the bootloader code?

Thank You in advance, waiting for your replies....
  1. AFAIK a bootloader is a simple and unsophisticated program for loading another program into memory. There is generally no criteria for what is and is not a valid program.
  2. Without specific criteria for making such a determination there is no way to answer that question
  3. Bootloaders will generally speaking write all new program over any programs that were previously there. I don't think I have ever seen one that managed multiple distinct program spaces.
  4. Yes bootloader code can be updated with new bootloader code,
Some additional points to remember:
  1. Bootloaders are designed to have as few instructions as possible.
  2. We used to enter them into memory manually with front panel switches.
  3. Most of us could commit the boot loader to memory so we could enter the instructions into a machine without looking at a reference sheet.
 

MrChips

Joined Oct 2, 2009
30,706
Hello Everyone,
I am new to the bootloader concept and i really want to learn this. First of all i have some doubts regarding to the bootloader
1. How bootloader checks if there is any valid application is present or not?
A computer in general begins life with no working code.
The bootloader is a short program or mechanism to load the first working code into the system.
The manufacturer has to provide a mechanism for getting the first user code into the system.

This could be:
  1. hardware mechanism
  2. non-erasable code in flash memory
  3. code in external memory

For example, Atmel ATmega328 uses hardware SPI to load the first code.
Arduino, which is based on the ATmega328 uses this mechanism to download its own bootloader so that the end user can use the serial port for loading a sketch (user program).

I can only speak from the perspective of small embedded systems using MCU.
PC, tablets, smartphones, servers, enterprise systems, etc. may use a different mechanism.
 

Dave Lowther

Joined Sep 8, 2016
224
  1. AFAIK a bootloader is a simple and unsophisticated program for loading another program into memory. There is generally no criteria for what is and is not a valid program.
  2. Without specific criteria for making such a determination there is no way to answer that question
  3. Bootloaders will generally speaking write all new program over any programs that were previously there. I don't think I have ever seen one that managed multiple distinct program spaces.
The ESP32 bootloader does check validity. https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/startup.html

1624372755245.png

That's partly why I asked in #2 to tell us if the question is about a specific microcontroller.
 

Papabravo

Joined Feb 24, 2006
21,157
I guess bootloaders are getting more sophisticated because they have the luxury of doing so. It is definitely a higher class bootloader than one that is entered manually on a set of switches.
 

Dave Lowther

Joined Sep 8, 2016
224
I guess bootloaders are getting more sophisticated because they have the luxury of doing so. It is definitely a higher class bootloader than one that is entered manually on a set of switches.
My first experience of a bootloader was on a Ferranti FM1600B http://www.computinghistory.org.uk/det/16840/Ferranti-FM1600-B/ IIRC it had a rotary switch to enter the bootloader into core memory. Rotating the switch caused one bootloader instruction to be clocked into memory for each switch position. Things have indeed moved on :)
 

MrChips

Joined Oct 2, 2009
30,706
In my days working with DEC and DG there were two loaders involved in the bootstrap process.

The bootstrap loader on the DG Nova 2 computer was a short program of 13 instructions that were entered manually into the computer's non-volatile magnetic core memory via front console toggle switches. When executed, this program reads a much larger program called the binary loader which allows the user to then load the application program.
 

ErnieM

Joined Apr 24, 2011
8,377
Generally the boot loaded reads binary or information from something (SD card, serial line, Wi-Fi stream) and stores it so it can be executed after the load and subsequent restarts. It requires some sort of trigger to begin. The one I once wrote tested a button and a memory location so you could cause a hard load with a reset or do it programmatically.

The huge advantage of a bootloader is you do not need any programmer to load code.

However, as the egg always proceeds the chicken, you still need a programmer to load the boot loaded itself.
 

Thread Starter

omac24

Joined Jun 22, 2021
2
@Dave Lowther , Actually i am working on Infineon TC 237 controller (Used in Automotive Embedded).
Where bootloader plays important role as it is the first code that will get execute when system power on and not only it checks the valid application is present or not but also it does some CRC checking to check application is valid or not.
So if anyone knows how bootloader works in case of these Automotive microcontroller then please let me know.
And thanks everyone for helping me by sending replies to my thread.
 

MrChips

Joined Oct 2, 2009
30,706
I would not call that the bootloader.
I would call that POST for Power On - Self Test.

The bootloader is embedded in the MCU's non-volatile memory and uses JTAG to load the user program or application.

POST is the user's application program which can perform any self validity tests that the OEM desires.
One of the first test for integrity that the POST performs is a program memory checksum.

The other function I would assume that an ECU has to perform is how to run the automobile in limp mode or fail safe mode.

http://www.rhinopower.org/Tech/limp.html
 

geekoftheweek

Joined Oct 6, 2013
1,201
Just out of curiosity I took at a peek at https://www.infineon.com/dgdl/Infin...N.pdf?fileId=5546d46269bda8df0169ca09bc6023f0.

Section 5 describes the boot process more or less. From what I can tell the BootROM section of memory is a set of routines in read only memory that are used to do the actual booting. You are stuck with that but...

It also looks like there are a few options when it comes to booting by either tying various pins to power or ground. Figure 8-21 (pg 466) seems to describe the possibilities. A couple options for reprogramming, and a couple for actual booting into program.

If I'm reading things correctly it is possible to skip certain parts of the boot process and just directly start executing code at A000 0020.

Good luck.
 
Last edited:
Top