Bootloader - What can I do with it and how?

Hi again,
my previous post has brought up another question which I hope someone can answer in short. A link would be fine as well, of course.

I would love to know what a bootloader is generally useful for and how that is basically done. Everywhere I looked on the net the information is obviously a bit above what I can understand or beyond what I want to know.

So my first question would be:
In what cases is it necessary or better to use a boot loader compared to ISP, i.e. what advantages are there?

One answer I already know is that ISP is not possible with the RESET pin being disabled (see previous topic).

Second: How is this basically done? (How to connect the AVR, where to, which software to use, …).

Third: Any disadvantages?

Thanks a lot for your time!!

Best,
Robert

Hello.

  1. The main advantage of a bootloader is that it lets you program the chip without an ISP programmer, which can potentially save you money and make the device easier to use. For example, Arduinos are controller boards that are programmed via a bootloader on each ATmega168.

  2. How it works really depends on how the bootloader is implemented. The bootloader is programmed to interpret input and then write data to the rest of the flash based on that input. The bootloaders I’ve seen typically respond to serial data sent to the MCU’s UART module. For example, you send them the content of a standard hex file over serial, and they parse the input and write the appropriate bytes to the appropriate flash memory locations. For something like this, you’d most likely want a USB-to-TTL-serial adapter connecting your AVR to your computer via its hardware serial pins, and you could talk to it using a piece of custom-written software or even just a simple terminal program.

  3. There are a few disadvantages:

  • You lose program space to the bootloader, so the space available for your own programs is smaller.
  • Not all AVRs support bootloaders.
  • A bootloader cannot modify the fuse bits or lock bits. This can be a plus if you’re worried that the user might accidentally break the microcontroller if they’re allowed to modify the fuses.
  • You need a way to tell the MCU when it’s time to enter the bootloader and wait for a new program to be transmitted. Typically the AVR will be configured to start execution in the bootloader on reset, so you just need a way of providing some specific input that tells execution to stay in the bootloader rather than jumping to the main program. Doing this might require the use of an I/O pin or an extra delay on reset and start-up.

- Ben

Hi Ben,

thanks again for your quick response. That definitely helped me a lot!

Best,
Robert