Go Down

Topic: what is a bootloader? (Read 441 times) previous topic - next topic

nanohex

My question is what exactly is a bootloader? From my understanding, it is some sort of program that lets you program your MCU with a serial connection, is that right? What are the advantages of a bootloader and how does one go about writing one? I know in Arduino it's as simple as clicking the "burn bootloader" button but I'm wondering what actually goes on, so I can implement it in other AVR programs (for example, when using chips that aren't supported by Arduino, or maybe if I decide to experiment with other microcontroller families).

Thanks!  :)

Osgeld

you are correct

when you write one to the arduino what happens is that it loads up as a normal program at the beginning of program memory, then a couple fuses are set to "lock" the first X bytes so when you upload another program though it, it will not get overwritten.

nanohex

Oh, so that's what stops it from being overwritten! What does it actually do though?

AWOL

Quote
Oh, so that's what stops it from being overwritten! What does it actually do though?

The bootloader occupies a section of memory protected from being overwritten by the controller's hardware, i.e. the bootloader cannot overwrite itself, but an external programmer can.
Program code running in the rest of memory cannot overwrite either itself or the bootloader.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

nanohex

I was wondering about that. If I were to compile a program for the atmega328 with AVR-GCC, then upload it to the board using WINAVR and an   ISP, would the bootloader be erased then?

holmes4

A bootloader or bootstrap program is a short simple program which is run by a computer on startup (the one for a PC is called the BIOS).

The arduino bootload runs when the chip is restart it waits to see if a new program is being send from the PC, if so it loads it and starts it running, if not it gives control to the last program loaded.

Mark

pranjalchaubey


I was wondering about that. If I were to compile a program for the atmega328 with AVR-GCC, then upload it to the board using WINAVR and an   ISP, would the bootloader be erased then?

Hi, I have a similar question but with a bit of a twist.
If I have an arduino (bootloader) loaded atmega328 and I write a program in the AVR-GCC...now is it possible to burn the code in the chip using the arduino bootloader? I mean, without using the arduino IDE and without using an ISP.....if I set the programmer as avrdude in the makefile then is it possible?

Nick Gammon

Yes, because the IDE uses avrdude to do exactly that. It uploads a .hex file using the bootloader, if requested.

pranjalchaubey


Yes, because the IDE uses avrdude to do exactly that. It uploads a .hex file using the bootloader, if requested.

Thanks Nick!  :)

I have one more query, does the arduino bootloader for ATmega168 will work for ATmega16 without any changes?
If it won't, can you give me a hint as to what things need to be changed?

Nick Gammon

I'm not sure. The signature would be different. If it is running at 16 MHz it may not need much or any change to the actual bootloader.

Go Up