Firmware upgrading method and device, equipment and medium

By identifying and switching the activated partition and backup partition of the MCU, the problems of wasted resources and poor reliability of FLASH erecting operation within the MCU are solved, and more efficient firmware upgrades and more reliable OTA status information management are achieved.

CN119536777APending Publication Date: 2025-02-28CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411592852.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-08
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

In the prior art, the ermination operation of FLASH in the MCU is carried out in sectors, resulting in the entire FLASH sector being erased every time the OTA status information occupied 2 bytes is modified, resulting in problems such as wasting resources, slow operation speed, poor reliability and limited life.

Method used

By identifying the activation partition and the backup partition, the second firmware is received using the backup partition, and the switch partition flag is queried through the boot program in the boot partition after the terminal device is reset. When the switch partition flag is the first value, the backup partition is used as the new activation partition, the new activation partition is activated and the second firmware is run.

Benefits of technology

It saves non-volatile storage resources, improves program operation efficiency, improves the reliability of reading and writing OTA status information, and avoids the APP partition startup error or startup failure caused by OTA status information reading errors or inaccessibility of bootloader.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119536777A_ABST
    Figure CN119536777A_ABST
Patent Text Reader

Abstract

The invention discloses a firmware upgrading method which is applied to terminal equipment, a storage area of the terminal equipment comprises a first storage area of nonvolatile storage and a second storage area with a state partition of volatile storage, and the upgrading method comprises the steps that an activation partition and a standby partition are recognized; the second firmware is received through the standby partition, and reset operation is executed on the terminal equipment in a software reset mode; after the terminal equipment is reset, querying the state partition through a bootstrap program in the bootstrap partition to obtain a partition switching mark; taking the standby partition as a new activated partition according to the partition switching mark; activating the new activated partition and running the second firmware; according to the method and the device, the OTA state information is stored in the storage area of the volatile storage, so that non-volatile storage resources are saved, the program running efficiency is improved, the reliability of reading and writing the OTA state information is improved, and the problem that the APP partition is mistakenly started or even fails to be started due to the fact that the OTA state information is read mistakenly or cannot be accessed in Bootloader is effectively avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automotive OTA technology, and in particular to a firmware upgrade method, device, equipment and medium. Background Art

[0002] As the core component of intelligent connected vehicles, the Smart Cockpit Domain Controller (CDC) integrates the functions of multiple cockpit subsystem electronic control units (ECUs), including entertainment, navigation, air conditioning, seat adjustment, and vehicle driving control.

[0003] CDC adopts the hardware architecture of System On Chip (SOC) plus Microcontroller Unit (MCU). SOC is responsible for running complex operating systems and processing image, video, audio and other data. MCU is responsible for CAN signal analysis, fault diagnosis, power management logic processing, etc.

[0004] Remote upgrade (Over the Air, OTA) is the basic function of CDC. SOC obtains the upgrade firmware compressed package from the OTA platform through the 4G communication module, and decompresses it to obtain the upgrade firmware of SOC and MCU. Figure 1 As shown, the SOC sends the upgrade firmware of the MCU to the MCU through the serial peripheral interface (SPI) between the MCU and the MCU, and the MCU writes the upgrade firmware into the corresponding FLASH space after receiving it.

[0005] However, the OTA status information is placed in the MCU's internal FLASH. The erase and write operations of the MCU's internal FLASH are usually performed in sectors, and a sector is generally 4K or 8K. Each time the OTA status information that occupies 2 bytes is modified, the entire FLASH sector needs to be erased and written. This sector cannot store other codes or data, resulting in a waste of FLASH resources. Summary of the invention

[0006] In view of the above-mentioned shortcomings of the prior art, the present application provides a firmware upgrade method, device, equipment and medium to solve at least one defect in the prior art.

[0007] To achieve the above purpose and other purposes, the present application provides a firmware upgrade method, which is applied to a terminal device, wherein the storage area of ​​the terminal device includes a first storage area of ​​non-volatile storage, a second storage area of ​​volatile storage, and a boot partition storing a boot program, the first storage area includes a first partition, a second partition and a boot partition, and the second storage area includes a status partition storing a switching partition flag; the method includes:

[0008] Identify an active partition and a standby partition, wherein the standby partition is one of the first partition and the second partition, and the active partition is the other of the first partition and the second partition; a first firmware is running in the active partition;

