In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the principle of equipment OTA air upgrade to you, the content is very detailed, interested friends can refer to, hope to be helpful to you.
1. Background
There is no perfect software, because of design defects and updated business requirements, the software is constantly upgrading and improving. How to replace the old running software with the new software is the focus of this paper, especially for electronic products, equipment air upgrade OTA, limited by hardware resources, we need to choose different programs for software upgrade.
two。 Air upgrade process
Online upgrade process, simplification is that the equipment runs the old software, obtains the new software package, and then performs special operations to cover the old software with the new software, and finally runs the new software. Picture according to the hardware resources and the overall framework of the system, choose different upgrade schemes, the scheme needs to be combined with reality to choose the best, the technical level is secondary.
3. The scheme of air upgrade
3.1. Whole package upgrade
Take the upgrade of STM8 single-chip microcomputer as an example, the running process of the minimum system of single-chip microcomputer is as follows: if you want to add the online upgrade function, you need to split the main application program, similar to two sets of programs running in the device, the standard name is bootload+app, in which bootload always remains the same, it receives new software packages and covers the app area.
Hardware limitation solution the single-chip microcomputer itself does not have the function of network connection, so it can only download the new software package from the remote server based on the plug-in network module, then transmit it to the single-chip microcomputer through the serial port to download the new software package by the plug-in host, and inform the single-chip microcomputer to enter the upgrade mode with small internal RAM, unable to copy operations or cache a large amount of data. A single piece of EEPROM is too small to save a complete new software package. You can only receive the new software in segments during Bootload and write it to flash immediately.
The overall plan is shown below:
Difficulties and risks
The single-chip microcomputer receives the upgrade request in the app and needs to restart and enter the bootload. For the equipment controlled by the single-chip computer, it is necessary to ensure that the network module does not lose power during the single-chip microcomputer restart, so it is necessary to immediately restore the power supply of the network module host when upgrading into the bootload, and hardware support is needed if necessary.
Single-chip microcomputer ram and rom are limited, so they can receive the new software package in segments and write it to flash directly, so it is necessary to ensure that the data packet will not be erroneous or omitted or retransmitted in the application layer protocol. At present, most of them use Ymodem protocol. The upgrade package needs to be converted into a bin file, and the single-chip microcomputer will receive it and write it to the starting address of app.
The whole process takes more than 10 seconds to write flash after receiving the MCU in segments. If the power is cut off, the app of the MCU software is in a damaged state, which requires the MCU to restart the timeout mechanism, start the upgrade again and actively require the network module to retransmit the new software package.
General PC software does not need to consider memory and storage space, but also uses the whole package upgrade, two files are saved at the same time. For example, the app.exe runtime downloads the new app_new.exe. After downloading the check, app.exe self-destructs and deletes itself, then renames the app_new.exe to app.exe and starts it.
3.2. Differential upgrade
The differential upgrade software framework is the same as the whole package upgrade, except that the new software package is provided in a different way.
The software of single-chip microcomputer generally does not exceed 50KB, and the software of complex microprocessors is generally large, but its RAM is also large, so it takes a long time and a waste of traffic to download complete new software packages, so based on the difference between the new and old versions of software, the difference files can be transmitted to the device, and the new software package can be upgraded by the device operation.
Difficulties and risks
The making of the differential package and the verification of the restoration algorithm, taking into account RAM when restoring the new software package by bootload, the differential package is generated by block, and the restore is also performed by block. Before each new software is written, it is necessary to back up the old block to prevent abnormal power outage from being restored. In case of an exception in the image, restart or enter bootlaod, query which block has been restored last time, and continue the later operation. In order to reduce the size of the differential package again, some will compress the file and decompress it before restoring.
When upgrading, you must ensure that the generated differential package is based on the version running in the current device, such as the device running V01, but the differential package provided is based on V02 to V03, which will cause an exception. Or the special version characters are preset in the file, and the version matching is used to upgrade the differential restore. The whole package does not have this disadvantage, as long as the bootlaod is normal, any app software version can upgrade each other.
3.3. Dynamic loading
Dynamic loading is very common in PC software, multiple exe executable files share dll library files, so the exe file is very small, the disadvantage is that to ensure the normal operation of exe, it is necessary to store dll files under the specified path. For the embedded platform, dynamic loading can be understood as keeping the underlying infrastructure unchanged, modifying or replacing different upper-level business logic to achieve different effects. In order to ensure the call relationship between the bottom layer and the upper layer, it is necessary to fix part of the interface address, that is, the interface mapping between the two, mainly through links. Picture embedded software from the source code to the image file that can be downloaded to the device, need to go through the steps: picture dynamic loading is in the link stage, the upper code obj is compiled into axf dynamically loadable files, instead of directly merging with other obj into executable files. The main thing is to use armlink configuration-entry to specify the initial entry point of the image file or to use the # pragma arm section code keyword in the code to ensure that the dynamic upper layer has a fixed entry address. For all the underlying interfaces called by the upper layer, the function body pointer is assigned a null instruction in the compilation phase to ensure compilation, and then points to the real address of the underlying layer. Picture
Its effect occurs in the system startup phase, loading from flash to memory, the interface in the whole file remains the same relative to the address, the overall offset. In this way, the software can still calculate the entry address to get the dynamic image file. Load into the memory area, you need to make sure that the area will not be occupied, otherwise the memory coverage will definitely cause an exception.
After the bottom layer starts, only the entry function of the dynamic loading file can be found, but in fact, there must be more than one interface between the bottom layer and the upper layer, and the upper layer will inevitably call the bottom interface. This requires the upper and lower layer address mapping in the first function with a clear address. There are two schemes, one is function pointer assignment, the other is string lookup. The bottom layer needs to call the interface to the upper layer, and the bottom layer maps the interface function pointer table and assigns values to the upper function pointer in a fixed order, or the bottom layer only provides one function in the upper layer, but look up the string in the function body to get the function pointer. In this way, the upper layer calls the underlying interface that is fixed in advance.
The interface provided by the upper layer to the bottom layer, which is also a fixed function pointer in advance, is also docked with the above method. The core of interface mapping is that the address of a function in the dynamic load block is specified when it is linked, and the function mapping between the upper and lower levels is realized in this function. In addition to functions, global variables are also passed using pointers.
Difficulties and risks
The first two schemes using bootload+app are relatively conventional, whose essence is that one chip runs two sets of software that do not interfere with each other, while the dynamically loaded upper and lower layers have a fixed interface, so the interaction outside the interface can not be used.
Dynamic loading has high requirements for links and arm, and few applications in the upgrade direction, because there are restrictions on the use of software development interfaces, but dynamic loading realizes the isolation between the upper and lower layers, avoids confusion in code calls, and provides a basis for cross-platform and multi-language development.
4. Conclusion
Online upgrade is to solve after-sales problems at a lower cost without recall; upgrade is to solve the problem, but failure may cause the equipment to become bricks. Pre-test should choose different devices to simulate upgrade anomalies, such as forced power outages or abnormal software packages, the equipment must have a self-recovery mechanism.
On the equipment OTA air upgrade principle is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.