Why does the microcontroller need both a bootloader and ISP?

Greetings everyone,

I hope that the category is adecuate for the question.
This question is just out of curiosity and to understand better the function of ISP in microcontrollers.

I'm an electronics engineering student and I'm doing a thesis where I implement a bootloader on a custom CPU written in VHDL. The focus of the whole thing is to understand bootloaders and to create several versions that, for example, accept .hex or binary files formats as input.

I also need to create a ""software"" bootloader, which is placed in the memory of the CPU and does it's work when the CPU is turn on, and a ""hardware"" bootloader, which does exactly the same as the other one but it's implemented in the CPU architecture (Not placed in the memory of the computer but rather as another module in the system). As of the part of investigating the functionality of other microcontrollers, I realised that microcontrollers, AVR included, have both a bootloader and ISP, which, as I understand, allows to reprogram the bootloader into the memory.

The thing is, why are there ""2"" bootloaders? Shouldn't it be enough with 1 ""hardware""/ ""software"" bootloader that takes the information from the UART or wathever input and writtes it into the memory? The only reason that I could think of was that having the bootloader implemented that way wouldn't allow for bug solving or updating the bootloader in case that is needed.

I greatly appreciate proper explanations, thank you in advance.

Welcome to the forum

Take the Arduino Uno as an example. Most users what to plug it into a USB socket and program it using the IDE. Bear in mind that is the sort of market that it is primarily aimed at.

However, how would you get the software bootloader onto the chip without a method to load it such as ICSP ?

Some users want more memory so don't want to have a software bootloader taking up space. They can use ICSP to load code directly and not have a software bootloader if it suits them. However, if this were the only way of uploading code it would seem unnecessarily complicated to the target users who just want plug and play functionality

1 Like

You could make a UNO like board where you replace the onboard USB<>Serial adapter with a onboard ICSP programmer (e.g. USBASP). You would have a board that needs no bootloader and can be plugged in the USB and be programmed.

However, you could not use the serial monitor via the same connection. You would need another USB<>Serial adapter to do so.

I consider the elegance of the bootloader that it enables you to both program and print via the same onboard USB<>Serial adapter, that connects your PC to the UART

Not true.
Some microcontrollers have neither.
Most modern flash based microcontrollers have some form of In Circuit Serial Programming (ICSP) capability but very very rarely have a bootloader.

AVR can be programmed via several ways. The default way for the raw chip is ISP and parallel which is more complicated way in compare with ISP. There is no bootloader in the raw chip. The bootloader must be created and uploaded first, usually via ISP and it is only user's choice. The bootloader uses serial line which is the most comfortable programming way for AVR but the cost is a part of the flash memory dedicated for the bootloader.

For an AVR, ISP programming is akin to your project’s “hardware bootloader” - it’s built into the chip hardware and does not consume memory. The Arduino bootloader is a “software bootloader.”

Hope, the following diagram (Fig-1) will answer to your queries:


Figure-1:

A: Boot Loader Programming Interface
1. "Boot Loader" is a piece of software (developed by Arduino Dev Team) which is pre-installed into the indicated portion of the Flash Memory of ATmega328P MCU.

2. The Boot Loader Program receives the ASCII coded Intel-Hex formatted frame (s) for the binary codes of the application (sketch) from the Arduino IDE of the PC over the Serial/UART Port, extracts the binary codes and stores them into the indicated application Flash using SPM instruction.

B: In System Serial Programming Interface (ISP)
Given the SPIEN fuse bit is programmed, this hardware interface (it is essentially the SPI Port of the MCU) receives the sketch via Arduino UNO from Arduino IDE of the PC and stores them into the application Flash. This method is known as Low Voltage Programming as it uses 5V Programming pulse.

C: Parallel Programming Interface
This is a piece of hardware tat receives sketch from the PC (no need of Arduin IDE) via an expensive commercial Universal ROM Programmer and stores them into the application Flash. Tis programming approcah helps to perform fuse/lock bits of the MCU. This method is known as High Voltage Programming as it uses 12V Programming pulse (it has some advantages over the Low Voltage Programming).

The answer is there is no technical NEED for more than one way to program the part with respect to getting firmware in the device.
The technical need to get firmware in the device is simply have a way to update firmware inside the target processor.
As long as you have a way to do that there is no technical need for another.
Note that I said "technical need to get firmware in the device" there can be other wants or even needs that trump this such as ease of use, minimizing h/w devices, or manufacturing requirements.
In the very early days of Arduino or even pre-Arduino, there was no bootloader.
The chips were programmed using the ISP capability built into the AVR chip.

That said, the h/w interface used for in circuit programming is often a manufacturing requirement for the chip maker as they can use it to test the chip on the assembly line to verify that it is fully functional.
This same circuitry also allows factory programming of parts, which is very useful
for manufacturers using the part in their designs directly on their assembly line.
Also, this same in circuit circuitry often has support for s/w debugging.
In chips that have a Harvard Architecture where the firmware lives and runs in flash, there is no way to do breakpoints for s/w debugging without some kind of h/w assist.
So for all these reasons, a h/w interface for testing, firmware loading, and s/w debugging tends to be a requirement.

A serial based software bootloader can be a nice to have or even a requirement for other reasons.

Having been involved with manufacturing products in the past (millions of units), that included custom silicon that used custom ARM based chips, granted that was 25 years ago, but still I'm not seeing the value or need for a putting h/w support inside a chip for a bootloader that uses some kind of serial protocol.
I'd just stick with lower level h/w interfaces.
i.e. keep things simple and minimize any potential issues to avoid cost and time overruns.

As far as bootloaders go on the older AVR based devices,
IMO,
At this point there is no longer a need for a bootloader on older AVR based devices such as the UNO and the MEGA boards.
The AVR could always be programmed using ICSP.
An no, this would not require the user have any additional h/w nor would it changing the current user experience of being able to use a USB interface and do everything from the IDE GUI.

For quite some time the onboard FTDI USB to serial chip was replaced with an AVR 16MEGA16U2 chip.
The s/w in this chip could be tweaked to provide not only a virtual serial port but also emulate an ISP programmer such as USBASP or USB Tiny.
There would also need to be a small tweak to the board layout to add the appropriate connections between the 16MEGA16U2 to the ATMEGA part to allow the 16MEGA16U2 to use ISP programming to program the main AVR chip.

This could eliminate the need for a bootloader and its associated resources in the main AVR chip.
It would also allow working with blank chips in the case of replacing a burned up chip all without the user needed to ever use an actual ISP programmer.
It would still allow using the serial port and even a bootloader, but a boot loader would no longer be needed as the 16MEGA16U2 could ISP program the main AVR.

I have contemplated taking on the 16MEGA16U2 s/w part of the project for quite a few years but never got around to it.

--- bill

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.