[0009] receiving a second firmware through the spare partition, wherein the version number of the second firmware is higher than the version number of the first firmware;

[0010] Reset the terminal device using software reset;

[0011] After the terminal device is reset, querying the status partition through the boot program in the boot partition to obtain a switch partition flag;

[0012] When the value of the switch partition flag is the first value, taking the standby partition as a new active partition;

[0013] Activate the new active partition and run the second firmware.

[0014] In one embodiment of the present application, the step of identifying the active partition and the standby partition includes:

[0015] Obtaining a storage address of the first firmware;

[0016] The active partition and the standby partition are determined based on the storage address.

[0017] In one embodiment of the present application, the step of receiving the second firmware through the spare partition includes:

[0018] Multiple upgrade packages split from the upgrade firmware are sequentially flashed to the spaces at corresponding addresses in the second partition.

[0019] In one embodiment of the present application, after receiving multiple upgrades, the method further includes verifying the multiple upgrade packages, including:

[0020] Performing integrity checks on the multiple upgrade packages in sequence;

[0021] When the integrity checks of the multiple upgrade packages all pass, the integrity check of the second firmware passes;

[0022] When the integrity check of any one of the multiple upgrade packages fails, the integrity check of the second firmware fails.

[0023] In one embodiment of the present application, the step of sequentially performing integrity checks on the multiple upgrade packages includes:

[0024] Calculating a CRC value of the upgrade package, and comparing the calculated CRC value with a preset CRC value to perform an integrity check on the upgrade package;

[0025] When the calculated CRC value is consistent with the preset CRC value, it is determined that the upgrade package passes the integrity check;

[0026] When the calculated CRC value is inconsistent with the preset CRC value, it is determined that the upgrade package fails the integrity check.

[0027] In one embodiment of the present application, the method further includes:

[0028] After the second firmware is successfully written to the second partition, setting the value of the switch partition flag to a first value;

[0029] The activation status partition flag corresponding to the activation partition is written into the status partition.

[0030] In one embodiment of the present application, after the second firmware is started, the method further includes:

[0031] Deactivating the first partition;

[0032] Switching the value of the switch partition flag in the state partition from a first value to a second value to update the switch partition flag;

[0033] Update the active partition flag.

[0034] To achieve the above-mentioned purpose and other related purposes, the present application provides a firmware upgrade device, characterized in that it is applied to a terminal device, the storage area of ​​the terminal device includes a first storage area of ​​non-volatile storage and a second storage area of ​​volatile storage, the first storage area includes a first partition, a second partition, and a boot partition storing a boot program, and the second storage area includes a status partition storing a switch partition flag; the method includes:

[0035] an identification module, used for identifying an active partition and a standby partition, wherein the standby partition is one of the first partition and the second partition, and the active partition is the other of the first partition and the second partition; and a first firmware is running in the active partition;

[0036] A receiving module, configured to receive a second firmware through a standby partition, wherein a version number of the second firmware is higher than a version number of the first firmware;

[0037] A reset module is used to perform a reset operation on the terminal device by using software reset;

[0038] A query module, used for querying the status partition through the boot program in the boot partition after the terminal device is reset to obtain an activation partition flag and a switch partition flag;

[0039] A switching module, configured to use the standby partition as a new active partition when the value of the switching partition flag is a first value;

[0040] The activation module is used to activate the new activation partition and run the second firmware.

[0041] To achieve the above objectives and other related objectives, the present application provides a firmware upgrade device, including:

[0042] one or more processors; and

[0043] The memory is used to store one or more programs. When the one or more programs are executed by the one or more processors, the memory implements the firmware upgrade method.

[0044] To achieve the above objectives and other related objectives, the present application provides one or more machine-readable media on which instructions are stored, which, when executed by one or more processors, enable the processors to execute the firmware upgrade method.

[0045] Beneficial effects of this application:

