Bootloader + Flashing App + Led blink example (opensource)

Since almost every Embedded project needs a bootloader and application for flashing firmware, I've decided to open-source my solution. The idea is to have a universal bootloader for all microcontrollers and a single flasher application. Another idea is to have a flashing application that can run on all operating systems.

This is where I open-sourced IMBootloaderIMFlahser together with the IMLedBlink example. 

Let shortly explain them.


Adapter functions

For anyone who wants to port this bootloader, it needs to do it through adapter functions. The source file of adapter functions is here: firmware_update_adapter.c

Magic key

IMBootlaoder is running at interrupt events from USB. In the beginning, it will check if firmware exists by checking the special part of flash and it will looking for the magic key. If the magic key exists bootloader will jump to the firmware. It is to keep booting time short as possible. If the magic key is not written bootloader will listen at USB for firmware. Once when firmware flashing is finished, the bootloader will write a magic key at its address.

Signature check

The bootloader has the capability to check the firmware signature before it starts to write firmware. This way it will prevent to wrong firmware to be written. Since this at this moment to enter bootloader is required to have functional firmware it is very important that not wrong or unfunctional firmware is written. 


It can work with GUI or as a console application. It is written in QT Creator so it could be built for any operating system. 

If running it from the console, this is an example of how to do it:

./imflasher flash "/IMProject/IMLedBlink/build/IMLedBlink_signed.bin"

If the console detects an application it will send a command for the application to go to the bootloader. Connect/reconnect USB will be necessary so IMFlasher can get new data for USB. 

Figure 1 - IMFlasher GUI


This simple example with linker scripts can show how a signature can be added to firmware with the linker script. It has code that shows how to delete the magic key from flash and reboot the microcontroller to enter into the bootloader. It also has a virtual serial port over USB, over IMFlasher can take information if it is connected to bootloader or application, and send information to enter the bootloader. 


Popular posts from this blog

AUTOSAR and CRC calculation

Flashing/debugging/running code at external memory in the memory-mapped mode

Debugging EK-TM4C123GXL with Visual Studio Code on Linux