WO2022094855A1 - Firmware upgrade method and electronic device - Google Patents

Firmware upgrade method and electronic device Download PDF

Info

Publication number
WO2022094855A1
WO2022094855A1 PCT/CN2020/126732 CN2020126732W WO2022094855A1 WO 2022094855 A1 WO2022094855 A1 WO 2022094855A1 CN 2020126732 W CN2020126732 W CN 2020126732W WO 2022094855 A1 WO2022094855 A1 WO 2022094855A1
Authority
WO
WIPO (PCT)
Prior art keywords
firmware
storage space
stored
boot program
verification
Prior art date
Application number
PCT/CN2020/126732
Other languages
French (fr)
Chinese (zh)
Inventor
周韦博
龚如
Original Assignee
深圳市大疆创新科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to PCT/CN2020/126732 priority Critical patent/WO2022094855A1/en
Publication of WO2022094855A1 publication Critical patent/WO2022094855A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Definitions

  • the present invention relates to the field of computer technology, and in particular, to a firmware upgrade method and an electronic device.
  • firmware programs capable of implementing various functions are stored in an electronic device to ensure that the electronic device can operate normally.
  • firmware program in the device needs to be upgraded for various reasons, such as: in order to overcome the loopholes in the original firmware, in order to enhance the compatibility of the device, in order to develop new functions of the device, and so on.
  • the firmware program is generally loaded and upgraded through a boot program (loader) in the device.
  • a boot program loader
  • the existing solution is to design some functions in the firmware into the boot program, which makes the boot program function complex and difficult to maintain.
  • the present application provides a firmware upgrade method and an electronic device, which are used to solve the problems in the prior art that the functions of the boot program are complex and difficult to maintain.
  • An embodiment of the present application provides a firmware upgrade method.
  • the method includes:
  • the boot program is made to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space to obtain upgraded firmware.
  • the electronic equipment includes:
  • the memory includes a second storage space and a first storage space;
  • a processor that performs the following actions:
  • the boot program is made to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space to obtain upgraded firmware.
  • the data acquisition stage that takes a long time and is prone to failure or interruption in the firmware upgrade process is set in the firmware to be upgraded, and the firmware stores the acquired firmware upgrade data in the second storage space, wherein the second storage space is different from the first storage space for storing the firmware.
  • the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process.
  • the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process.
  • the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process.
  • the firmware if the data acquisition stage fails or is interrupted, the program still remains in the firmware, and the firmware can still perform the corresponding functions normally to protect the normal operation of the device. That is, in the technical solutions
  • FIG. 1 is a schematic flowchart of a firmware upgrade method provided by an embodiment of the present application.
  • FIG. 2 is a schematic flowchart of a firmware upgrade method provided by another embodiment of the present application.
  • FIG. 3 is a structural block diagram of an electronic device provided by an embodiment of the present application.
  • an electronic device includes a boot program area for storing a boot program and an application program area for storing firmware.
  • the boot program is used to load and upgrade the firmware; the firmware is used to perform corresponding functions to ensure the normal operation of the electronic device.
  • the boot program is generally run first, and then the boot program is used to load the firmware program, thereby completing the realization of the firmware function.
  • the firmware upgrade needs to be performed in the bootloader.
  • the upgrade process is: the bootloader first erases the firmware in the application program area; then, the host computer divides the new version of the firmware into small packages and sends it, and the bootloader receives a package.
  • Write a package in the application area after all the writing is completed, the bootloader performs an integrity check on the new version of the firmware in the application program area, and jumps to the new version of the firmware if the verification is passed.
  • Some electronic devices still need to work during the firmware upgrade process, which requires the boot program itself to have certain functions to ensure the normal operation of the electronic devices.
  • the smart battery as an example, the drone or other smart devices still need to rely on the smart battery for power supply during the firmware upgrade process of the smart battery.
  • the boot program of the smart battery needs to have a complex circuit protection function to ensure the normal operation of the smart battery.
  • the boot program also needs to support the charging and discharging function to ensure the normal operation of the smart battery.
  • the embodiments of the present application provide a firmware upgrade method, in which the data acquisition stage in the firmware upgrade process is set in the firmware, so that the firmware can acquire firmware upgrade data and execute corresponding functions to ensure the device's normal operation. In this way, there is no need to design some functions of the firmware into the boot program, and the boot program has simple functions, low complexity, and low maintenance difficulty.
  • FIG. 1 shows a schematic flowchart of a firmware upgrade method provided by an embodiment of the present application. As shown in Figure 1, the method includes:
  • the firmware upgrade method provided by the embodiment of the present application can be used for upgrading the firmware of an electronic device.
  • the execution subject of the firmware upgrade method provided by the embodiment of the present application is an electronic device, and specifically a processor of the electronic device, for example, an MCU (Microcontroller Unit, micro control unit).
  • MCU Microcontroller Unit, micro control unit
  • the above-mentioned electronic devices may specifically be smart batteries, drones, automobiles, and the like.
  • the above firmware is stored and executed in the first storage space.
  • the firmware upgrade data is acquired through the firmware, and the firmware upgrade data is stored in the second storage space. That is, in the process of running the above-mentioned firmware in the first storage space, the firmware upgrade data is acquired by executing the preset acquisition instruction in the firmware; and by executing the preset storage instruction in the firmware, the acquired data is obtained.
  • the obtained firmware upgrade data is stored in the second storage space.
  • firmware upgrade data can be obtained from the host computer.
  • the host computer device can send an upgrade command to the electronic device; after receiving the upgrade command, the electronic device obtains firmware upgrade data from the host computer device through the firmware in the first storage space.
  • the electronic device receives the upgrade command, it sends a data acquisition request to the upper computer device through the firmware in the first storage space.
  • the firmware in the first storage space receives the firmware upgrade data transmitted from the upper computer device.
  • the data volume of the firmware upgrade data is relatively large, so the host computer device can divide the firmware upgrade data into multiple data packets and send them one by one, and the electronic device sequentially receives the multiple data packets transmitted by the host computer device through the firmware in the first storage space. , and write multiple data packets into the second storage space in sequence.
  • the electronic device may periodically send a data acquisition request to the upper computer device through the firmware in the first storage space.
  • the host computer device After the host computer device receives the data acquisition request sent by the electronic device, it checks whether the firmware upgrade data is stored locally; if the firmware upgrade data is stored locally, the firmware upgrade data is sent to the electronic device, and the electronic device passes through the first storage space.
  • the firmware of the device receives the firmware upgrade data transmitted from the host computer device; if the firmware upgrade data is not stored locally, an empty data packet is sent to the electronic device to inform the electronic device that no upgrade is currently required.
  • the firmware upgrade data is obtained through the firmware stored in the first storage space, and after the firmware upgrade data is stored in the second storage space, the electronic device can enter the boot program through program reset, thereby realizing the startup of the boot program. . It should be added that after the boot program is started, the firmware stored in the first storage space stops running.
  • the bootstrap program in the process of running the bootstrap program, is made to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space, and also That is, the firmware stored in the first storage space is upgraded according to the firmware upgrade data stored in the second storage space by executing the preset upgrade instruction in the bootstrap program, and an upgrade is obtained. post firmware.
  • Manner 1 Make the bootloader read firmware upgrade data from the second storage space; make the bootloader overwrite the read firmware upgrade data into the first storage space to obtain upgraded firmware.
  • Method 2 Make the boot program erase the firmware stored in the first storage space; make the boot program read the firmware upgrade data from the second storage space, and read the firmware update data from the second storage space. The obtained firmware upgrade data is written into the first storage space to obtain upgraded firmware.
  • the firmware upgrade data can be understood as new firmware.
  • the firmware upgrade data obtained from the host computer is encrypted data, so the boot program can first decrypt the firmware upgrade data in the second storage space, and then read the decrypted firmware upgrade data from the second storage space.
  • the data acquisition stage that takes a long time and is prone to failure or interruption in the firmware upgrade process is set in the firmware to be upgraded, and the firmware stores the acquired firmware upgrade data in the second storage space, wherein the second storage space is different from the first storage space in which the firmware is stored.
  • the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process.
  • the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process.
  • the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process.
  • the firmware if the data acquisition stage fails or is interrupted, the program still remains in the firmware, and the firmware can still perform the corresponding functions normally to protect the normal operation of the device. That is to say, in
  • the above method may further include the following steps:
  • the boot program If the first verification result shows that the verification fails, then make the boot program replace the upgraded firmware stored in the first storage space with the backup firmware stored in the second storage space. the backup firmware.
  • the first verification instruction in the boot program can be specifically executed to verify the upgraded firmware stored in the first storage space.
  • the check may be an integrity check, for example, an MD5 check, which is used to judge whether the firmware is complete after the upgrade. Through the verification, you can predict in advance whether the firmware is available after the upgrade, so as to avoid future troubles.
  • an integrity check for example, an MD5 check
  • a copy of available backup firmware may be reserved in the second storage space in advance.
  • the first verification result shows that the verification fails, indicating that the firmware is unavailable after the upgrade, and the upgrade fails. Therefore, the boot program can read the backup firmware from the second storage space, and replace the upgraded firmware stored in the first storage space with the backup firmware. Specifically, the boot program can store the firmware in the first storage space. After the upgrade, the firmware is erased, and then the backup firmware is read from the second storage space, and the read backup firmware is written into the first storage space.
  • the bootloader of a smart battery does not need protection strategies, low power consumption, and charging and discharging functions.
  • the above method may also include:
  • the first verification result shows that the verification is successful, it means that the upgraded firmware is available, that is, the upgrade is successful, and then jumps to the upgraded firmware stored in the first storage space.
  • the upgraded firmware runs in the first storage space.
  • the upgraded firmware in the first storage space passes the verification, it means that the firmware upgrade data stored in the second storage space is available, so the firmware upgrade data in the second storage space can be used as backup firmware , for subsequent backup and restore use.
  • the above method further includes:
  • the boot program can obtain the backup firmware according to the backup firmware flag.
  • the above method may further include:
  • the boot program performs an integrity check on the firmware upgrade data stored in the second storage space to ensure that the transmitted firmware upgrade data is complete. Through the verification, it can be predicted in advance whether the transmitted firmware upgrade data is available, so as to avoid future troubles.
  • the firmware in the first storage space can be verified. If the verification is successful, it will jump to the firmware in the first storage space; if the verification fails, it will be backed up and restored. .
  • the above method may also include:
  • the bootloader needs to determine whether the firmware upgrade needs to be performed at present after jumping from the firmware to the bootloader through a program reset.
  • a firmware information area can be set, and an update flag can be set in the firmware information area.
  • the update flag is updated once. In this way, after jumping into the boot program, the boot program can judge whether the firmware upgrade needs to be performed according to the update flag in the firmware information area.
  • the above method may also include:
  • the above-mentioned update flag may specifically be an Arabic numeral, and the numeral is incremented by 1 each time it is updated.
  • the update flag is 2 before the update, and the update flag is 3 after the update.
  • the above method may further include:
  • the above-mentioned firmware upgrade method is applicable to a smart battery; the smart battery includes the above-mentioned second storage space and the above-mentioned first storage space.
  • the smart battery can use the above firmware upgrade method to upgrade its firmware.
  • the boot program in the smart battery does not need functions such as protection strategy, low power consumption, charging and discharging, and has simple functions and low maintenance difficulty.
  • step 205 If it is updated, execute the following step 205; if it is not updated, execute the following step 215.
  • step 206 If the second verification result shows that the verification is successful, the following step 206 is performed; if the second verification result shows that the verification fails, the following step 212 is performed.
  • the following steps 209 and 210 are performed; if the first verification result shows that the verification fails, the following step 211 is performed.
  • step 213 If the third verification result shows that the verification is successful, the following step 213 is performed; if the third verification result shows that the verification fails, the following step 214 is performed.
  • step 216 If the fourth verification result shows that the verification is successful, the following step 216 is performed; if the fourth verification result shows that the verification fails, the following step 217 is performed.
  • the upgrade transmission process is set to be performed in the firmware, the firmware first saves the new firmware in the second storage space, and at the same time retains a backup firmware in the second storage space, and then jumps to the boot program to boot The program only performs the firmware transfer work. If the new firmware is abnormal, the backup firmware can be returned, which ensures that the program will never stay in the bootloader. In this way, there is no need to design the corresponding functions in the firmware into the bootloader. The complexity of the bootloader is greatly reduced.
  • FIG. 3 shows a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the electronic device includes a memory 1101 and a processor 1102 .
  • the processor 1102 is configured to perform the following operations:
  • the boot program is made to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space to obtain upgraded firmware.
  • the data acquisition stage that takes a long time and is prone to failure or interruption in the firmware upgrade process is set in the firmware to be upgraded, and the firmware stores the acquired firmware upgrade data in the second storage space, wherein the second storage space is different from the first storage space in which the firmware is stored.
  • the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process.
  • the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process.
  • the firmware if the data acquisition stage fails or is interrupted, the program still stays in the firmware, and the firmware can still perform the corresponding functions normally to protect the normal operation of the device. That is to say, in the technical solutions provided by the embodiments of the present application, it is not necessary to design the corresponding functions of the firmware into the bootstrap program, and the bootstrap program has simple functions, low complexity, and low
  • the processor when the processor causes the boot program to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space, it is specifically used to:
  • the processor is further configured to:
  • the processor is further configured to:
  • the boot program is made to replace the upgraded firmware stored in the first storage space with the updated firmware according to the backup firmware stored in the second storage space Backup firmware.
  • the processor is further configured to:
  • the processor is further configured to:
  • the processor is further configured to:
  • the processor is further configured to:
  • the boot program will replace the firmware stored in the first storage space with the firmware stored in the second storage space according to the backup firmware stored in the second storage space. Backup firmware.
  • the processor is further configured to:
  • the update flag in the firmware information area is updated by the firmware
  • the processor is further configured to:
  • the boot program will replace the firmware stored in the first storage space with the firmware stored in the second storage space according to the backup firmware stored in the second storage space. Backup firmware.
  • the processor is further configured to:
  • the electronic device is a smart battery.
  • the embodiments of the present application further provide a computer-readable storage medium storing a computer program, and when the computer program is executed by a computer, the steps or functions of the firmware upgrade methods provided by the above method embodiments can be implemented.
  • each embodiment can be implemented by means of software plus a necessary general hardware platform, and certainly can also be implemented by hardware.
  • the above-mentioned technical solutions can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products can be stored in computer-readable storage media, such as ROM/RAM, magnetic A disc, an optical disc, etc., includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform the methods described in various embodiments or some parts of the embodiments.