[0046] A firmware upgrade method of the present application is applied to a terminal device, wherein the storage area of ​​the terminal device includes a first storage area of ​​non-volatile storage, a second storage area of ​​volatile storage and a boot partition, the first storage area includes a first partition, a second partition, and a boot partition storing a boot program, and the second storage area includes a status partition storing a switch partition flag; the method includes: identifying an active partition and a standby partition, the standby partition is one of the first partition and the second partition, and the active partition is the other of the first partition and the second partition; a first firmware is running in the active partition; a second firmware is received through the standby partition, and the version number of the second firmware is higher than the version number of the first firmware; a reset operation is performed on the terminal device by means of software reset; after the terminal device is reset, the status partition is queried through the boot program in the boot partition to obtain a switch partition flag; when the value of the switch partition flag is a first value, the standby partition is used as a new active partition; the new active partition is activated and the second firmware is run. In response to the shortcomings of storing OTA status information in non-volatile storage, the present application proposes a solution to store OTA status information in volatile storage, which saves non-volatile storage resources, improves program running efficiency, and improves the reliability of reading and writing OTA status information, and effectively avoids the problem of APP partition startup errors or even startup failures due to OTA status information reading errors or inaccessibility in the boot program Bootloader.

[0047] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0049] Figure 1 This is the CDC OTA link block diagram;

[0050] Figure 2 This is a schematic diagram of the internal FLASH allocation of the MCU in the non-sensing OTA solution;

[0051] Figure 3 This is the startup flow chart of the senseless OTA solution after firmware update;

[0052] Figure 4 A schematic diagram of MCU internal resource allocation according to an embodiment of the present application;

[0053] Figure 5 This is a flowchart of a firmware upgrade method according to an embodiment of the present application;

[0054] Figure 6 This is a flowchart of starting after firmware update according to an embodiment of the present application;

[0055] Figure 7 This is a principle block diagram of a firmware upgrade device according to an embodiment of the present application;

[0056] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing the memory of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0057] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.

[0058] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application, and thus the drawings only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed at will, and the component layout may also be more complicated.

[0059] Although the terms "first", "second", "A", and "B", etc. may be used herein to describe various elements, these elements should not be limited by these terms and are only used to distinguish one element from another. For example, a first element may be referred to as a second element, and similarly, a second element may be referred to as a first element without departing from the scope of the following technology. The term "and / or" includes a combination of multiple related items or any of the multiple related items.

[0060] As used herein, unless the context indicates otherwise, the singular form is intended to include the plural form, and it will be understood that the term "comprising" means the presence of stated features, quantities, steps, operations, elements, or combinations thereof, but does not exclude the presence or addition of one or more other features, quantities, steps, operations, elements, components, or combinations thereof.

[0061] Before the detailed description, it is intended to clarify that the division of components in this specification is divided only by the main function of each component. That is, two or more components to be described below can be combined into one component, or can be divided into two or more components according to more detailed functions. In addition to the main function of the component, each component to be described below can also perform some or all of the functions of other components, and some of the main functions of each component can be exclusively performed by other components.

[0062] Remote upgrade (Over the Air, OTA) is the basic function of CDC. SOC obtains the upgrade firmware compression package from the OTA platform through the 4G communication module, and decompresses it to obtain the upgrade firmware of SOC and MCU. SOC sends the upgrade firmware of MCU to MCU through the serial peripheral interface (Serial Peripheral Interface, SPI) between SOC and MCU. After receiving the upgrade firmware, MCU writes it into the corresponding FLASH space. Figure 1 shown.

[0063] As automobile manufacturers further improve their requirements for software reliability and user experience, MCUs on CDCs generally adopt dual-partition non-sensing OTA solutions. Figure 2 As shown, Figure 2 This is a diagram of the MCU internal FLASH allocation for the non-sensing OTA solution. In the non-sensing OTA solution, the MCU internal FLASH is generally divided into the bootloader area (Bootloader), application A partition (APP_A), application B partition (APP_B), and OTA status area (Status).

[0064] See also Figure 3 , Figure 3 This is the startup flow chart of the non-sense OTA solution firmware update. The non-sense OTA solution firmware update and startup process is as follows:

[0065] Step 1: In the APP initialization program, read the FLASH address of the main function. If the main function address is in the FLASH address segment of partition A, the partition currently running on the MCU is determined to be partition A; if the main function address is in the FLASH address segment of partition B, the partition currently running on the MCU is determined to be partition B. The partition currently running on the MCU is used as the active partition, and the other partition is used as the standby partition;

