Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now
102

A bootloader is a program that runs in the microcontroller to be programmed. It receives new program information externally via some communication means and writes that information to the program memory of the processor. This is in contrast with the normal way of getting the program into the microcontroller, which is via special hardware built into the ...


55

A bootloader on a microcontroller is responsible for updating the main firmware over a communication channel other than the programming header. This is useful for updating firmware in the field over BLE, UART, I2C, SD cards, USB, etc. It would be extremely inconvenient to require customers to purchase programmers just to update the firmware on their ...


26

So that the loading process can recover from errors. Suppose there is a communication error or power disconnects during an upgrade. If the boot loader were part of the application you were upgrading then the user wouldn't be able to try again without using special hardware to reflash to boot loader. Some microcontrollers can't execute code from RAM. If the ...


22

What is the concept of the bootloader? Picture this scenario: You have a fair amount of storage on your microcontroller - enough to store more than 2-3 programs or applications that are independent of each other. Suppose that when you boot your device, you may want to be able to choose which one to run. So what would you need to support this? You would ...


20

Generally speaking the factory reset function you mention will restore any saved variable data information back to default values. It is not true that all embedded devices have this capability. Some do but not all. If you want your device to support a return to factory default firmware itself then your design has to incorporate a memory into the circuit to ...


17

The main purpose of a bootloader is to allow updating the firmware through interfaces other than the default hardware interface. For example, this allows updates via communication channels that the application uses otherwise for its own purposes, which means that you can do remote in-system updates without requiring physical intervention at the remote site. ...


15

Before you can start executing code from external RAM, you have to first initialize FSMC and copy your code into that RAM, so you have to boot from flash anyway. A properly written linker script (with an additional code section linked at the correct address but placed in flash, like the .data section) will help greatly. You'll be able to mark functions you ...


14

You only need to put the microcontroller into bootloader mode if you're going to program it over the UART, using the bootloader. Generally speaking, you can program the microcontroller over SWD at any time. The primary exceptions are if the microcontroller is running a program that disables SWD by setting a SWJ_CFG bit in AFIO->MAPR (e.g, to use the ...


11

If you take the most common example of factory defaults, it's your PC's UEFI (BIOS). It is made with a flash chip and a volatile battery backup SRAM memory chip. The flash chip contains the program, and the SRAM contains the settings. On factory reset, the contents of the volatile sram are erased. On the next boot, it detects that the checksum of the ...


11

They're generally there to allow you to update your main application program. You need some code which knows how to erase and reprogram some of the internal flash, that can't be the main program as when it's erased itself it wouldn't be able to reprogram.


10

The basic answer is that some people don't want to buy or make a programmer. They just need a serial port to program the IC using a bootloader. It's cheaper. Or sometime you want to be able to upgrade your code on the field without using your expensive programmer. Then a bootloader is fine. But if you think about the usage of your system and don't find a ...


10

The bootloader lets you reprogram the PIC from the USB port, taking advantage of the ability of the controller to write into its own program memory. Usually, it checks to see if some criteria is met, like some bit being set high, before entering the programming mode. It will shift your program into higher memory space to accommodate the boot loading ...


10

I suspect you have set the controller's fuses to use an external clock source as it is impossible to get the internal oscillator to run at 20MHz. You can blow new life into your controller by connecting a clock signal to pin 2 CLKI and try to reset the clock to 8MHz internal RC clock. There is actually a 'fixed' version of ArduinoISP that has a clock output ...


10

No, you don't need to, in fact you can't, use SPI, UART, or I2C to program the PIC. The only way to get a new program into a PIC that doesn't have special code loaded for that purpose (a bootloader) is to use the external hardware programming interface. Electrically, this means connecting to Vss, MCLR, PGC, and PGD. It can be useful to have the programmer ...


10

A microcontroller, just like any other CPU, starts executing code from a fixed address. That address is often known as the "reset vector". The address will be in the datasheet for the microcontroller. Even on a PC it works like that. The "booting" off a hard drive is about number 10347 in its list of things to do when it starts - the first is to execute ...


10