Abstract

Embodiments of the present application provide a firmware upgrade method and an electronic device. The method comprises: obtaining firmware upgrade data by means of firmware stored in a first storage space, and storing said firmware upgrade data in a second storage space; starting a boot loader; according to the firmware upgrade data stored in said second storage storage space, causing said boot loader to upgrade the firmware stored in the first storage to obtain upgraded firmware. In the technical solutions provided by the embodiments of the present application, it is unnecessary to design certain features of the firmware into the boot loader, the boot loader has simple functions and low complexity, and is less difficult to maintain.

Description

固件升级方法及电子设备Firmware upgrade method and electronic device 技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种固件升级方法及电子设备。The present invention relates to the field of computer technology, and in particular, to a firmware upgrade method and an electronic device.
背景技术Background technique
通常,电子设备中会存储有能够实现各种各样功能的固件程序(Firmware),以确保电子设备能够正常运转。实际应用中,会由于各种原因需要升级设备中的固件程序,例如:为了克服原有固件所存在的漏洞、为了增强设备的兼容性、为了开发设备新的功能,等等。Usually, firmware programs (Firmware) capable of implementing various functions are stored in an electronic device to ensure that the electronic device can operate normally. In practical applications, the firmware program in the device needs to be upgraded for various reasons, such as: in order to overcome the loopholes in the original firmware, in order to enhance the compatibility of the device, in order to develop new functions of the device, and so on.
现有技术中,一般是通过设备中的引导程序(loader)来加载、升级固件程序。为了降低在固件升级过程中因固件升级引起的设备运转异常的出现率,现有的方案是将固件中的某些功能设计到引导程序中,这就导致引导程序功能复杂,难以维护。In the prior art, the firmware program is generally loaded and upgraded through a boot program (loader) in the device. In order to reduce the occurrence rate of abnormal device operation caused by firmware upgrade during the firmware upgrade process, the existing solution is to design some functions in the firmware into the boot program, which makes the boot program function complex and difficult to maintain.
发明内容SUMMARY OF THE INVENTION
本申请提供了一种固件升级方法及电子设备,用于解决现有技术中引导程序功能复杂,难以维护的问题。The present application provides a firmware upgrade method and an electronic device, which are used to solve the problems in the prior art that the functions of the boot program are complex and difficult to maintain.
本申请一实施例提供一种固件升级方法。该方法包括:An embodiment of the present application provides a firmware upgrade method. The method includes:
通过存储于第一存储空间中的固件获取固件升级数据,并将所述固件升级数据存储于第二存储空间;Obtain firmware upgrade data through firmware stored in the first storage space, and store the firmware upgrade data in the second storage space;
启动引导程序;start the bootloader;
使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级,得到升级后固件。The boot program is made to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space to obtain upgraded firmware.
本申请又一实施例提供了一种电子设备。该电子设备包括:Yet another embodiment of the present application provides an electronic device. The electronic equipment includes:
存储器,用于存储计算机程序;所述存储器包括第二存储空间和第一存储空间;a memory for storing computer programs; the memory includes a second storage space and a first storage space;
处理器,用于执行以下操作:A processor that performs the following actions:
通过存储于第一存储空间中的固件获取固件升级数据,并将所述固件 升级数据存储于第二存储空间;Obtain firmware upgrade data by the firmware stored in the first storage space, and store the firmware upgrade data in the second storage space;
启动引导程序;start the bootloader;
使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级,得到升级后固件。The boot program is made to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space to obtain upgraded firmware.
本申请实施例提供的技术方案中,将固件升级过程中耗时长、容易出现失败或中断的数据获取阶段设置在待升级的固件中进行,并由固件将获取到的固件升级数据存储在第二存储空间,其中,第二存储空间区别于用于存储该固件的第一存储空间。这样,在固件升级过程中的数据获取阶段,待升级的固件可一边获取其固件升级数据,一边执行相应功能来保证设备的正常运转,降低了固件升级过程中设备运转异常的出现率。此外,若数据获取阶段出现失败或中断,程序依旧停留在固件中,固件还是可以正常执行相应功能来保护设备的正常运转。也就是说,在本申请实施例提供的技术方案中,无需将固件的某些功能设计到引导程序中,引导程序功能简单,复杂度低,维护难度小。In the technical solutions provided by the embodiments of the present application, the data acquisition stage that takes a long time and is prone to failure or interruption in the firmware upgrade process is set in the firmware to be upgraded, and the firmware stores the acquired firmware upgrade data in the second storage space, wherein the second storage space is different from the first storage space for storing the firmware. In this way, in the data acquisition stage of the firmware upgrade process, the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process. In addition, if the data acquisition stage fails or is interrupted, the program still remains in the firmware, and the firmware can still perform the corresponding functions normally to protect the normal operation of the device. That is, in the technical solutions provided by the embodiments of the present application, some functions of the firmware need not be designed into the boot program, and the boot program has simple functions, low complexity, and low maintenance difficulty.
附图说明Description of drawings
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described herein are used to provide further understanding of the present application and constitute a part of the present application. The schematic embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation of the present application. In the attached image:
图1为本申请一实施例提供的固件升级方法的流程示意图;1 is a schematic flowchart of a firmware upgrade method provided by an embodiment of the present application;
图2为本申请又一实施例提供的固件升级方法的流程示意图;2 is a schematic flowchart of a firmware upgrade method provided by another embodiment of the present application;
图3为本申请一实施例提供的电子设备的结构框图。FIG. 3 is a structural block diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
除非另有定义,本文所使用的所有的技术和科学术语与属于本发明的技术领域的技术人员通常理解的含义相同。本文中在本发明的说明书中所使用 的术语只是为了描述具体的实施例的目的,不是旨在于限制本发明。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terms used herein in the description of the present invention are for the purpose of describing specific embodiments only, and are not intended to limit the present invention.
为了便于理解本申请的技术方案和技术效果,下面对现有技术进行简要说明:In order to facilitate the understanding of the technical solutions and technical effects of the present application, the prior art is briefly described below:
现有技术中,电子设备包括存储引导程序的引导程序区和存储固件的应用程序区。其中,引导程序是用来加载、升级固件的;固件是用来执行相应功能以确保电子设备正常运转的。通常,在电子设备上电开机后,一般会先运行引导程序,然后利用引导程序来加载固件程序,从而完成固件功能实现。固件升级需要在引导程序中执行,升级流程为:由引导程序先将应用程序区的固件进行擦除;然后,上位机将新版本固件分成小包发送,引导程序每接收到一包就在应用程序区写入一包;全部写完后,引导程序对应用程序区的新版本固件进行完整性校验,校验通过则跳转至新版本固件。In the prior art, an electronic device includes a boot program area for storing a boot program and an application program area for storing firmware. Among them, the boot program is used to load and upgrade the firmware; the firmware is used to perform corresponding functions to ensure the normal operation of the electronic device. Usually, after the electronic device is powered on, the boot program is generally run first, and then the boot program is used to load the firmware program, thereby completing the realization of the firmware function. The firmware upgrade needs to be performed in the bootloader. The upgrade process is: the bootloader first erases the firmware in the application program area; then, the host computer divides the new version of the firmware into small packages and sends it, and the bootloader receives a package. Write a package in the application area; after all the writing is completed, the bootloader performs an integrity check on the new version of the firmware in the application program area, and jumps to the new version of the firmware if the verification is passed.
有些电子设备在固件升级过程中,依旧需要工作,这就需要引导程序本身也具备某些功能以保证电子设备的正常运转。以智能电池为例,无人机或者其他智能设备在其智能电池固件升级过程中,依旧需要依赖智能电池供电,这时智能电池的引导程序就需要具备复杂的电路保护功能以保证智能电池的正常运转;并且,一旦升级失败,程序只能停留在引导程序中,因此,引导程序还需要支持充放电功能以保证智能电池的正常运转。也就是说,现有技术中,为了降低固件升级过程中设备运转异常的出现率,需要将固件的某些功能设计到引导程序中,使得引导程序功能复杂度高,且引导程序本身很难升级,对维护造成麻烦。Some electronic devices still need to work during the firmware upgrade process, which requires the boot program itself to have certain functions to ensure the normal operation of the electronic devices. Taking the smart battery as an example, the drone or other smart devices still need to rely on the smart battery for power supply during the firmware upgrade process of the smart battery. At this time, the boot program of the smart battery needs to have a complex circuit protection function to ensure the normal operation of the smart battery. And, once the upgrade fails, the program can only stay in the boot program, so the boot program also needs to support the charging and discharging function to ensure the normal operation of the smart battery. That is to say, in the prior art, in order to reduce the occurrence rate of abnormal operation of the device during the firmware upgrade process, some functions of the firmware need to be designed into the boot program, which makes the function complexity of the boot program high, and the boot program itself is difficult to upgrade. , causing trouble for maintenance.
为了解决上述技术问题,本申请实施例提供了一种固件升级方法,将固件升级过程中的数据获取阶段设置在固件中进行,这样固件可一边获取固件升级数据,一边执行相应功能来保证设备的正常运转。这样一来,就无需将固件的某些功能设计到引导程序中,引导程序功能简单,复杂度低,维护难度小。In order to solve the above technical problems, the embodiments of the present application provide a firmware upgrade method, in which the data acquisition stage in the firmware upgrade process is set in the firmware, so that the firmware can acquire firmware upgrade data and execute corresponding functions to ensure the device's normal operation. In this way, there is no need to design some functions of the firmware into the boot program, and the boot program has simple functions, low complexity, and low maintenance difficulty.
下面结合附图,对本发明的一些实施方式作详细说明。在各实施例之间不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。Some embodiments of the present invention will be described in detail below with reference to the accompanying drawings. The following embodiments and features in the embodiments may be combined with each other without conflict between the embodiments.
图1示出了本申请实施例提供的固件升级方法的流程示意图。如图1所示,该方法,包括:FIG. 1 shows a schematic flowchart of a firmware upgrade method provided by an embodiment of the present application. As shown in Figure 1, the method includes:
101、通过存储于第一存储空间中的固件获取固件升级数据,并将所述 固件升级数据存储于第二存储空间。101. Obtain firmware upgrade data through firmware stored in the first storage space, and store the firmware upgrade data in the second storage space.
102、启动引导程序。102. Start the bootstrap program.
103、使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级,得到升级后固件。103. Make the boot program upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space to obtain upgraded firmware.
本申请实施例提供的固件升级方法可用于电子设备固件的升级。本申请实施例提供的固件升级方法的执行主体为电子设备,具体为电子设备的处理器,例如:MCU(Microcontroller Unit,微控制单元)。实际应用时,上述电子设备具体可以为智能电池、无人机、汽车等。The firmware upgrade method provided by the embodiment of the present application can be used for upgrading the firmware of an electronic device. The execution subject of the firmware upgrade method provided by the embodiment of the present application is an electronic device, and specifically a processor of the electronic device, for example, an MCU (Microcontroller Unit, micro control unit). In practical applications, the above-mentioned electronic devices may specifically be smart batteries, drones, automobiles, and the like.
上述101中,上述固件存储并运行于第一存储空间中。在所述第一存储空间中运行其存储的固件的过程中,通过该固件来获取固件升级数据,并将固件升级数据存储于第二存储空间。也即是,在第一存储空间中运行上述固件的过程中,通过执行所述固件中的预设获取指令,来获取固件升级数据;并通过执行所述固件中的预设存储指令,将获取到的固件升级数据存储于第二存储空间。In the above 101, the above firmware is stored and executed in the first storage space. During the process of running the firmware stored in the first storage space, the firmware upgrade data is acquired through the firmware, and the firmware upgrade data is stored in the second storage space. That is, in the process of running the above-mentioned firmware in the first storage space, the firmware upgrade data is acquired by executing the preset acquisition instruction in the firmware; and by executing the preset storage instruction in the firmware, the acquired data is obtained. The obtained firmware upgrade data is stored in the second storage space.
实际应用中,可从上位机设备处获取固件升级数据。在一实例中,上位机设备可向电子设备发送升级命令;电子设备接收到升级命令后,通过第一存储空间中的固件从上位机设备处获取固件升级数据。具体地,电子设备接收到升级命令后,通过第一存储空间中的固件向上位机设备发送数据获取请求,上位机设备接收到数据获取请求后,将固件升级数据发送给电子设备,电子设备通过第一存储空间中的固件接收上位机设备传输来的固件升级数据。通常,固件升级数据的数据量较大,故上位机设备可将固件升级数据分成多个数据包逐一发送,电子设备通过第一存储空间中的固件依次接收上位机设备传输来的多个数据包,并将多个数据包依次写入第二存储空间。In practical applications, firmware upgrade data can be obtained from the host computer. In an example, the host computer device can send an upgrade command to the electronic device; after receiving the upgrade command, the electronic device obtains firmware upgrade data from the host computer device through the firmware in the first storage space. Specifically, after the electronic device receives the upgrade command, it sends a data acquisition request to the upper computer device through the firmware in the first storage space. After the upper computer device receives the data acquisition request, it sends the firmware upgrade data to the electronic device, and the electronic device passes the data acquisition request. The firmware in the first storage space receives the firmware upgrade data transmitted from the upper computer device. Usually, the data volume of the firmware upgrade data is relatively large, so the host computer device can divide the firmware upgrade data into multiple data packets and send them one by one, and the electronic device sequentially receives the multiple data packets transmitted by the host computer device through the firmware in the first storage space. , and write multiple data packets into the second storage space in sequence.
在另一实例中,电子设备可通过第一存储空间中的固件定时向上位机设备发送数据获取请求。上位机设备接收到电子设备发送来的数据获取请求后,检查本地是否存储有固件升级数据;若本地存储有固件升级数据,则将固件升级数据发送给电子设备,电子设备通过第一存储空间中的固件接收上位机设备传输来的固件升级数据;若本地未存储有固件升级数据,则向电子设备发送一个空的数据包,以告知电子设备当前无需升级。In another example, the electronic device may periodically send a data acquisition request to the upper computer device through the firmware in the first storage space. After the host computer device receives the data acquisition request sent by the electronic device, it checks whether the firmware upgrade data is stored locally; if the firmware upgrade data is stored locally, the firmware upgrade data is sent to the electronic device, and the electronic device passes through the first storage space. The firmware of the device receives the firmware upgrade data transmitted from the host computer device; if the firmware upgrade data is not stored locally, an empty data packet is sent to the electronic device to inform the electronic device that no upgrade is currently required.
上述102中,通过存储于第一存储空间中的固件获取固件升级数据,并将所述固件升级数据存储于第二存储空间后,电子设备可通过程序复位进入引 导程序,从而实现引导程序的启动。需要补充的是:在启动引导程序后,存储于第一存储空间中的固件就停止运行了。In the above-mentioned 102, the firmware upgrade data is obtained through the firmware stored in the first storage space, and after the firmware upgrade data is stored in the second storage space, the electronic device can enter the boot program through program reset, thereby realizing the startup of the boot program. . It should be added that after the boot program is started, the firmware stored in the first storage space stops running.
上述103中,在运行引导程序的过程中,使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级,也即是,通过执行引导程序中的预设升级指令,以实现根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级,得到升级后固件。In the above 103, in the process of running the bootstrap program, the bootstrap program is made to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space, and also That is, the firmware stored in the first storage space is upgraded according to the firmware upgrade data stored in the second storage space by executing the preset upgrade instruction in the bootstrap program, and an upgrade is obtained. post firmware.
上述103中“使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级,得到升级后固件”,可采用如下方式中的一种或多种来实现:In the above-mentioned 103, "make the boot program upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space, and obtain the upgraded firmware", the following can be used One or more of the ways to achieve:
方式一、使引导程序从第二存储空间中读取固件升级数据;使引导程序将读取到的固件升级数据覆盖写入第一存储空间,以得到升级后固件。Manner 1: Make the bootloader read firmware upgrade data from the second storage space; make the bootloader overwrite the read firmware upgrade data into the first storage space to obtain upgraded firmware.
方式二、使所述引导程序将存储于所述第一存储空间中的所述固件进行擦除;使所述引导程序从所述第二存储空间读取所述固件升级数据,并将读取到的所述固件升级数据写入所述第一存储空间,以得到升级后固件。Method 2: Make the boot program erase the firmware stored in the first storage space; make the boot program read the firmware upgrade data from the second storage space, and read the firmware update data from the second storage space. The obtained firmware upgrade data is written into the first storage space to obtain upgraded firmware.
其中,固件升级数据可理解为新的固件。The firmware upgrade data can be understood as new firmware.
通常,从上位机处获取的固件升级数据为加密数据,故引导程序可先对第二存储空间中的固件升级数据进行解密,然后从第二存储空间读取解密后的固件升级数据。Usually, the firmware upgrade data obtained from the host computer is encrypted data, so the boot program can first decrypt the firmware upgrade data in the second storage space, and then read the decrypted firmware upgrade data from the second storage space.
本申请实施例提供的技术方案中,将固件升级过程中耗时长、容易出现失败或中断的数据获取阶段设置在待升级的固件中进行,并由固件将获取到的固件升级数据存储在第二存储空间,其中,第二存储空间区别于存储该固件的第一存储空间。这样,在固件升级过程中的数据获取阶段,待升级的固件可一边获取其固件升级数据,一边执行相应功能来保证设备的正常运转,降低了固件升级过程中设备运转异常的出现率。此外,若数据获取阶段出现失败或中断,程序依旧停留在固件中,固件还是可以正常执行相应功能来保护设备的正常运转。也就是说,在本申请实施例提供的技术方案中,无需将固件的相应功能设计到引导程序中,引导程序功能简单,复杂度低,维护难度小。In the technical solutions provided by the embodiments of the present application, the data acquisition stage that takes a long time and is prone to failure or interruption in the firmware upgrade process is set in the firmware to be upgraded, and the firmware stores the acquired firmware upgrade data in the second storage space, wherein the second storage space is different from the first storage space in which the firmware is stored. In this way, in the data acquisition stage of the firmware upgrade process, the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process. In addition, if the data acquisition stage fails or is interrupted, the program still remains in the firmware, and the firmware can still perform the corresponding functions normally to protect the normal operation of the device. That is to say, in the technical solutions provided by the embodiments of the present application, there is no need to design the corresponding functions of the firmware into the boot program, and the boot program has simple functions, low complexity, and low maintenance difficulty.
实际应用时,在上述步骤103之后,上述方法,还可包括如下步骤:In practical application, after the above step 103, the above method may further include the following steps:
104、使所述引导程序对存储于所述第一存储空间的升级后固件进行校 验,得到第一校验结果。104. Make the boot program verify the upgraded firmware stored in the first storage space to obtain a first verification result.
105、若所述第一校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的升级后固件替换成所述备份固件。105. If the first verification result shows that the verification fails, then make the boot program replace the upgraded firmware stored in the first storage space with the backup firmware stored in the second storage space. the backup firmware.
上述104中,具体可执行引导程序中的第一校验指令,以对存储于所述第一存储空间中的升级后固件进行校验。该校验具体可以为完整性校验,例如:MD5校验,用于判断升级后固件是否完整。通过校验,可提前预知升级后固件是否可用,避免之后的麻烦。具体的校验过程可参见现有技术,在此不再详述。In the above 104, the first verification instruction in the boot program can be specifically executed to verify the upgraded firmware stored in the first storage space. Specifically, the check may be an integrity check, for example, an MD5 check, which is used to judge whether the firmware is complete after the upgrade. Through the verification, you can predict in advance whether the firmware is available after the upgrade, so as to avoid future troubles. For the specific verification process, reference may be made to the prior art, which will not be described in detail here.
上述105中,在本方案中,可事先在第二存储空间中保留一份可用的备份固件。所述第一校验结果显示校验失败,说明升级后固件不可用,升级失败。故可使引导程序从第二存储空间读取备份固件,并将存储于所述第一存储空间的升级后固件替换成备份固件,具体地,引导程序可将存储于所述第一存储空间的升级后固件擦除,然后从第二存储空间读取备份固件,并将读取到的备份固件写入到第一存储空间。In the above 105, in this solution, a copy of available backup firmware may be reserved in the second storage space in advance. The first verification result shows that the verification fails, indicating that the firmware is unavailable after the upgrade, and the upgrade fails. Therefore, the boot program can read the backup firmware from the second storage space, and replace the upgraded firmware stored in the first storage space with the backup firmware. Specifically, the boot program can store the firmware in the first storage space. After the upgrade, the firmware is erased, and then the backup firmware is read from the second storage space, and the read backup firmware is written into the first storage space.
在本实施例中,通过备份固件,可保证程序永远不会停留在引导程序中,使得引导程序复杂度大大降低。以智能电池为例,智能电池的引导程序不需要保护策略、低功耗以及充放电等功能。In this embodiment, by backing up the firmware, it can be ensured that the program will never stay in the boot program, so that the complexity of the boot program is greatly reduced. Taking a smart battery as an example, the bootloader of a smart battery does not need protection strategies, low power consumption, and charging and discharging functions.
进一步的,上述方法,还可包括:Further, the above method may also include:
106、若所述第一校验结果显示校验成功,则跳转进入存储于所述第一存储空间的升级后固件。106. If the first verification result shows that the verification is successful, jump to the upgraded firmware stored in the first storage space.
上述106中,若第一校验结果显示校验成功,则说明升级后固件可用,也即升级成功,则跳转进入存储于所述第一存储空间的升级后固件。升级后固件运行于所述第一存储空间。In the above 106, if the first verification result shows that the verification is successful, it means that the upgraded firmware is available, that is, the upgrade is successful, and then jumps to the upgraded firmware stored in the first storage space. The upgraded firmware runs in the first storage space.
在实际应用时,若第一存储空间中的升级后固件通过校验,则说明存储于第二存储空间的固件升级数据是可用的,故可将第二存储空间中的固件升级数据作为备份固件,以供后续备份还原使用。In practical application, if the upgraded firmware in the first storage space passes the verification, it means that the firmware upgrade data stored in the second storage space is available, so the firmware upgrade data in the second storage space can be used as backup firmware , for subsequent backup and restore use.
具体地,若所述第一校验结果显示校验成功,则在跳转进入存储于所述第一存储空间的升级后固件之前,上述方法,还包括:Specifically, if the first verification result shows that the verification is successful, before jumping into the upgraded firmware stored in the first storage space, the above method further includes:
107、使所述引导程序针对存储于所述第二存储空间中的所述固件升级数据设置备用固件标志,以将所述固件升级数据作为备份固件供后续使用。107. Cause the boot program to set a backup firmware flag for the firmware upgrade data stored in the second storage space, so as to use the firmware upgrade data as backup firmware for subsequent use.
这样,后续进行备份还原时,引导程序可根据备用固件标志来获取备份固件。In this way, during subsequent backup and restoration, the boot program can obtain the backup firmware according to the backup firmware flag.
在另一实施例中,上述方法,还可包括:In another embodiment, the above method may further include:
108、使所述引导程序对存储于所述第二存储空间中的固件升级数据进行校验,得到第二校验结果。108. Cause the boot program to verify the firmware upgrade data stored in the second storage space to obtain a second verification result.
109、若所述第二校验结果显示校验成功,则触发执行使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级的步骤。109. If the second verification result shows that the verification is successful, trigger the execution to cause the boot program to update all the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space. Steps to upgrade the firmware.
上述108中,具体地,引导程序对存储于所述第二存储空间中的固件升级数据进行完整性校验,以确保传输来的固件升级数据是完整的。通过校验,可提前预知传输来的固件升级数据是否可用,避免之后的麻烦。In the above 108, specifically, the boot program performs an integrity check on the firmware upgrade data stored in the second storage space to ensure that the transmitted firmware upgrade data is complete. Through the verification, it can be predicted in advance whether the transmitted firmware upgrade data is available, so as to avoid future troubles.
若第二校验结果显示校验成功,说明第二存储空间的固件升级数据可用,故可以根据第二存储空间中的固件升级数据对第一存储空间的固件进行升级。若第二校验结果显示校验失败,说明第二存储空间的固件升级数据不可用,故不能根据第二存储空间中的固件升级数据对第一存储空间的固件进行升级。这时,为了不影响设备的正常运转,可对第一存储空间中的固件进行校验,若校验成功,则跳转进入第一存储空间中的固件;若校验失败,则进行备份还原。If the second verification result shows that the verification is successful, it means that the firmware upgrade data of the second storage space is available, so the firmware of the first storage space can be upgraded according to the firmware upgrade data in the second storage space. If the second verification result shows that the verification fails, it means that the firmware upgrade data in the second storage space is unavailable, so the firmware in the first storage space cannot be upgraded according to the firmware upgrade data in the second storage space. At this time, in order not to affect the normal operation of the device, the firmware in the first storage space can be verified. If the verification is successful, it will jump to the firmware in the first storage space; if the verification fails, it will be backed up and restored. .
具体地,上述方法,还可包括:Specifically, the above method may also include:
109、若所述第二校验结果显示校验失败,则使所述引导程序对存储于所述第一存储空间中的所述固件进行校验,得到第三校验结果。109. If the second verification result shows that the verification fails, enable the boot program to verify the firmware stored in the first storage space to obtain a third verification result.
110、若所述第三校验结果显示校验成功,则跳转进入存储于所述第一存储空间中的所述固件。110. If the third verification result shows that the verification is successful, jump into the firmware stored in the first storage space.
111、若所述第三校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的所述固件替换成所述备份固件。111. If the third verification result shows that verification fails, make the boot program replace the firmware stored in the first storage space with the backup firmware stored in the second storage space with the backup firmware.
由于固件和引导程序是两个相互独立的程序,通过程序复位,从固件跳转进入引导程序后,引导程序需要判断当前是否需要执行固件升级。为了方便引导程序判断,可设置一个固件信息区,并在固件信息区设置一个更新标志,固件每获取一次固件升级数据,就对该更新标志进行更新一次。这样,跳转进入引导程序后,引导程序可根据该固件信息区中的更新标志来判断是 否需要执行固件升级。Since the firmware and the bootloader are two independent programs, the bootloader needs to determine whether the firmware upgrade needs to be performed at present after jumping from the firmware to the bootloader through a program reset. In order to facilitate the judgment of the boot program, a firmware information area can be set, and an update flag can be set in the firmware information area. Each time the firmware obtains firmware update data, the update flag is updated once. In this way, after jumping into the boot program, the boot program can judge whether the firmware upgrade needs to be performed according to the update flag in the firmware information area.
具体地,上述方法,还可包括:Specifically, the above method may also include:
112、通过所述固件将所述固件升级数据存储于所述第二存储空间之后,通过所述固件更新固件信息区中的更新标志。112. After the firmware upgrade data is stored in the second storage space by the firmware, update the update flag in the firmware information area by the firmware.
113、启动所述引导程序后,使所述引导程序判断所述固件信息区中的更新标志是否被更新。113. After starting the bootstrap program, enable the bootstrap program to determine whether the update flag in the firmware information area is updated.
114、若所述更新标志被更新,则触发执行使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级的步骤。114. If the update flag is updated, trigger the execution of a program that causes the boot program to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space. step.
上述112中,在一具体实例中,上述更新标志具体可以为阿拉伯数字,每更新一次,其数字加1。例如:更新前更新标志为2,更新后更新标志为3。In the above-mentioned 112, in a specific example, the above-mentioned update flag may specifically be an Arabic numeral, and the numeral is incremented by 1 each time it is updated. For example: the update flag is 2 before the update, and the update flag is 3 after the update.
在实际应用时,若更新标志未被更新,则说明无需执行固件升级。因此,上述方法,还可包括:In practical application, if the update flag is not updated, it means that the firmware update does not need to be performed. Therefore, the above method may further include:
115、若所述更新标志未被更新,则使所述引导程序对存储于所述第一存储空间中的所述固件进行校验,得到第四校验结果。115. If the update flag has not been updated, enable the boot program to verify the firmware stored in the first storage space to obtain a fourth verification result.
116、若所述第四校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的所述固件替换成所述备份固件。116. If the fourth verification result shows that the verification fails, then make the boot program replace the firmware stored in the first storage space with the backup firmware stored in the second storage space. the backup firmware.
117、若所述第四校验结果显示校验成功,则跳转进入存储于所述第一存储空间中的所述固件。117. If the fourth verification result shows that the verification is successful, jump into the firmware stored in the first storage space.
上述115中对第一存储空间中的固件进行校验的具体实现可参见上述实施例中相应内容。For the specific implementation of the verification of the firmware in the first storage space in the above step 115, reference may be made to the corresponding content in the above embodiment.
上述116中,若第一存储空间中的所述固件未通过校验,则说明第一存储空间中的固件被损坏,故需要使用备份固件进行还原。In the above 116, if the firmware in the first storage space fails to pass the verification, it means that the firmware in the first storage space is damaged, so the backup firmware needs to be used for restoration.
在一具体应用场景中,上述固件升级方法适用于智能电池;智能电池包括上述第二存储空间和上述第一存储空间。智能电池可采用上述固件升级方法来升级其固件。这样智能电池中的引导程序就不需要保护策略、低功耗以及充放电等功能,功能简单,维护难度小。In a specific application scenario, the above-mentioned firmware upgrade method is applicable to a smart battery; the smart battery includes the above-mentioned second storage space and the above-mentioned first storage space. The smart battery can use the above firmware upgrade method to upgrade its firmware. In this way, the boot program in the smart battery does not need functions such as protection strategy, low power consumption, charging and discharging, and has simple functions and low maintenance difficulty.
需要补充说明的是,在跳转进入固件、升级后固件或备用固件后,引导程序就停止运行了。It should be added that after jumping into firmware, upgraded firmware, or backup firmware, the bootloader stops running.
下面将结合图2对本申请实施例提供的技术方案进行详细介绍:The technical solutions provided by the embodiments of the present application will be described in detail below with reference to FIG. 2 :
201、通过存储并运行于第一存储空间中的固件获取固件升级数据,并将所述固件升级数据存储于第二存储空间。201. Obtain firmware upgrade data through firmware stored and run in the first storage space, and store the firmware upgrade data in the second storage space.
202、通过运行于第一存储空间中的固件更新固件信息区中的更新标志。202. Update the update flag in the firmware information area through the firmware running in the first storage space.
203、通过程序复位,进入引导程序。203. Enter the boot program through program reset.
204、使所述引导程序判断所述固件信息区中的更新标志是否被更新。204. Make the boot program determine whether the update flag in the firmware information area is updated.
若被更新,则执行下述步骤205;若未被更新,则执行下述步骤215。If it is updated, execute the following step 205; if it is not updated, execute the following step 215.
205、使所述引导程序对存储于所述第二存储空间中的固件升级数据进行校验,得到第二校验结果。205. Cause the boot program to verify the firmware upgrade data stored in the second storage space to obtain a second verification result.
若第二校验结果显示校验成功,则执行下述步骤206;若第二校验结果显示校验失败,则执行下述步骤212。If the second verification result shows that the verification is successful, the following step 206 is performed; if the second verification result shows that the verification fails, the following step 212 is performed.
206、使所述引导程序将存储于所述第一存储空间中的所述固件进行擦除;206. Cause the boot program to erase the firmware stored in the first storage space;
207、使所述引导程序从所述第二存储空间读取所述固件升级数据,并将读取到的所述固件升级数据写入所述第一存储空间,以得到升级后固件。207. Make the boot program read the firmware upgrade data from the second storage space, and write the read firmware upgrade data into the first storage space to obtain upgraded firmware.
208、使所述引导程序对存储于所述第一存储空间的升级后固件进行校验,得到第一校验结果。208. Cause the boot program to verify the upgraded firmware stored in the first storage space to obtain a first verification result.
若所述第一校验结果显示校验成功,则执行下述步骤209和210;若所述第一校验结果显示校验失败,则执行下述步骤211。If the first verification result shows that the verification is successful, the following steps 209 and 210 are performed; if the first verification result shows that the verification fails, the following step 211 is performed.
209、使引导程序针对存储于第二存储空间中的固件升级数据设置备用固件标志。209. Cause the boot program to set an alternate firmware flag for the firmware upgrade data stored in the second storage space.
210、跳转进入存储于所述第一存储空间的升级后固件。210. Jump to the upgraded firmware stored in the first storage space.
211、使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的升级后固件替换成所述备份固件。211. Cause the boot program to replace the upgraded firmware stored in the first storage space with the backup firmware according to the backup firmware stored in the second storage space.
212、使所述引导程序对存储于所述第一存储空间中的所述固件进行校验,得到第三校验结果。212. Cause the boot program to verify the firmware stored in the first storage space to obtain a third verification result.
若所述第三校验结果显示校验成功,则执行下述步骤213;若所述第三校验结果显示校验失败,则执行下述步骤214。If the third verification result shows that the verification is successful, the following step 213 is performed; if the third verification result shows that the verification fails, the following step 214 is performed.
213、跳转进入存储于所述第一存储空间中的所述固件。213. Jump into the firmware stored in the first storage space.
214、使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的所述固件替换成所述备份固件。214. Cause the boot program to replace the firmware stored in the first storage space with the backup firmware according to the backup firmware stored in the second storage space.
215、使所述引导程序对存储于所述第一存储空间中的所述固件进行校验, 得到第四校验结果。215. Make the boot program verify the firmware stored in the first storage space to obtain a fourth verification result.
若所述第四校验结果显示校验成功,则执行下述步骤216;若所述第四校验结果显示校验失败,则执行下述步骤217。If the fourth verification result shows that the verification is successful, the following step 216 is performed; if the fourth verification result shows that the verification fails, the following step 217 is performed.
216、跳转进入存储于所述第一存储空间中的所述固件。216. Jump into the firmware stored in the first storage space.
217、使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的所述固件替换成所述备份固件。217. Cause the boot program to replace the firmware stored in the first storage space with the backup firmware according to the backup firmware stored in the second storage space.
本申请实施例中,将升级传输过程设置在固件中进行,固件先把新的固件保存在第二存储空间中,同时第二存储空间中保留一份备份固件,然后跳转至引导程序,引导程序只执行固件搬运工作,若新的固件异常,可以退回备份固件,这就保证了程序永远不会停留在引导程序中,这样,就不需要将固件中的相应功能设计到引导程序中,使得引导程序的复杂度大大降低。In the embodiment of the present application, the upgrade transmission process is set to be performed in the firmware, the firmware first saves the new firmware in the second storage space, and at the same time retains a backup firmware in the second storage space, and then jumps to the boot program to boot The program only performs the firmware transfer work. If the new firmware is abnormal, the backup firmware can be returned, which ensures that the program will never stay in the bootloader. In this way, there is no need to design the corresponding functions in the firmware into the bootloader. The complexity of the bootloader is greatly reduced.
图3示出了本申请一实施例提供的电子设备的结构示意图。如图3所示,所述电子设备包括存储器1101以及处理器1102。FIG. 3 shows a schematic structural diagram of an electronic device provided by an embodiment of the present application. As shown in FIG. 3 , the electronic device includes a memory 1101 and a processor 1102 .
存储器1101,用于存储计算机程序;所述存储器1101包括第二存储空间和第一存储空间;a memory 1101 for storing computer programs; the memory 1101 includes a second storage space and a first storage space;
处理器1102,用于执行以下操作:The processor 1102 is configured to perform the following operations:
通过存储于第一存储空间中的固件获取固件升级数据,并将所述固件升级数据存储于第二存储空间;Obtain firmware upgrade data through firmware stored in the first storage space, and store the firmware upgrade data in the second storage space;
启动引导程序;start the bootloader;
使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级,得到升级后固件。The boot program is made to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space to obtain upgraded firmware.
本申请实施例提供的技术方案中,将固件升级过程中耗时长、容易出现失败或中断的数据获取阶段设置在待升级的固件中进行,并由固件将获取到的固件升级数据存储在第二存储空间,其中,第二存储空间区别于存储该固件的第一存储空间。这样,在固件升级过程中的数据获取阶段,待升级的固件可一边获取其固件升级数据,一边执行相应功能来保证设备的正常运转,降低了固件升级过程中设备运转异常的出现率。此外,若数据获取阶段出现失败或中断,程序依旧停留在固件中,固件还是可以正常执行相应功能来保护设备的正常运转。也就是说,在本申请实施例提供的技术方案中,无需将固件的相应功能设计到引导程序中,引导程序功能简单,复杂度低,维护难 度小。In the technical solutions provided by the embodiments of the present application, the data acquisition stage that takes a long time and is prone to failure or interruption in the firmware upgrade process is set in the firmware to be upgraded, and the firmware stores the acquired firmware upgrade data in the second storage space, wherein the second storage space is different from the first storage space in which the firmware is stored. In this way, in the data acquisition stage in the firmware upgrade process, the firmware to be upgraded can obtain its firmware upgrade data while executing corresponding functions to ensure the normal operation of the device, thereby reducing the occurrence rate of abnormal device operation during the firmware upgrade process. In addition, if the data acquisition stage fails or is interrupted, the program still stays in the firmware, and the firmware can still perform the corresponding functions normally to protect the normal operation of the device. That is to say, in the technical solutions provided by the embodiments of the present application, it is not necessary to design the corresponding functions of the firmware into the bootstrap program, and the bootstrap program has simple functions, low complexity, and low maintenance difficulty.
可选的,所述处理器使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级时,具体用于:Optionally, when the processor causes the boot program to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space, it is specifically used to:
使所述引导程序将存储于所述第一存储空间中的所述固件进行擦除;causing the boot program to erase the firmware stored in the first storage space;
使所述引导程序从所述第二存储空间读取所述固件升级数据,并将读取到的所述固件升级数据写入所述第一存储空间,以得到升级后固件。causing the boot program to read the firmware upgrade data from the second storage space, and write the read firmware upgrade data into the first storage space to obtain upgraded firmware.
可选的,所述处理器,还用于:Optionally, the processor is further configured to:
使所述引导程序对存储于所述第一存储空间的升级后固件进行校验,得到第一校验结果;causing the boot program to verify the upgraded firmware stored in the first storage space to obtain a first verification result;
若所述第一校验结果显示校验成功,则跳转进入存储于所述第一存储空间的升级后固件。If the first verification result shows that the verification is successful, then jump to the upgraded firmware stored in the first storage space.
可选的,所述处理器,还用于:Optionally, the processor is further configured to:
若所述第一校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的升级后固件替换成所述备份固件。If the first verification result shows that the verification fails, the boot program is made to replace the upgraded firmware stored in the first storage space with the updated firmware according to the backup firmware stored in the second storage space Backup firmware.
可选的,若所述第一校验结果显示校验成功,则在跳转进入存储于所述第一存储空间的升级后固件之前,所述处理器还用于:Optionally, if the first verification result shows that the verification is successful, before jumping into the upgraded firmware stored in the first storage space, the processor is further configured to:
使所述引导程序针对存储于所述第二存储空间中的所述固件升级数据设置备用固件标志,以将所述固件升级数据作为备份固件供后续使用。causing the boot program to set a backup firmware flag for the firmware upgrade data stored in the second storage space, so as to use the firmware upgrade data as backup firmware for subsequent use.
可选的,所述处理器,还用于:Optionally, the processor is further configured to:
使所述引导程序对存储于所述第二存储空间中的固件升级数据进行校验,得到第二校验结果;causing the boot program to verify the firmware upgrade data stored in the second storage space to obtain a second verification result;
若所述第二校验结果显示校验成功,则触发执行使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级的步骤。If the second verification result shows that the verification is successful, trigger the execution to cause the boot program to update the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space Steps to perform the upgrade.
可选的,所述处理器,还用于:Optionally, the processor is further configured to:
若所述第二校验结果显示校验失败,则使所述引导程序对存储于所述第一存储空间中的所述固件进行校验,得到第三校验结果;If the second verification result shows that the verification fails, causing the boot program to verify the firmware stored in the first storage space to obtain a third verification result;
若所述第三校验结果显示校验成功,则跳转进入存储于所述第一存储空间中的所述固件。If the third verification result shows that the verification is successful, then jump into the firmware stored in the first storage space.
可选的,所述处理器,还用于:Optionally, the processor is further configured to:
若所述第三校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的所述固件替换成所述备份固件。If the third verification result shows that verification fails, the boot program will replace the firmware stored in the first storage space with the firmware stored in the second storage space according to the backup firmware stored in the second storage space. Backup firmware.
可选的,所述处理器,还用于:Optionally, the processor is further configured to:
通过所述固件将所述固件升级数据存储于所述第二存储空间之后,通过所述固件更新固件信息区中的更新标志;After the firmware upgrade data is stored in the second storage space by the firmware, the update flag in the firmware information area is updated by the firmware;
启动所述引导程序后,使所述引导程序判断所述固件信息区中的更新标志是否被更新;After starting the bootstrap program, make the bootstrap program determine whether the update flag in the firmware information area is updated;
若所述更新标志被更新,则触发执行使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级的步骤。If the update flag is updated, a step of causing the boot program to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space is triggered.
可选的,所述处理器,还用于:Optionally, the processor is further configured to:
若所述更新标志未被更新,则使所述引导程序对存储于所述第一存储空间中的所述固件进行校验,得到第四校验结果;If the update flag has not been updated, causing the boot program to verify the firmware stored in the first storage space to obtain a fourth verification result;
若所述第四校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的所述固件替换成所述备份固件。If the fourth verification result shows that the verification fails, the boot program will replace the firmware stored in the first storage space with the firmware stored in the second storage space according to the backup firmware stored in the second storage space. Backup firmware.
可选的,所述处理器,还用于:Optionally, the processor is further configured to:
若所述第四校验结果显示校验成功,则跳转进入存储于所述第一存储空间中的所述固件。If the fourth verification result shows that the verification is successful, jump into the firmware stored in the first storage space.
可选的,所述电子设备为智能电池。Optionally, the electronic device is a smart battery.
相应地,本申请实施例还提供一种存储有计算机程序的计算机可读存储介质,所述计算机程序被计算机执行时能够实现上述各方法实施例提供的固件升级方法的步骤或功能。Correspondingly, the embodiments of the present application further provide a computer-readable storage medium storing a computer program, and when the computer program is executed by a computer, the steps or functions of the firmware upgrade methods provided by the above method embodiments can be implemented.
通过以上的实施例的描述,本领域的技术人员可以清楚地了解到各实施例可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机 设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and certainly can also be implemented by hardware. Based on this understanding, the above-mentioned technical solutions can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products can be stored in computer-readable storage media, such as ROM/RAM, magnetic A disc, an optical disc, etc., includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform the methods described in various embodiments or some parts of the embodiments.
以上所述仅为本发明的实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above descriptions are only the embodiments of the present invention, and are not intended to limit the scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the description and drawings of the present invention, or directly or indirectly applied to other related technologies Fields are similarly included in the scope of patent protection of the present invention.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: The technical solutions described in the foregoing embodiments can still be modified, or some or all of the technical features thereof can be equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the embodiments of the present invention. scope.

