How to update firmware in the field using a microcontroller’s DFU mode
06 June 2018
Nearly every embedded system needs the ability to have its firmware updated in the field to add new features or fix bugs. However, firmware field updates can be challenging as a developer must either program their own bootloader or procure one from a third-party component supplier. There is an easier route: this piece explains how to use the device firmware update (DFU) feature that is built into many microcontrollers – but is often overlooked.
Developing a bootloader from scratch is no trivial endeavor. Developers must parse out their flash space so that multiple applications can co-exist. They then need to develop some way to transfer their compiled binary onto the microcontroller without the use of a programming tool.
This requires them to either develop their communication protocol or increase their system complexity by adding external memory to store new images. They can also increase the amount of internal memory they have on their microcontroller. Also, the software itself can become complex, given that the bootloader will need to set the system state and determine whether it is safe to jump to the application code or not.
Using a custom bootloader can provide developers with much needed flexibility for their applications, but there is a firmware update standard that can work in many applications that requires no work from a developer: the USB standard’s built-in device firmware update (DFU) class. This can be used to update a microcontroller’s application code in the field via its USB port, which can dramatically decrease the firmware update process and development cycle.
DFU has become so pervasive that some microcontroller vendors such as STMicroelectronics even include the software necessary to perform the updates hardcoded into their ROM. Those that don’t often provide example code on how to support DFU.
Selecting a DFU-capable microcontroller
The easiest way to support DFU is to select a microcontroller that already has DFU included in its ROM, such as STMicroelectronics’ STM32 microcontrollers. Among these, the devices that are particularly interesting for a developer to experiment with are the STM32 IoT Discovery Node or the STM32F429 Discovery Kit.
The STM32 IoT Discovery Node is a low-cost development board designed for use as an IoT sensor node, and includes several different interfaces for connectivity (such as Wi-Fi and Bluetooth). What’s interesting is that the onboard STM32L475 provides developers with the ability to test and use DFU capabilities on a device designed to connect to the internet.
For developers who just want to test DFU on a standalone device, the STM32F429 Discovery Kit is a well-known, low-cost development kit for the STM32F4 series of microcontrollers. Let’s discuss how a developer would go about testing DFU on these microcontrollers…
Please note that this article is a sample: for more info, click on the original Digi-Key piece here, or visit EPDT's online ActiveMag version of the piece.
Contact Details and Archive...