Factory reset is whatever you want it to be. It depends on the application and device type. I usually do two things: Ensure that there is always a reliable way to enter the bootloader, so that even a partial/wrong firmware update can't brick the device. Have a way to reset the firmware settings in case the user changes something, a particular setting ...


9

There is an actively developed free and open-source Arduino bootloader / firmware called OptiBoot, that might be of interest. From their site: Optiboot is a quarter of the size of the default bootloader, freeing 1.5k of extra space. Many Arduino / clone boards now ship with OptiBoot instead of the classic Arduino firmware, though not necessarily with the ...


9

There are some scenarios where a boot loader doesn't add much value. You are right if you have a couple of boards you can certainly attach the programmer and flash the code again. If you are a hobbyist with a couple of boards or you have even a small production you can do it this way. The bootloaders have more sense in scenarios where physically connecting ...


9

The bootloader allows the MCU to communicate with something else to accept a new program, store it, and run it after a reset. If you didn't have a bootloader, then a Programmer is needed to access the memory and put the program in place.


8

A bootloader is no different from a normal program. You will need to think of the following things first: What do I want my bootloader to do? Since it usually takes care of upgrading software, where do I get the new application image from? Do I want to be able to communicate with the bootloader via UART/USB/? How do I make sure that a valid program is ...


7

A quick search led me to this Microchip forum discussion where the solution appears to be specifying --CODEOFFSET as one of the linker arguments. The forum also has a link to a webinar on the same topic. Command line: You can pass the offset when compiling with the command line by passing --codeoffset=<location> during linking (i.e. --codeoffset=...


7

This might seem a bit glib, but if you find yourself not needing the Arduino bootloader (because you do not need to reflash your AtmegaXXX over a serial link in-circuit) then you don't need a bootloader. That is all a bootloader does for you. Generally I've found that keeping the Arduino bootloader on my Atmega microcontrollers makes them more flexible ...


7

Have you considered creating a simple kernel module you can insert to make the MTD partition(s) writable? I had this same problem and was able to work around it by writing a kernel module. For simplicity, I just went ahead and had it make every MTD device writable. Basically, the module has to do something like this in its init function: struct mtd_info *...


7

The processor on the BeagleBone is not a microcontroller, but rather a microprocessor (the Sitara AM3359 from Texas Instruments), which doesn't have non-volatile memory on the processor itself, but rather tries to load programs (such as an OS) into RAM via a communications interface (UART, USB, Ethernet) or from an external memory (FLash or memory card). The ...


7

There may be some confusion around the term "bootloader", which is used very differently in the context of embedded systems vs. "desktop" systems. First of all, the code that any processor executes following a reset must already be in memory, at a particular fixed address that's determined by the specific processor being used. In an embedded system, this ...


7

At last I've found what was missing. VDDA should be connected! e.g. to VDD. I believe if device has VSSA also, it also should be connected. Otherwise the chip is in reset mode "thanks" to functionality which monitors both VDD and VDDA and simply does not allow chip to start. So minimal connection is like this: 3.3 Volts to VDD, VDDA, BOOT0 GND to VSS (...


7

In addition to the other correct answers about allowing reprogramming of the main firmware from the bootloader, another benefit of having the bootloader be separate is that you can logically separate the "do once on boot" tasks from the code you need during runtime. Then, after the bootloader finishes its initial configuration tasks, the main firmware can ...


6

For an overview of the bootloader take a look at the Bootloader Development page. The actual source code is available and can be browsed here. To modify the wait time (or the behaviour of the waiting) take a look at the ATmegaBOOT.c file. In line 91 is MAX_ERROR_COUNT defined and used to determine when to start the actual application on your arduino. To ...


6

Regarding you comment question "If i design everything using 3.3v i guess worst case i can just put in a 8MHz crystal and it should be fine?". Look at the speed grades in the datasheet where maximum frequency vs voltage is given. Since the curve is linear between 2.7V and 4.5V you can calculate the maximum speed @3.3V as follows: fmax@3.3V = (3.3V / 2.7V) *...


Only top voted, non community-wiki answers of a minimum length are eligible