Claims (24)

  1. 一种固件升级方法,其特征在于,包括:A method for upgrading firmware, comprising:
    通过存储于第一存储空间中的固件获取固件升级数据,并将所述固件升级数据存储于第二存储空间;Obtain firmware upgrade data through firmware stored in the first storage space, and store the firmware upgrade data in the second storage space;
    启动引导程序;start the bootloader;
    使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级,得到升级后固件。The boot program is made to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space to obtain upgraded firmware.
  2. 根据权利要求1所述的方法,其特征在于,使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级,包括:The method according to claim 1, wherein the boot program is made to upgrade the firmware stored in the first storage space according to firmware upgrade data stored in the second storage space, include:
    使所述引导程序将存储于所述第一存储空间中的所述固件进行擦除;causing the boot program to erase the firmware stored in the first storage space;
    使所述引导程序从所述第二存储空间读取所述固件升级数据,并将读取到的所述固件升级数据写入所述第一存储空间,以得到升级后固件。causing the boot program to read the firmware upgrade data from the second storage space, and write the read firmware upgrade data into the first storage space to obtain upgraded firmware.
  3. 根据权利要求1所述的方法,其特征在于,还包括:The method of claim 1, further comprising:
    使所述引导程序对存储于所述第一存储空间的升级后固件进行校验,得到第一校验结果;causing the boot program to verify the upgraded firmware stored in the first storage space to obtain a first verification result;
    若所述第一校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的升级后固件替换成所述备份固件。If the first verification result shows that the verification fails, the boot program is made to replace the upgraded firmware stored in the first storage space with the updated firmware according to the backup firmware stored in the second storage space Backup firmware.
  4. 根据权利要求3所述的方法,其特征在于,还包括:The method of claim 3, further comprising:
    若所述第一校验结果显示校验成功,则跳转进入存储于所述第一存储空间的升级后固件。If the first verification result shows that the verification is successful, then jump to the upgraded firmware stored in the first storage space.
  5. 根据权利要求3所述的方法,其特征在于,若所述第一校验结果显示校验成功,则在跳转进入存储于所述第一存储空间的升级后固件之前,上述方法,还包括:The method according to claim 3, wherein if the first verification result shows that the verification is successful, before jumping into the upgraded firmware stored in the first storage space, the method further comprises: :
    使所述引导程序针对存储于所述第二存储空间中的所述固件升级数据设置备用固件标志,以将所述固件升级数据作为备份固件供后续使用。causing the boot program to set a backup firmware flag for the firmware upgrade data stored in the second storage space, so as to use the firmware upgrade data as backup firmware for subsequent use.
  6. 根据权利要求1至5中任一项所述的方法,其特征在于,还包括:The method according to any one of claims 1 to 5, characterized in that, further comprising:
    使所述引导程序对存储于所述第二存储空间中的固件升级数据进行校验,得到第二校验结果;causing the boot program to verify the firmware upgrade data stored in the second storage space to obtain a second verification result;
    若所述第二校验结果显示校验成功,则触发执行使所述引导程序根据 存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级的步骤。If the second verification result shows that the verification is successful, trigger the execution to cause the boot program to update the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space Steps to perform the upgrade.
  7. 根据权利要求6所述的方法,其特征在于,还包括:The method of claim 6, further comprising:
    若所述第二校验结果显示校验失败,则使所述引导程序对存储于所述第一存储空间中的所述固件进行校验,得到第三校验结果;If the second verification result shows that the verification fails, causing the boot program to verify the firmware stored in the first storage space to obtain a third verification result;
    若所述第三校验结果显示校验成功,则跳转进入存储于所述第一存储空间中的所述固件。If the third verification result shows that the verification is successful, jump into the firmware stored in the first storage space.
  8. 根据权利要求7所述的方法,其特征在于,还包括:The method of claim 7, further comprising:
    若所述第三校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的所述固件替换成所述备份固件。If the third verification result shows that verification fails, the boot program will replace the firmware stored in the first storage space with the firmware stored in the second storage space according to the backup firmware stored in the second storage space. Backup firmware.
  9. 根据权利要求1至5中任一项所述的方法,其特征在于,还包括:The method according to any one of claims 1 to 5, characterized in that, further comprising:
    通过所述固件将所述固件升级数据存储于所述第二存储空间之后,通过所述固件更新固件信息区中的更新标志;After the firmware upgrade data is stored in the second storage space by the firmware, the update flag in the firmware information area is updated by the firmware;
    启动所述引导程序后,使所述引导程序判断所述固件信息区中的更新标志是否被更新;After starting the bootstrap program, make the bootstrap program determine whether the update flag in the firmware information area is updated;
    若所述更新标志被更新,则触发执行使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级的步骤。If the update flag is updated, a step of causing the boot program to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space is triggered.
  10. 根据权利要求9所述的方法,其特征在于,还包括:The method of claim 9, further comprising:
    若所述更新标志未被更新,则使所述引导程序对存储于所述第一存储空间中的所述固件进行校验,得到第四校验结果;If the update flag has not been updated, causing the boot program to verify the firmware stored in the first storage space to obtain a fourth verification result;
    若所述第四校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的所述固件替换成所述备份固件。If the fourth verification result shows that the verification fails, the boot program will replace the firmware stored in the first storage space with the firmware stored in the second storage space according to the backup firmware stored in the second storage space. Backup firmware.
  11. 根据权利要求10所述的方法,其特征在于,还包括:The method of claim 10, further comprising:
    若所述第四校验结果显示校验成功,则跳转进入存储于所述第一存储空间中的所述固件。If the fourth verification result shows that the verification is successful, jump into the firmware stored in the first storage space.
  12. 根据权利要求1至5中任一项所述的方法,其特征在于,所述方法适用于智能电池;The method according to any one of claims 1 to 5, wherein the method is suitable for smart batteries;
    所述智能电池包括所述第二存储空间和所述第一存储空间。The smart battery includes the second storage space and the first storage space.
  13. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    存储器,用于存储计算机程序;所述存储器包括第二存储空间和第一存储空间;a memory for storing computer programs; the memory includes a second storage space and a first storage space;
    处理器,用于执行以下操作:A processor that performs the following actions:
    通过存储于第一存储空间中的固件获取固件升级数据,并将所述固件升级数据存储于第二存储空间;Obtain firmware upgrade data through firmware stored in the first storage space, and store the firmware upgrade data in the second storage space;
    启动引导程序;start the bootloader;
    使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级,得到升级后固件。The boot program is made to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space to obtain upgraded firmware.
  14. 根据权利要求13所述的电子设备,其特征在于,所述处理器使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级时,具体用于:The electronic device according to claim 13, wherein the processor causes the boot program to update all the files stored in the first storage space according to firmware upgrade data stored in the second storage space. When upgrading the firmware mentioned above, it is specifically used for:
    使所述引导程序将存储于所述第一存储空间中的所述固件进行擦除;causing the boot program to erase the firmware stored in the first storage space;
    使所述引导程序从所述第二存储空间读取所述固件升级数据,并将读取到的所述固件升级数据写入所述第一存储空间,以得到升级后固件。causing the boot program to read the firmware upgrade data from the second storage space, and write the read firmware upgrade data into the first storage space to obtain upgraded firmware.
  15. 根据权利要求13所述的电子设备,其特征在于,所述处理器,还用于:The electronic device according to claim 13, wherein the processor is further configured to:
    使所述引导程序对存储于所述第一存储空间的升级后固件进行校验,得到第一校验结果;causing the boot program to verify the upgraded firmware stored in the first storage space to obtain a first verification result;
    若所述第一校验结果显示校验成功,则跳转进入存储于所述第一存储空间的升级后固件。If the first verification result shows that the verification is successful, then jump to the upgraded firmware stored in the first storage space.
  16. 根据权利要求15所述的电子设备,其特征在于,所述处理器,还用于:The electronic device according to claim 15, wherein the processor is further configured to:
    若所述第一校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的升级后固件替换成所述备份固件。If the first verification result shows that the verification fails, the boot program is made to replace the upgraded firmware stored in the first storage space with the updated firmware according to the backup firmware stored in the second storage space Backup firmware.
  17. 根据权利要求15所述的电子设备,其特征在于,若所述第一校验结果显示校验成功,则在跳转进入存储于所述第一存储空间的升级后固件之前,所述处理器还用于:The electronic device according to claim 15, wherein if the first verification result shows that the verification is successful, before jumping into the upgraded firmware stored in the first storage space, the processor Also used for:
    使所述引导程序针对存储于所述第二存储空间中的所述固件升级数据 设置备用固件标志,以将所述固件升级数据作为备份固件供后续使用。causing the boot program to set a backup firmware flag for the firmware upgrade data stored in the second storage space, so as to use the firmware upgrade data as backup firmware for subsequent use.
  18. 根据权利要求13至17中任一项所述的电子设备,其特征在于,所述处理器,还用于:The electronic device according to any one of claims 13 to 17, wherein the processor is further configured to:
    使所述引导程序对存储于所述第二存储空间中的固件升级数据进行校验,得到第二校验结果;causing the boot program to verify the firmware upgrade data stored in the second storage space to obtain a second verification result;
    若所述第二校验结果显示校验成功,则触发执行使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级的步骤。If the second verification result shows that the verification is successful, trigger the execution to cause the boot program to update the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space Steps to perform the upgrade.
  19. 根据权利要求18所述的电子设备,其特征在于,所述处理器,还用于:The electronic device according to claim 18, wherein the processor is further configured to:
    若所述第二校验结果显示校验失败,则使所述引导程序对存储于所述第一存储空间中的所述固件进行校验,得到第三校验结果;If the second verification result shows that the verification fails, causing the boot program to verify the firmware stored in the first storage space to obtain a third verification result;
    若所述第三校验结果显示校验成功,则跳转进入存储于所述第一存储空间中的所述固件。If the third verification result shows that the verification is successful, then jump into the firmware stored in the first storage space.
  20. 根据权利要求19所述的电子设备,其特征在于,所述处理器,还用于:The electronic device according to claim 19, wherein the processor is further configured to:
    若所述第三校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的所述固件替换成所述备份固件。If the third verification result shows that verification fails, the boot program will replace the firmware stored in the first storage space with the firmware stored in the second storage space according to the backup firmware stored in the second storage space. Backup firmware.
  21. 根据权利要求13至17中任一项所述的电子设备,其特征在于,所述处理器,还用于:The electronic device according to any one of claims 13 to 17, wherein the processor is further configured to:
    通过所述固件将所述固件升级数据存储于所述第二存储空间之后,通过所述固件更新固件信息区中的更新标志;After the firmware upgrade data is stored in the second storage space by the firmware, the update flag in the firmware information area is updated by the firmware;
    启动所述引导程序后,使所述引导程序判断所述固件信息区中的更新标志是否被更新;After starting the bootstrap program, make the bootstrap program determine whether the update flag in the firmware information area is updated;
    若所述更新标志被更新,则触发执行使所述引导程序根据存储于所述第二存储空间中的固件升级数据,对存储于所述第一存储空间中的所述固件进行升级的步骤。If the update flag is updated, a step of causing the boot program to upgrade the firmware stored in the first storage space according to the firmware upgrade data stored in the second storage space is triggered.
  22. 根据权利要求21所述的电子设备,其特征在于,所述处理器,还用于:The electronic device according to claim 21, wherein the processor is further configured to:
    若所述更新标志未被更新,则使所述引导程序对存储于所述第一存储 空间中的所述固件进行校验,得到第四校验结果;If the update flag is not updated, then make the boot program verify the firmware stored in the first storage space to obtain a fourth verification result;
    若所述第四校验结果显示校验失败,则使所述引导程序根据存储于所述第二存储空间中的备份固件,将存储于所述第一存储空间的所述固件替换成所述备份固件。If the fourth verification result shows that the verification fails, the boot program will replace the firmware stored in the first storage space with the firmware stored in the second storage space according to the backup firmware stored in the second storage space. Backup firmware.
  23. 根据权利要求22所述的电子设备,其特征在于,所述处理器,还用于:The electronic device according to claim 22, wherein the processor is further configured to:
    若所述第四校验结果显示校验成功,则跳转进入存储于所述第一存储空间中的所述固件。If the fourth verification result shows that the verification is successful, jump into the firmware stored in the first storage space.
  24. 根据权利要求13至17中任一项所述的电子设备,其特征在于,所述电子设备为智能电池。The electronic device according to any one of claims 13 to 17, wherein the electronic device is a smart battery.