[0066] Step 2: After receiving the firmware upgrade request from MCU, SOC initiates an upgrade request to MCU; MCU activates the APP program of the partition, and after receiving the upgrade request from SOC, determines whether the upgrade conditions are met. If the upgrade conditions are met, it replies a positive response to SOC;

[0067] Step 3: After receiving the positive response, the SOC splits the upgraded firmware into multiple data packets and sends them to the MCU. After receiving the data packets, the MCU writes them into the corresponding spare partitions. After each data packet is written, it replies to the SOC that the data packet is written successfully. After receiving the reply of successful writing, the SOC continues to send the next data packet;

[0068] Step 4: After all upgrade data packets are successfully flashed, the MCU sets the switch partition flag to 1, and writes it to the status area Status together with the activation partition flag (A or B), notifying the SOC that the upgrade is successful, and the SOC sends a reset command to the MCU;

[0069] Step 5: After receiving the reset command, the MCU performs a software reset. After the MCU is reset and restarted, the bootloader is first run. If the bootloader finds that the switch partition flag in the status area is 1, it will use the backup partition that was originally flashed with the upgraded firmware as the new active partition according to the activation partition signal, and then jump to the new activation partition to run the APP program. Then, in the APP initialization program, the switch partition flag in the Status area is set to 0, and the activation partition flag is updated.

[0070] However, managing OTA status information in the MCU's internal FLASH has the following disadvantages:

[0071] 1. Waste of resources. The erase and write operations of the FLASH inside the MCU are usually performed in sectors, and a sector is generally 4K or 8K. Each time the OTA status information that occupies 2 bytes is modified, the entire FLASH sector needs to be erased. This sector cannot store other codes or data, resulting in a waste of FLASH resources. 2. Slow operation speed. The FLASH is erased and written in sectors, and for functional safety reasons, the sector needs to be unlocked before erasing, and error checking and correction (ECC) is required after writing, which affects the CPU's scheduling of other tasks. 3. Poor reliability. Since the erase and write speed of FLASH is relatively slow, if the power supply voltage is abnormal during the erase process, or the erase is interrupted by a software interrupt, the OTA status information data stored in the FLASH may be erroneous or inaccessible, causing the MCU to start the wrong APP partition or even fail to start. 4. Limited lifespan. The erase and write lifespan of the FLASH sector is generally 100,000 times, and its lifespan is affected by the number of reads and writes.

[0072] Based on the above defects, an embodiment of the present application provides a firmware upgrade method. The firmware upgrade method is applied to a terminal device, see Figure 4 , Figure 4The terminal device includes an MCU, and the MCU includes a first storage area, a second storage area, and a boot partition storing a boot program. The first storage area is a non-volatile storage area, and the second storage area is a volatile storage area. The non-volatile storage area includes: ROM (Read-only memory), PROM (Programmable read-only memory), EAROM (Electrically alterable read only memory), EPROM (Erasable programmable read only memory), EEPROM (Electrically erasable programmable read only memory), Flash memory; the volatile storage area includes: RAM (Random Access Memory). In some embodiments, the non-volatile storage area is FLASH.

[0073] See also Figure 5 , Figure 5 This is a flowchart of a firmware upgrade method according to an embodiment of the present application. Figure 5 The startup methods include:

[0074] Step S510, identifying an active partition and a standby partition, wherein the standby partition is one of the first partition and the second partition, and the active partition is the other of the first partition and the second partition; the first firmware is running in the active partition;

[0075] In one embodiment, the step of identifying the active partition and the standby partition includes: obtaining a storage address of the first firmware; and determining the active partition and the standby partition according to the storage address.

[0076] Suppose that the first storage area is divided into a first partition and a second partition in advance, the first partition is partition A, and the second partition is partition B. The current running area of ​​the first firmware in the MCU can be determined by reading the FLASH address of the main function of the first firmware. For example, if the main function address is in the FLASH address segment of partition A, then the current running area of ​​the MCU is judged to be partition A; if the main function address is in the FLASH address segment of partition B, then the current running area of ​​the MCU is judged to be partition B. At this time, the partition currently running in the MCU can be used as the active partition, and the other partition can be used as the standby partition, that is, the first partition can be used as the active partition, and the second partition can be used as the standby partition. At this time, an activation partition flag can be set for the active partition, such as flag A; and a standby partition flag can be set for the standby partition, such as flag B.

