Terminal equipment online upgrade

Currently, electronic devices based on mobile networks require internal software to support online upgrades. The principle is to use new software to cover old software, but different hardware resources have different final implementation schemes.

Simple 8-bit single-chip microcomputers such as STM8, without operating system, are actually developing two sets of codes BL and APP. After the MCU is connected to the network module, after downloading the new software of the MCU through the mobile network, it informs the APP to request an upgrade, and the MCU restarts and enters the BL. BL receives the new APP bin file through UART or other interfaces, and directly overwrites the area written in the original APP, and then jumps to the APP for execution after completion. Because of code space limitations, the upgrade is to replace the complete APP software and there is no backup, so be sure to use the power-down storage area to make a mark. In case of abnormality, you need to automatically enter the BL to send information to the outside world to request the APP software again.

Complicated ARM system such as MTK mobile phone chip, with file system and network function, enough computing capacity, you can download the new APP software through the network to save the file area, and then restart to enter the BL to write new software to Flash, failing to rewrite.

This kind of upgrade method of downloading complete APP software to cover, downloading wastes traffic and takes a long time, and has a worse experience for a large number of GSM/GPRS or NB-Iot-based IoT products, so the best choice is to upgrade DFOTA differentially.

Run the software V01 in the device and expect to upgrade to V02. You can extract the difference part of V01 into V02 and generate the difference file D3, which is the difference package. The device receives D3, restores V02 based on its own V01 calculation, and then writes V02 to complete the upgrade.

The algorithm involved in the differential upgrade is open source, but for safety, some special marks are usually added to the head and tail of the D3 file for verification. If the D3 file is received incomplete, it will be discarded and V01 will continue to run.

The upgrade is to solve the problem, but once it fails, it may cause the device to become bricked. In the preliminary test, try to choose different devices to simulate the upgrade abnormality, such as forced power off or abnormal software package, the device must have a self-recovery mechanism.

For more development skills, please follow the WeChat public accountInsert picture description here

Guess you like

Origin blog.csdn.net/chengjunchengjun/article/details/108733566