What does the bootloader do?

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

Thank you.

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 :confused:

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 :/

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.