How to implement Bluetooth Low Energy OTA? What is DFU? How to achieve firmware upgrade via UART? How to achieve firmware upgrade through USB? How to ensure the security of the upgrade? What is a dual bank DFU? What is a single bank DFU? What is Backstage DFU? This article will discuss the above issues.
The so-called DFU (Device Firmware Update) means device firmware upgrade, and OTA (Over The Air) is just a way to implement DFU. To be precise, the full name of OTA should be OTA DFU, that is, the device firmware is implemented wirelessly over the air. upgrade. It’s just that for the sake of convenience, we directly use OTA to refer to firmware over-the-air upgrades (sometimes we also call OTA FOTA, that is, Firmware OTA, which means more clearly). As long as DFU is realized through wireless communication, it can be called OTA, such as 2G/3G/4G/WiFi/Bluetooth/NFC/ZigBee, they all support OTA. DFU can be upgraded not only through wireless (OTA), but also through wired methods, such as upgrading device firmware through UART, USB or SPI communication interface.
Whether OTA mode or wired communication mode is adopted, DFU includes two modes: background mode and non background mode. Background DFU, also known as silent DFU, quietly downloads new firmware in the background during the upgrade, that is, the download of new firmware is part of the application function. During the download of new firmware, the application can be used normally, that is, the whole download process is insensitive to the user. After the download is completed, the system jumps to the BootLoader mode, and the BootLoader completes the operation of new firmware covering the old firmware, So far, the whole upgrade process is over. For example, when upgrading Android or IOS systems for smart phones, the back desk DFU mode is adopted. During the download process of the new system, the mobile phone can be used normally. When upgrading a non desktop DFU, the system needs to jump from the application mode to the BootLoader mode first, and the BootLoader will download the new firmware. After the download is completed, the BootLoader will continue to complete the operation of covering the old firmware with the new firmware, and the upgrade is over. The previous functional computers used non desktop DFU to upgrade the operating system . That is, users need to press and hold some keys to enter the BootLoader mode, and then upgrade. The normal functions of the mobile phone cannot be used during the whole upgrade process.
Let’s talk about dual bank DFU and single bank DFU . Dual bank or single bank DFU are two ways to cover new firmware and old firmware. The background DFU must be upgraded in dual bank mode, that is, the old system (old firmware) and the new system (new firmware) each occupy a bank (storage area), assuming that the old firmware is placed in bank0, and the new firmware is placed in bank1. When the new firmware is downloaded to bank1, the system will jump into BootLoader mode only when the new firmware is downloaded and verified successfully, and then erase the bank0 area where the old firmware is located, and copy the new firmware to in bank0. The non-background DFU can use dual bank or single bank mode. Similar to the background DFU, the new and old firmware each occupies a bank in dual bank mode (the old firmware is bank0, and the new firmware is bank1). When upgrading, the system jumps first. Enter the BootLoader mode, and then the BootLoader program downloads the new firmware to bank1. Only after the new firmware is downloaded and verified successfully, the bank0 area where the old firmware is located will be erased, and the new firmware will be copied to the bank0 area. The non-background DFU in single bank mode has only one bank0. The old firmware and the new firmware share this bank0. When upgrading, enter the BootLoader mode and immediately erase the old firmware, and then directly download the new firmware to the same bank. The download is complete After verifying the validity of the new firmware, the new firmware is effectively upgraded, otherwise it is required to restart. Compared with the non-background DFU dual bank mode, the single bank mode saves a bank of Flash space. When the system resources are relatively tight, the single bank mode is a good choice. Regardless of whether it is a dual bank mode or a single bank mode, after a problem occurs in the upgrade process, a second upgrade can be performed, and there will be no “bricking” situation. However, the dual bank mode has an advantage. If there is a problem during the upgrade process or the new firmware has a problem, it can also choose the previous old firmware and the old system to continue to execute without being affected by it. In single bank mode, when this happens, you can only stay in the BootLoader and wait for two or more upgrade attempts. At this time, the normal functions of the device are no longer available. From the perspective of users, you can indeed say that at this point the device has been “bricked”. Therefore, although the dual bank mode sacrifices a lot of storage space, it brings a better upgrade experience.