[0077] Step S520, receiving a second firmware through the spare partition, wherein the version number of the second firmware is higher than the version number of the first firmware;

[0078] After receiving the MCU upgrade firmware sent by the OTA platform, the SOC initiates an upgrade request to the MCU. After receiving the upgrade request sent by the SOC, the MCU determines whether the upgrade conditions are met. If the upgrade conditions are met, it replies to the SOC with a positive response. After receiving the positive response, the SOC writes the upgrade firmware to the corresponding backup partition, and receives the second firmware through the backup partition. The version number of the second firmware is higher than the version number of the first firmware.

[0079] In one embodiment, the step of receiving the second firmware through the spare partition includes: sequentially flashing multiple upgrade packages split from the upgrade firmware to the spaces at corresponding addresses in the second partition.

[0080] After receiving the affirmative response, the SOC splits the upgraded firmware into multiple upgrade packages and sends them to the MCU. After receiving the data packet, the MCU writes it into the corresponding spare partition FLASH address. After each packet of data is written, it replies to the SOC that the upgrade package is written successfully. After receiving the write success reply, the SOC continues to send the next upgrade package until all upgrades are flashed.

[0081] In one embodiment, after receiving the multiple upgrades, the method further includes verifying the multiple upgrade packages, including:

[0082] Integrity checks are performed on multiple upgrade packages in sequence; when the integrity checks of multiple upgrade packages all pass, the integrity check of the second firmware passes; when the integrity check of any one of the multiple upgrade packages fails, the integrity check of the second firmware fails.

[0083] In one embodiment, the step of sequentially performing integrity checks on multiple upgrade packages includes:

[0084] Calculate the CRC value of the upgrade package, and compare the calculated CRC value with the preset CRC value to perform an integrity check on the upgrade package; when the calculated CRC value is consistent with the preset CRC value, determine that the upgrade package has passed the integrity check; when the calculated CRC value is inconsistent with the preset CRC value, determine that the upgrade package has not passed the integrity check.

[0085] As an example, the integrity check of the upgrade package can be performed using a CRC (Cyclic Redundancy Check) check method. For example, the CRC32 algorithm is used for verification. Usually, when the OTA application downloads the new upgrade firmware to the second partition, in order to improve the data transmission efficiency, the second firmware will be split into multiple upgrade packages, and then the second firmware will be sent to the MCU in the form of an upgrade package, wherein each upgrade package is protected by a CRC32 value. When performing the integrity check, the CRC32 algorithm is calculated for each upgrade package and compared with the preset CRC value. If they are consistent, it is determined that the upgrade package passes the integrity check. If they are inconsistent, it is determined that the upgrade package fails to pass the integrity check. After the second firmware is flashed, for all upgrade packages flashed to the second partition, if all upgrade packages pass the integrity check, it is determined that the second firmware passes the integrity check. If there is any upgrade package that fails the integrity check, it is determined that the second firmware fails the integrity check.

[0086] In some embodiments, it also includes:

[0087] After the second firmware is successfully flashed to the second partition, the value of the switch partition flag is set to the first value;

[0088] The activation status partition flag corresponding to the activation partition is written into the status partition.

[0089] As an example, the value of the switch partition flag includes a first value and a second value. When the value of the switch partition flag is the first value, the standby partition needs to be switched to a new active partition, that is, the standby partition needs to be activated; when the value of the switch partition flag is the second value, the standby partition does not need to be switched to a new active partition, that is, the standby partition does not need to be activated. The first value can be represented by "1" and the second value can be represented by "0", that is, when the switch partition flag is queried to be "1", the standby partition needs to be used as a new active partition. If the switch partition flag is queried to be "0", the standby partition does not need to be used as a new active partition. That is, after the second firmware is successfully flashed to the second partition, since the version number of the second firmware is higher than the version number of the first firmware, it can be determined that the MCU needs to be upgraded. At this time, in order to run the second firmware, the standby partition is used as a new active partition, and the value of the switch partition flag is set to the first value.

[0090] As an example, when an active partition is identified between the first partition and the second partition, an active partition flag may be set for the active partition, and the active partition may be identified based on the active partition flag. At this time, flag A may be set for the active partition, and flag B may be set for the standby partition. In the subsequent upgrade process, the active partition and the standby partition may be identified based on the flags.