PCT/CN2020/126732 2020-11-05 2020-11-05 Firmware upgrade method and electronic device WO2022094855A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2020/126732 WO2022094855A1 (en) 2020-11-05 2020-11-05 Firmware upgrade method and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2020/126732 WO2022094855A1 (en) 2020-11-05 2020-11-05 Firmware upgrade method and electronic device

Publications (1)

Publication Number Publication Date
WO2022094855A1 true WO2022094855A1 (en) 2022-05-12

Family

ID=81458402

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/126732 WO2022094855A1 (en) 2020-11-05 2020-11-05 Firmware upgrade method and electronic device

Country Status (1)

Country Link
WO (1) WO2022094855A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114968314A (en) * 2022-08-01 2022-08-30 摩尔线程智能科技(北京)有限责任公司 Firmware upgrading method and device for display equipment, electronic equipment and storage medium
CN116185461A (en) * 2023-04-28 2023-05-30 广东华芯微特集成电路有限公司 Firmware upgrading method and framework
CN116560696A (en) * 2023-06-20 2023-08-08 广东保伦电子股份有限公司 Singlechip partition with high application data duty ratio and firmware upgrading method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050036348A1 (en) * 2003-08-08 2005-02-17 Canon Kabushiki Kaisha Peripheral apparatus, firmware updating method thereof, and program
CN103246536A (en) * 2013-04-28 2013-08-14 常州南京大学高新技术研究院 Method for wirelessly upgrading firmware of instrumented positioning system
CN108804118A (en) * 2018-04-25 2018-11-13 顺丰科技有限公司 Firmware upgrade method, equipment and storage medium
CN109117168A (en) * 2018-08-29 2019-01-01 拓攻(南京)机器人有限公司 Unmanned plane firmware update, device, unmanned plane and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050036348A1 (en) * 2003-08-08 2005-02-17 Canon Kabushiki Kaisha Peripheral apparatus, firmware updating method thereof, and program
CN103246536A (en) * 2013-04-28 2013-08-14 常州南京大学高新技术研究院 Method for wirelessly upgrading firmware of instrumented positioning system
CN108804118A (en) * 2018-04-25 2018-11-13 顺丰科技有限公司 Firmware upgrade method, equipment and storage medium
CN109117168A (en) * 2018-08-29 2019-01-01 拓攻(南京)机器人有限公司 Unmanned plane firmware update, device, unmanned plane and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114968314A (en) * 2022-08-01 2022-08-30 摩尔线程智能科技(北京)有限责任公司 Firmware upgrading method and device for display equipment, electronic equipment and storage medium
CN116185461A (en) * 2023-04-28 2023-05-30 广东华芯微特集成电路有限公司 Firmware upgrading method and framework
CN116560696A (en) * 2023-06-20 2023-08-08 广东保伦电子股份有限公司 Singlechip partition with high application data duty ratio and firmware upgrading method

