Update Firmware in the Field Using a Microcontroller’s DFU Mode
By Jacob Beningo
Contributed By Digi-Key's North American Editors
2018-01-24
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 a bootloader from a third-party component supplier.
There is an easier route. This article will show how to use the device firmware updates (DFU) feature that is built into many microcontrollers, but yet is often overlooked.
Firmware update options
Developing a bootloader from scratch is not a trivial endeavor. Developers need to 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, since 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 require 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 through 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.....