[0091] Step S530, performing a reset operation on the terminal device by using software reset;

[0092] The reset methods of MCU can be divided into two categories: software reset and hardware reset.

[0093] Software reset: It is realized by controlling the MCU reset register, and the reset process does not cut off the power.

[0094] Hardware reset: The most common way is to power on the MCU again, which is called Power On Reset (POR).

[0095] The MCU is restarted through software reset. During the whole process, the MCU will not lose power and the data in the RAM will not be lost.

[0096] Step S540, after the terminal device is reset, query the status partition through the boot program in the boot partition to obtain the switch partition flag;

[0097] After the MCU is reset, it does not directly enter the bootloader. Taking the Arm Cortex-M7 core as an example, the complete process from MCU reset to running the Bootloader is as follows:

[0098] Step 1: Enter the reset entry function Reset_Handler.

[0099] Step 2: Turn off CPU global interrupts and clear CPU general registers.

[0100] Step 2: Enable the clock, relocate the interrupt vector table, and initialize the CPU stack pointer.

[0101] Step 3: Disable the watchdog and complete RAM, ECC, and system initialization.

[0102] Step 4: Enter the main function of Bootloader.

[0103] During the RAM initialization phase, all RAM data will be cleared by default. If there is no special requirement, the user can directly use the official startup code. However, in some embodiments, it is required that the RAM data in the Status area cannot be cleared after the MCU software is reset, so the startup code needs to be actively modified. The modification method is as follows:

[0104] Step 1: In the link file, allocate a RAM space for the Status area, called Status_RAM, with a size of 64 bytes. Actually use 2 bytes, and the remaining 62 bytes are reserved.

[0105] Step 2: In the RAM initialization function of the startup code, first read the MCU reset status register to determine the MCU reset reason. If the reset reason is a power-on reset, all RAM data will be cleared. If the reset reason is a software reset, the Status_RAM data will be retained and the rest of the RAM data will be cleared.

[0106] After the terminal device is reset by software reset, the bootloader in the boot partition is run to query the status partition, so as to obtain the switch partition flag stored in the boot partition. The switch partition flag is used to indicate whether to switch the standby partition to the active partition.

[0107] Step S550, when the value of the switch partition flag is the first value, the standby partition is used as a new active partition;

[0108] Step S560: activating the new active partition and running the second firmware.

[0109] In some embodiments, after the second firmware is started, the method further includes:

[0110] Deactivating the first partition;

[0111] Switching the value of the switch partition flag in the status partition from the first value to the second value to update the switch partition flag;

[0112] Update the active partition flag.

[0113] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0114] In order to help understand the technical concept of the present application, a specific embodiment is listed to illustrate the firmware upgrade method of the present application:

[0115] Step 1: In the APP initialization program, read the FLASH address of the main function. If the main function address is in the FLASH address segment of partition A, it is determined that the MCU is currently running in partition A. If the main function address is in the FLASH address segment of partition B, it is determined that the MCU is currently running in partition B. The partition currently running on the MCU is used as the active partition, and the other partition is used as the standby partition;

[0116] Step 2: After receiving the MCU upgrade firmware sent by the OTA platform, the SOC initiates an upgrade request to the MCU; the MCU activates the partitioned APP program, and after receiving the upgrade request sent by the SOC, it determines whether the upgrade conditions are met. If the upgrade conditions are met, it replies to the SOC with a positive response;

[0117] Step 3: After receiving the positive response, SOC splits the upgrade firmware into multiple upgrade packages and sends them to MCU. After receiving the data packet, MCU writes it into the corresponding spare partition FLASH address. After each data packet is written, it replies to SOC that the data packet is written successfully. After receiving the reply of successful writing, SOC continues to send the next data packet.

[0118] Step 4: After all upgrade data packets are successfully written, the MCU sets the switch partition flag to 1 and writes it to the Status area together with the activation partition signal (A or B) to notify the SOC that the upgrade is successful. The SOC sends a reset command to the MCU.

[0119] Step 5: In the RAM initialization function of the startup code, first read the MCU reset status register to determine the MCU reset reason. If the reset reason is a power-on reset, all RAM data will be cleared. If the reset reason is a software reset, the Status_RAM data will be retained and the rest of the RAM data will be cleared.

