Pages: [1]   Go Down
Author Topic: What does the bootloader do?  (Read 1979 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Thank you.
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 33
Posts: 1226
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: October 02, 2010, 05:06:15 am by 3dprinter » Logged

0
Offline Offline
God Member
*****
Karma: 1
Posts: 513
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 33
Posts: 1226
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

DCB: Defenitly a much shorter version of explaining it!  smiley  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  smiley-wink
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8602
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
« Last Edit: October 02, 2010, 05:26:27 am by graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Pages: [1]   Go Up
Jump to: