Bootloader and Firmware

1.5. Bootloader and Firmware#

When a microcontroller boots (starts) it runs special software called the bootloader. Its job is to:

  • check that the BOOT pin is set and if so, accept new firmware

  • otherwise load the existing firmware from the microcontroller’s non-volatile memory

The firmware is the code written by the software engineer to run on the microcontroller. It is called firmware to distinguish from software because it doesn’t change as frequently as software - usually once the code for a device is developer it doesn’t change. However re-programming microcontrollers has become easier over time with microcontrollers that support USB or Wi-Fi and the difference between firmware and software is disappearing.

The bootloader is stored in a write protected area of memory so that your firmware can’t overwrite it.

../../_images/firmware_bootloader_hardware.png

1.5.1. Firmware and Interpreted Languages#

Historically the code that ran on microcontrollers was written in compiled languages such as C and C++. Compiled languages offer several advantages such as lower memory requirements and speed compared to interpreted languages, which was critical on early and resource constrained microcontrollers.

However compiled languages can slow development and microcontrollers now have sufficient computational power and memory to support interpreted languages such as Python.

To run an interpreted language requires an additional layer in the bootloader and firmware stack. The firmware becomes the interpreter for the language and then the code written by the software engineer is just the software.

../../_images/bootloader_firmware_application.png