[0120] Step 6: The MCU enters the Bootloader program. If the partition switching flag in the Status_RAM area is queried in the Bootloader, determine whether the partition switching flag is 1; if it is 1, determine whether the original active partition is partition A. If the original active partition is partition A, then use the backup partition that has been flashed with various levels of firmware as the new active partition, and jump to the new active partition to run the APP program. If the original active partition does not have an A partition, it can be determined to be a B partition, then jump to the APP_A partition, and update the Status_RAM data. If the partition switching flag is 0, determine whether the active partition is partition A. If it is partition A, jump to the APP_A partition and update the Status_RAM data; if the active partition is not partition A, jump to the APP_B partition to update the Status_RAM data. Among them, the fifth and sixth steps start the process of the factors as follows: Figure 6 shown.

[0121] In summary, in response to the shortcomings of storing OTA status information in non-volatile storage, this application proposes a solution to store OTA status information in volatile storage, which saves non-volatile storage resources, improves program running efficiency, and improves the reliability of reading and writing OTA status information, effectively avoiding the problem of APP partition startup errors or even startup failures due to OTA status information reading errors or inaccessibility in the Bootloader.

[0122] Figure 7 is a block diagram of a firmware upgrade device shown in an embodiment of the present application. The device can be applied to Figure 1The device can also be applied to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the device is applied.

[0123] like Figure 7 As shown, a firmware upgrade device is applied to a terminal device, wherein the storage area of ​​the terminal device includes a first storage area of ​​non-volatile storage and a second storage area of ​​volatile storage, the first storage area includes a first partition, a second partition, and a boot partition storing a boot program, and the second storage area includes a status partition storing a switch partition flag; the method includes:

[0124] An identification module 710 is used to identify an active partition and a standby partition, wherein the standby partition is one of the first partition and the second partition, and the active partition is the other of the first partition and the second partition; the first firmware runs in the active partition;

[0125] The receiving module 720 is used to receive the second firmware through the spare partition, and the version number of the second firmware is higher than the version number of the first firmware;

[0126] The reset module 730 is used to perform a reset operation on the terminal device by using software reset;

[0127] A query module 740, configured to query the status partition through the boot program in the boot partition after the terminal device is reset to obtain an activation partition flag and a switch partition flag;

[0128] A switching module 750, configured to use the standby partition as a new active partition when the value of the switch partition flag is a first value;

[0129] The activation module 760 is used to activate the new activation partition and run the second firmware.

[0130] It should be noted that the firmware upgrade device provided in the above embodiment and the firmware upgrade method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In actual application, the firmware upgrade device provided in the above embodiment can allocate the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0131] An embodiment of the present application also provides a device, including: one or more processors; and a memory for storing one or more programs, when the one or more programs are executed by one or more processors, the memory implements the firmware upgrade method in the above embodiment.

[0132] The embodiments of the present application also provide one or more machine-readable media on which instructions are stored, which, when executed by one or more processors, enable the processors to execute the firmware upgrade method in the above embodiments.

[0133] Figure 8 The schematic diagram of the structure of a computer system suitable for implementing the memory of the embodiment of the present application is shown. It should be noted that: Figure 8 The computer system of the memory shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0134] like Figure 8 As shown, the computer system includes a central processing unit (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) or the program loaded from the storage part to the random access memory (RAM), such as the method in the above embodiment. In the RAM, various programs and data required for system operation are also stored. The CPU, ROM and RAM are connected to each other through a bus. The input / output (I / O) interface is also connected to the bus.

[0135] The following components are connected to the I / O interface: an input part including a keyboard, a mouse, etc.; an output part including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage part including a hard disk, etc.; and a communication part including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication part performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface as needed. Removable media, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., are installed on the drive as needed so that a computer program read therefrom is installed into the storage part as needed.

[0136] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the firmware upgrade method of the aforementioned implementation. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), various functions defined in the system of the present application are executed.

[0137] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0138] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0139] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0140] Another aspect of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor of a computer, the computer executes the firmware upgrade method as described above. The computer-readable storage medium may be included in the memory described in the above embodiment, or may exist independently without being assembled into the memory.

[0141] Another aspect of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the firmware upgrade method provided in each of the above embodiments.