Similar Documents

Publication Publication Date Title
WO2022094855A1 (en) Firmware upgrade method and electronic device
JP5346253B2 (en) Firmware update system, information device, and program
WO2017067448A1 (en) Firmware-over-the-air upgrade method, system and computer storage medium
JP5113700B2 (en) Firmware update apparatus and method
WO2013103023A1 (en) Information processing device, information processing method, and computer program
CN109062598B (en) Safe OTA (over the air) upgrading method and system
US10303459B2 (en) Electronic system with update control mechanism and method of operation thereof
JP2013520744A (en) Method and apparatus for generating minimum boot image
CN104823160A (en) Virtual machine-preserving host updates
CN103377063A (en) Method and system for recovering unified extensible firmware interface (UEFI) pre-starting environment from legacy operation system environment
US8972964B2 (en) Dynamic firmware updating system for use in translated computing environments
WO2011095074A1 (en) Method for upgrading terminal device system and terminal device
US7620994B2 (en) Data recording system and data access method
WO2012127522A1 (en) Information processing device and method for controlling information processing device
WO2011088701A1 (en) Method and device for online upgrading cross-platform version
CN103186390A (en) Home gateway and software upgrading method thereof
CN107566169A (en) A kind of firmware upgrade method and router based on openwrt
WO2021103745A1 (en) Method for protectively desiging boot program
CN109086078A (en) Android system upgrade method, device, server and mobile terminal
US8856756B2 (en) Simulation control techniques
CN112433769A (en) BMC starting method and device, computer equipment and storage medium
JP2003317387A (en) Information recording apparatus and method for recording information onto recording medium
US9274899B2 (en) Providing non-volatile memory for suspend-to-random access memory
CN116382753A (en) High-reliability remote upgrading method for equipment firmware based on network
CN114035831B (en) CPLD upgrading method, system and computer readable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20960316

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20960316

Country of ref document: EP

Kind code of ref document: A1