Go Down

Topic: What does the bootloader do? (Read 6158 times) previous topic - next topic


Hi guys!
Sooo... What does the bootloader do? Can you explain it as simple as you can?

Thank you.


Oct 02, 2010, 11:57 am Last Edit: Oct 02, 2010, 12:06 pm by 3dprinter Reason: 1
Although I have not examined the code of the Arduino bootloader, I presume it works like all other bootloaders I have met.

The reason for a bootloader is that when you power up, either a pc or an Arduino, the RAM contains gibberish. So the reset pulse forces the "computer" to start executing at a fixed address. This fixed address points to some non-volitile memory. This is the "Bootloader".

It examines the state of the RX/TX pins for a second or so, and tries to communicate with the pc. If this fails, either because nothing is connected, or the communication is gibberish then the Bootloader will transfer execution control to the start address of the (previously) loaded program.

If the communication is good, then the bootloader assumes that we are receiving a new program from the pc. This is placed in a memory area, not occupied by the bootloader. The transfer of a program includes some checksums to avoid errors.

When the bootloader has finished transfering the new program, the Bootloader will transfer execution control to the program, like before.

Thus, should you loose your bootloader, then you are unable to program it, or maybe even not start the program you have loaded.

There are two layers of Bootloader, if we are more accurate. One that is hardwired into the very chip construction. This is much simpler in the protocol to receive the program (possibly uses differnet pins) and was used to get the fancy Arduino bootloader into the memory. On your chip it simply transfers execution control to the more sophisticated Arduino boot loader.

When you have written your Arduino program, it gets merged with the "core" (or Operating system of the Arduino, to give it a fancy name). It will receive the execution control when the Bootloader has finished. It will initialise the SRAM/volitile memory, do some behind the scenes stuff with the timers (which makes the millis() function and PWM stuff work) and then call your setup() and your loop() function. But that is not part of bootloader.

The truth is "complicated", I hope you found this a simple enough version of it.

More info at http://en.wikipedia.org/wiki/Booting#Boot_loader


the bootloader is an optional program that runs when the chip first powers up/resets and looks to see if someone is trying to load a new version of the main program.  If so it loads the new program and runs it, if not it runs the existing program.


Wow... I took a look at it now - it seems sooo complicated :/


DCB: Defenitly a much shorter version of explaining it!  :)  I disagree about it being "optional". Maybe the Arduino bootloader can be, but then it isnt an Arduino anymore, but an Atmel  microcontroller, so to speak  ;)


I dont just get one thing. I soldered my own microcontroller few months ago, it worked without a boot loader :/


Oct 02, 2010, 12:25 pm Last Edit: Oct 02, 2010, 12:26 pm by graynomad Reason: 1
it worked without a boot loader

Then you must have programmed it using ISP/JTAG etc. The bootloader removes the need for special hardware and is therefore more beginner friendly.
Rob Gray aka the GRAYnomad www.robgray.com

Go Up