[0142] The above embodiments are merely illustrative of the principles and effects of the present application, and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.

Claims

1. A firmware upgrade method, characterized in that: Applied to a terminal device, the storage area of ​​the terminal device includes a first storage area of ​​non-volatile storage and a second storage area of ​​volatile storage, the first storage area includes a first partition, a second partition, and a boot partition storing a boot program, and the second storage area includes a status partition storing a switch partition flag; the method includes: Identify an active partition and a standby partition, wherein the standby partition is one of the first partition and the second partition, and the active partition is the other of the first partition and the second partition; a first firmware is running in the active partition; receiving a second firmware through the spare partition, wherein the version number of the second firmware is higher than the version number of the first firmware; Reset the terminal device using software reset; After the terminal device is reset, querying the status partition through the boot program in the boot partition to obtain a switch partition flag; When the value of the switch partition flag is the first value, taking the standby partition as a new active partition; Activate the new active partition and run the second firmware.

2. The firmware upgrade method according to claim 1, characterized in that: The step of identifying the active partition and the standby partition comprises: Obtaining a storage address of the first firmware; The active partition and the standby partition are determined according to the storage address.

3. The firmware upgrade method according to claim 1, characterized in that: The step of receiving the second firmware through the spare partition comprises: Multiple upgrade packages split from the upgrade firmware are sequentially flashed to the spaces at corresponding addresses in the second partition.

4. The firmware upgrade method according to claim 3, characterized in that: After receiving the multiple upgrades, the method further includes verifying the multiple upgrade packages, including: Performing integrity checks on the multiple upgrade packages in sequence; When the integrity checks of the multiple upgrade packages all pass, the integrity check of the second firmware passes; When the integrity check of any one of the multiple upgrade packages fails, the integrity check of the second firmware fails.

5. The firmware upgrade method according to claim 4, characterized in that: The step of sequentially performing integrity checks on the multiple upgrade packages includes: Calculating a CRC value of the upgrade package, and comparing the calculated CRC value with a preset CRC value to perform an integrity check on the upgrade package; When the calculated CRC value is consistent with the preset CRC value, it is determined that the upgrade package passes the integrity check; When the calculated CRC value is inconsistent with the preset CRC value, it is determined that the upgrade package fails the integrity check.

6. The firmware upgrade method according to claim 1, characterized in that: The method further comprises: After the second firmware is successfully written to the second partition, setting the value of the switch partition flag to a first value; The activation status partition flag corresponding to the activation partition is written into the status partition.

7. The firmware upgrade method according to claim 6, characterized in that: After the second firmware is started, the method further includes: Deactivating the first partition; Switching the value of the switch partition flag in the state partition from a first value to a second value to update the switch partition flag; Update the active partition flag.

8. A firmware upgrade device, characterized in that: Applied to a terminal device, the storage area of ​​the terminal device includes a first storage area of ​​non-volatile storage and a second storage area of ​​volatile storage, the first storage area includes a first partition, a second partition, and a boot partition storing a boot program, and the second storage area includes a status partition storing a switch partition flag; the method includes: an identification module, used for identifying an active partition and a standby partition, wherein the standby partition is one of the first partition and the second partition, and the active partition is the other of the first partition and the second partition; and a first firmware is running in the active partition; A receiving module, configured to receive a second firmware through a standby partition, wherein a version number of the second firmware is higher than a version number of the first firmware; A reset module is used to perform a reset operation on the terminal device by using software reset; A query module, used for querying the status partition through the boot program in the boot partition after the terminal device is reset to obtain an activation partition flag and a switch partition flag; A switching module, configured to use the standby partition as a new active partition when the value of the switching partition flag is a first value; The activation module is used to activate the new activation partition and run the second firmware.

9. A firmware upgrade device, characterized in that: include: one or more processors; and A memory, used to store one or more programs, when the one or more programs are executed by the one or more processors, the memory implements the firmware upgrade method according to any one of claims 1 to 7.

10. A machine-readable medium, characterized in that Instructions are stored thereon, which, when executed by one or more processors, enable the processors to execute the firmware upgrade method as described in any one of claims 1-7.

Citation Information

Cited By

  • Three-partition over-the-air downloading upgrading method and upgrading system based on non-SWAP AB technology

    CN121349496A