CN117931251A - Firmware online upgrading method and device, electronic equipment, storage medium and product - Google Patents
Firmware online upgrading method and device, electronic equipment, storage medium and product Download PDFInfo
- Publication number
- CN117931251A CN117931251A CN202410131409.0A CN202410131409A CN117931251A CN 117931251 A CN117931251 A CN 117931251A CN 202410131409 A CN202410131409 A CN 202410131409A CN 117931251 A CN117931251 A CN 117931251A
- Authority
- CN
- China
- Prior art keywords
- partition
- address information
- system partition
- value
- storage area
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 53
- 238000005192 partition Methods 0.000 claims abstract description 478
- 230000008569 process Effects 0.000 claims abstract description 13
- 230000006870 function Effects 0.000 claims description 75
- 238000004590 computer program Methods 0.000 claims description 16
- 238000004364 calculation method Methods 0.000 claims description 13
- 230000004044 response Effects 0.000 claims description 8
- 239000011449 brick Substances 0.000 abstract description 6
- 238000013500 data storage Methods 0.000 description 14
- 238000013507 mapping Methods 0.000 description 10
- 238000010586 diagram Methods 0.000 description 7
- 238000007726 management method Methods 0.000 description 6
- 238000012545 processing Methods 0.000 description 6
- 230000006854 communication Effects 0.000 description 5
- 230000007246 mechanism Effects 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 3
- 230000008859 change Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 3
- 238000004458 analytical method Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 238000013475 authorization Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013524 data verification Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000006855 networking Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
- G06F8/654—Updates using techniques specially adapted for alterable solid state memories, e.g. for EEPROM or flash memories
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0238—Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
- G06F12/0246—Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
The application provides a firmware online upgrading method, a device, electronic equipment, a storage medium and a product, and belongs to the technical field of Internet of things. The method comprises the following steps: in the process of executing the first system partition, when the first firmware image file is determined to be required to be updated, writing the second firmware image file into the second system partition, and writing second address information of the second system partition into the first register; configuring a partition exchange identifier in a second register as a first numerical value, and writing the first numerical value of the partition exchange identifier into a second storage area; after restarting the electronic equipment, when the partition exchange identifier in the first storage area is queried to be a first numerical value, reading second address information mapped by the first address information in the first storage area from a first register; based on the second address information, a second firmware image in the second system partition is executed. The application can reduce the management cost when the firmware is updated on line, avoid the error selection of the system partition and effectively prevent the equipment from changing bricks.
Description
Technical Field
The application relates to the technical field of the internet of things, in particular to a firmware online upgrading method, a device, electronic equipment, a storage medium and a product.
Background
In the technical field of the internet of things, the system is formed by networking thousands of ECU (Electronic Control Unit ) devices. For The ECU equipment, in The life cycle, a Firmware On-The-Air (FOTA) upgrading mechanism is used for upgrading The Firmware image file, so that The security problem of system loopholes can be solved or new system characteristics can be supported. The firmware image file of the ECU equipment runs on the FLASH, the upgrading time and place are uncertain, even the network condition is possibly poor, and high requirements are put forward on the firmware on-line method of the ECU equipment.
In the related art, a system partition B having the same size as the system partition a is allocated in advance, a firmware image file to be upgraded is written into the system partition B, a partition selection identifier is set as an identifier of the system partition B, and then the electronic device is restarted. After restarting the electronic equipment, the bootstrap program reads the identification of the partition selection identification as the system partition B, acquires the address of the system partition B according to the identification of the system partition B, and further executes the firmware image file in the system partition B according to the address of the system partition B so as to complete the online firmware upgrade.
However, before upgrading the firmware image file, the partition selection identifier and the address of the system partition corresponding to the partition selection identifier need to be stored for the time, so that the management cost is high, errors are easy to occur, and once the errors occur, the equipment changes bricks.
Disclosure of Invention
The embodiment of the application provides a firmware online upgrading method, a device, electronic equipment, a storage medium and a product, which can reduce the management cost during online firmware upgrading, avoid system partition selection errors and effectively prevent equipment from changing bricks. The technical scheme is as follows:
in a first aspect, a firmware online upgrade method is provided, the method including:
In the process of executing the first system partition, when it is determined that the first firmware image file needs to be upgraded, writing a second firmware image file into the second system partition, and writing second address information of the second system partition into a first register, wherein the second firmware image file is an upgrade version of the first firmware image file, the first system partition and the second system partition are two system partitions with different address information, and the first register is used for storing actual address information mapped by the first address information of the first system partition in a first storage area;
Configuring a partition exchange identifier in a second register as a first value, and writing the first value of the partition exchange identifier into a second storage area, wherein the second register is used for configuring the value of a partition exchange related identifier, the first value is used for indicating that a partition exchange function is started, and the partition exchange function is a function of reading second address information mapped by first address information in the first storage area from the first register;
restarting the electronic equipment, and after restarting the electronic equipment, inquiring the numerical value of the partition exchange identifier in the first storage area;
When the partition exchange identifier is inquired to be a first numerical value, reading the second address information mapped by the first address information in the first storage area from the first register;
And executing the second firmware image file in the second system partition based on the second address information.
In a second aspect, there is provided an online firmware upgrade apparatus, the apparatus comprising:
The first writing module is used for writing a second firmware image file into a second system partition when the first firmware image file is determined to be updated in the process of executing the first system partition, wherein the second firmware image file is an updated version of the first firmware image file, and the first system partition and the second system partition are two system partitions with different address information;
The second writing module is used for writing second address information of the second system partition into a first register, and the first register is used for storing actual address information mapped by first address information of the first system partition in the first storage area;
The first configuration module is used for configuring the partition exchange identifier in the second register as a first value, the second register is used for configuring the value of the partition exchange related identifier, the first value is used for indicating that a partition exchange function is started, and the partition exchange function is a function of reading the second address information mapped by the first address information in the first storage area from the first register;
A third writing module for writing the first value of the partition exchange identifier into the second storage area
The first restarting module is used for restarting the electronic equipment;
The inquiring module is used for inquiring the numerical value of the partition exchange identifier in the first storage area after the electronic equipment is restarted;
a first reading module, configured to read, when it is queried that the partition exchange identifier is a first value, the second address information mapped by the first address information in the first storage area from the first register;
And the first execution module is used for executing the second firmware image file in the second system partition based on the second address information.
In a third aspect, an electronic device is provided that includes a processor and a memory; the memory stores at least one piece of program code; the at least one program code is configured to be invoked and executed by the processor to implement the firmware online upgrade method of the first aspect.
In a fourth aspect, there is provided a computer readable storage medium having stored therein at least one computer program capable of implementing the firmware online upgrade method according to the first aspect when executed by a processor.
In a fifth aspect, a computer program product is provided, the computer program product comprising a computer program, the computer program when executed by a processor being capable of implementing the firmware online upgrade method according to the first aspect.
The technical scheme provided by the embodiment of the application has the beneficial effects that:
The embodiment of the application configures two system partitions, namely a first system partition and a second system partition, and the address information of the first system partition and the address information of the second system partition are different, but when the electronic equipment is started for the first time, the first address information of the first system partition is written into a first storage area, the first address information in the first storage area is actually logic address information, and the address information of different system partitions can be mapped according to whether a partition exchange function is started or not, so that the access to the different system partitions is carried out according to the address information of the mapped system partitions. For example, when it is determined that the partition exchange function is on based on the data stored in the second storage area, the first address information in the first storage area is hidden, and the second address information mapped by the first address information in the first storage area is read from the first register; and when it is determined that the partition exchange function is not turned on based on the data stored in the second storage area, first address information is stored in the first storage area. When the firmware image file is updated subsequently, no matter in which system partition the firmware image file of the updated version is, the embodiment of the application only stores and reads the first address information in the first storage area to access the corresponding system partition. Because the different system partitions do not need to be managed respectively when the firmware online upgrade operation is executed each time, the management cost is reduced, and meanwhile, the system partition selection error can be avoided, and the equipment brick change is effectively prevented.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a system partition provided by an embodiment of the present application;
FIG. 2 is a system architecture diagram of a firmware online upgrade method according to an embodiment of the present application;
FIG. 3 is a flowchart of a firmware online upgrade method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a firmware online upgrade apparatus according to an embodiment of the present application;
fig. 5 shows a block diagram of an electronic device according to an exemplary embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings.
It will be understood that the terms "each," "plurality," and "any" and the like, as used in this embodiment of the application, include two or more, each referring to each of the corresponding plurality, and any one referring to any one of the corresponding plurality. For example, the plurality of words includes 10 words, and each word refers to each of the 10 words, and any word refers to any one of the 10 words.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or fully authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region, and provide corresponding operation entries for the user to select authorization or rejection.
The method provided by the embodiment of the application aims at the problem of online upgrading of the firmware of system software in an embedded chip (for example, ECU equipment). Firmware image files of system software in embedded chips are typically stored in FLASH. FLASH includes multiple partitions, see fig. 1, including Common partitions (Common regions), system partitions, etc., which may include system partition a (System Partition A, i.e., a first system partition), system partition B (System Partition B, i.e., a second system partition), etc. The start Address of the normal partition is Address0 (Address 0), the start Address of the system partition a is Address1 (Address 1), and the start Address of the system partition B is Address2 (Address 2).
Each time the electronic device is started, a boot program (Bootloader) selects one of the system partitions to execute the firmware image file. The selected system Partition is called an Active Partition (Active Partition), and the unselected system partitions are called inactive partitions. The boot program is a first code segment executed after the embedded system is powered on, after initialization of a processor and related hardware equipment is completed, a mirror image or a solidified embedded application program of the operating system is loaded into a memory, and then the memory space where the operating system is located is jumped to, so that the operating system is operated. The boot program may initialize the hardware device, build a memory space map, and bring the system's software and hardware environment to a proper state to prepare the correct environment for the final invocation of the operating system kernel. In an embodiment of the application, the processor has different rights to the system partitions in different states. For active partitions, the processor has read rights, and for inactive partitions, the processor has read and write rights.
In order to realize the access of the same address information to different system partitions, the embodiment of the application provides a partition exchange function, when the partition exchange function is started, the actual address of the address mapping of the system partition A is the address of the system partition B, and the processor accesses the system partition B instead of the system partition A according to the address of the system partition A; when the partition exchange function is turned off, the actual address of the address mapping of the system partition a is still the system partition a, and the processor accesses the system partition a according to the address of the system partition a.
However, after the partition swap function is turned on, the partition swap function is only validated when the processor performs a read operation on the system partition, and if the processor performs a write operation on the system partition, the partition swap function is not validated even if the partition swap function is turned on.
For the case of starting addresses System Partition A and System Partition B when the processor performs read and write operations ON FLASH, respectively, with the partition hiding function in the ON (ON) and OFF (OFF) states, respectively, see table 1 below.
TABLE 1
As can be seen from table 1, when the processor performs a read operation on FLASH, if the partition exchange function is turned on, the addresses of System Partition A and System Partition B are interchanged, that is, the starting Address of System Partition A is changed from Address1 to Address2, and the starting Address of System Partition B is changed from Address2 to Address1; if the partition switch function is off, then the addresses System Partition A and System Partition B are not interchanged, and the starting Address of System Partition A is still Address1 and the starting Address of System Partition B is still Address2. When the processor performs a write operation on the FLASH, the addresses System Partition A and System Partition B are not interchanged no matter whether the partition exchange function is started, at this time, the starting Address of System Partition A is still Address1, and the starting Address of System Partition B is still Address2.
Note that, address interchange of System Partition A and System Partition B does not truly occur interchange of physical addresses, but rather, system Partition mapped by Address1 is transformed. Address1, originally the starting Address of System Partition A, can access System Partition A according to Address1, but after the partition exchange function is in effect, address1 maps to a system partition System Partition B, where System Partition B is accessed according to Address1 instead of System Partition A.
Fig. 2 shows a system architecture diagram of a firmware online upgrade method provided by an embodiment of the present application, referring to fig. 2, the system includes: the system comprises a bootstrap program, a processor logic control unit, a partition mapping data storage unit and a system partition.
The bootstrap program (Bootloader) is used for checking the data in the system partition and initializing the partition exchange function of the processor logic control unit.
The processor logic control unit is used for configuring information related to the partition exchange function and completing the access and verification of data in the system partition. The processor logic control unit includes a plurality of register sets and a partition swap logic unit. The partition exchange logic unit is a logic control circuit for realizing partition exchange for the processor and is used for realizing the logic function of partition exchange according to a plurality of register groups. The plurality of register sets include a Partition logic control register set (Partition LC REGISTER, i.e., a second register), a Partition logic address register set (Partition LA REGISTER, i.e., a first register), a Partition switch context register set (Partition swap context register, i.e., a third register), and the like. The partition logic control register set includes at least one register for configuring the value of the partition exchange correlation identifier. The partition exchange related identification includes a partition exchange function identification, a partition signature identification, and the like. The partition logical address register set includes at least one register for storing real address information mapped by first address information of a first system partition in the first storage area. The partition exchange context register group comprises at least one register, can be used for setting and configuring information such as the address, the size and the like of a system partition needing to be exchanged by a user, and can also be used for accessing a partition mapping data storage unit and the system partition, checking partition data and the like.
The partition map data storage unit includes a plurality of storage areas, which are respectively a partition logic control data storage area (i.e., a second storage area), a partition logic address data storage area (i.e., a first storage area), a partition signature data storage area (i.e., a third storage area), and the like. The logic control data storage area is used for storing logic control data of the system partition, and the logic control data comprises a numerical value of a partition exchange function identifier, a numerical value of a partition signature identifier and the like. The partition logical address data storage area is used for storing address data of a system partition. The partition signature data storage area is used for storing check values of system partition data.
The system partitions include a system partition a (i.e., a first system partition) and a system partition B (i.e., a second system partition), and so on. Partition a and system partition B are used to store system code data. The addresses of the system partition A and the system partition B are different, and the address size of the system partition A and the system partition B can be preconfigured by a user.
The embodiment of the application provides a firmware online upgrading method, taking an electronic device with a system architecture shown in fig. 2 as an example to execute the embodiment of the application, referring to fig. 3, the method flow provided by the embodiment of the application includes:
301. And in the process of executing the first system partition, when the first firmware image file is determined to need to be updated, writing the second firmware image file into the second system partition, and writing second address information of the second system partition into the first register.
The second firmware image file and the second firmware image file are different versions of the same firmware, and the second firmware image file is an upgrade version of the first firmware image file. The first system partition and the second system partition are two system partitions of FLASH, and the first system partition can be used as a main system partition, and the second system partition can be used as an auxiliary system partition. The address information of the first system partition and the second system partition are different, and the address information includes a start address, a size, and the like. The difference in address information between the first system partition and the second system partition mainly means that the start addresses are different. The first system partition and the second system partition may be the same or different in size, and may be specifically configured by a user according to requirements. When the system software in the system partition is upgraded, a ping-pong mechanism can be adopted for upgrading, and at the moment, the upgraded version of the system software is alternately stored in the first system partition and the second system partition, and the first system partition and the second system partition are also alternately executed. In this way, the first system partition and the second system partition will store different versions of the system software together. For example, the system software may have four versions, a first system partition may store a first version and a third version of the system software, and a second system partition may store a second version and a fourth version of the system software. The first register is used for storing actual address information mapped by first address information of a first system partition in the first storage area. As the system software is updated, different versions of the system software are alternately stored in the first system partition and the second system partition, and the address information stored in the first register will also change.
When the electronic equipment is started for the first time, the bootstrap program is communicated with the processor logic control unit through the third register, whether the partition exchange function of the processor logic control unit is initialized is judged in the communication process, if not, the partition exchange function is initialized, and after the partition exchange function is initialized, the first system partition is executed.
Specifically, when the electronic device is started for the first time, the partition exchange function is initialized, and the following steps may be adopted:
3011. When the electronic equipment is started for the first time, the first address information is written into the first register, and the first address information is written into the first storage area.
The electronic device may first boot up, write the first address information of the first system partition into the first register, and then write the first address information into the first storage area through the third register. The first address information is a unified access address exposed by the system partition for executing the firmware online upgrade operation in the embodiment of the application, and the first address information in the first storage area is not updated when the firmware online upgrade operation is carried out subsequently. The embodiment of the application only maintains the address information of one system partition, thereby reducing the management cost, and avoiding the error of the system partition and effectively preventing the equipment from changing bricks because the address of the system partition for executing the firmware online upgrade operation does not need to be updated.
3012. And carrying out hash calculation on the data of the first system partition to obtain a first hash value.
And carrying out hash calculation on the data of the first system partition by adopting a hash algorithm, so as to obtain a first hash value corresponding to the first system partition.
3013. The partition exchange identifier in the second register is configured to be a second value, and the partition signature identifier in the second register is configured to be a third value.
The second value is used for indicating that the partition exchange function is closed, and the third value is used for indicating that the partition signature function is opened. The partition swap function refers to a function of reading second address information mapped by first address information in the first storage area from the first register. The partition signature function is a function of writing a hash value corresponding to the firmware image file in the system partition into the third storage area.
3014. And writing the second value of the partition exchange identifier and the third value of the partition signature identifier into the second storage area.
The bootstrap program may write the second value of the partition exchange identifier and the third value of the partition signature identifier to the second storage area through a third register.
3015. In response to the partition signature identifying a third value, the first hash value is written to a third storage area.
When the partition signature is identified as the third value, indicating that the partition signature function is on, the first hash value may be written to the third storage area. The first hash value may be written through a third register when the first hash value is written to the third storage area.
After the steps 3011 to 3015 are performed, the initialization operation of the partition exchange function is completed, so that the first system partition can be performed according to the first address information of the first system partition in the first storage area.
In the process of executing the first system partition, when an upgrade version corresponding to the first firmware image file, namely the second firmware image file, is detected, it is determined that the first firmware image file needs to be upgraded. And the OTA program of the system acquires the second firmware image file, and then writes the second firmware image file into the system partition. Because the first firmware image file is stored in the first system partition, based on the ping-pong upgrade mechanism, when the upgrade is performed this time, the second firmware image file needs to be written into the second system partition. Because the first firmware image file is the latest version of the firmware image file stored in the system partition before the second firmware image file is written into the second system partition, and the second firmware image file is the latest version of the firmware image file in the system partition after the second firmware image file is written into the second system partition, and the address information of the system partition where the latest version of the firmware image file in the system partition is located is stored in the first register, after the second firmware image file is written into the second system partition, the second address information of the second system partition also needs to be written into the first register, so that the address information of the system partition where the latest version of the firmware image file in the system partition is stored in the first register is ensured.
302. And configuring the partition exchange identifier in the second register as a first value, and writing the first value of the partition exchange identifier into the second storage area.
The first value is used for indicating that the partition exchange function is started. Since the first storage area stores the first address information of the first system partition, the latest version of the second firmware image is stored in the second system partition, and the address information of the second system partition is the second address information and is not the first address information. However, in order to implement online firmware upgrade, a second firmware image file in the second system partition needs to be executed, and the first address information is a unified access address exposed to the outside by the system partition executing online firmware upgrade operation in the embodiment of the present application, in order to implement access to the second system partition, a partition exchange identifier in the second register needs to be configured as a first value to start a partition exchange function, so that actual address information mapped by the first address information in the first storage area can be read.
Further, after the partition exchange identifier in the second register is configured as the first value, the first value of the partition exchange identifier is also written into the second storage area, so that when the firmware online upgrade operation is executed, state data related to the partition exchange function can be read, and further corresponding operation is executed according to the read state data.
Further, in order to avoid that data in the second firmware image file is lost or tampered in the firmware online upgrade operation process, so that the firmware online upgrade operation is ensured to fail, in the embodiment of the application, after the second firmware image file is acquired, hash calculation is performed on the data in the second system partition to obtain a second hash value, and then the first hash value in the third storage area is updated to the second hash value. The second hash value can be used as a reference value to carry out integrity check on data in a second system partition in the online upgrading operation process of the firmware.
303. Restarting the electronic equipment, and after restarting the electronic equipment, inquiring the numerical value of the partition exchange identifier in the first storage area.
Because the two system partitions are provided in the embodiment of the application, the two system partitions are the first system partition and the second system partition respectively, the firmware image file of the latest version may be located in the first system partition or may be located in the second system partition, and the address information of the system partition for executing the firmware upgrading operation stored in the electronic device is the first address information, so that the electronic device can also query the numerical value of the partition exchange identifier in the first storage area when the electronic device is restarted because of the need of upgrading the electronic device by the first firmware image file.
304. And when the partition exchange identifier is queried to be a first value, reading second address information mapped by the first address information in the first storage area from the first register.
When the partition exchange identifier is inquired to be a first value, the partition exchange function is determined to be started, and the operation type of the current processor on the FLASH is a reading operation, so that the first system partition can be hidden, and the second system partition can be accessed based on the first address information. Because the first address information is the physical address of the first system partition, in order to achieve access to the second system partition, the actual address information mapped by the first address information needs to be acquired, and the actual address information mapped by the first address information in the first storage area is stored in the first register, so that the second address information mapped by the first address information in the first storage area can be read from the first register.
305. Based on the second address information, a second firmware image in the second system partition is executed.
In order to improve the success rate of the firmware online upgrade, the data in the second system partition needs to be checked before the second firmware image file in the second system partition is executed. Specifically, according to the second address information, data of the second system partition can be read from the second system partition, a hash algorithm is adopted to perform hash calculation on the data of the second system partition to obtain a third hash value, then the second hash value is read from the third storage area, the second hash value is further compared with the third hash value, and when the second hash value is matched with the third hash value, a second firmware image file in the second system partition is executed to finish upgrading of the first firmware image file. It should be noted that, the two hash values may be equal to each other, or the error is within a set range.
In another embodiment of the present application, in the process of executing the first system partition, when it is determined that the first firmware image file does not need to be updated and the electronic device is restarted, the first firmware image file in the first system partition may be executed after the electronic device is restarted.
Further, the electronic device will also perform an integrity check on the data in the first system partition before executing the first firmware image in the first system partition. Specifically, the value of the partition exchange identifier may be read from the second storage area, and in response to the value of the partition exchange identifier being the second value, that is, the partition exchange function is not turned on, the first address information in the first storage area is read, then the data in the first system partition is read according to the first address information, and further, a hash algorithm is adopted to perform hash calculation on the data in the first system partition, so as to obtain a fourth hash value. And then reading the first hash value from the third storage area, comparing the first hash value with the fourth hash value, and executing the first firmware image file in the first system partition when the first hash value is matched with the fourth hash value.
Further, when the first hash value is not matched with the fourth hash value, error prompt is carried out on the electronic equipment, and then the electronic equipment is restarted.
To facilitate understanding of the firmware online upgrade method, the following description will be made with reference to fig. 2.
Referring to fig. 2, in step ①, after the electronic device is started for the first time, the bootstrap program communicates with the processor logic control unit through the partition switch context register set, and in the communication process, it is determined whether the partition switch function is turned on, and if not, an initialization operation is performed on the partition switch function. Specifically, address information of a system partition a is written into a partition logical address register group, address information of the system partition a is written into a first storage area of a partition mapping data storage unit, then a hash value a of data in the system partition a is calculated, a partition logical control register is configured, a value of a partition exchange identifier is set to a second value to close a partition exchange function, a partition signature identifier is set to a third value to open the partition signature function, then the second value of the partition exchange identifier and the third value of the partition signature identifier are written into the second storage area of the partition mapping data storage unit through the partition exchange context register group, and then the hash value a is written into the first storage area of the partition mapping data storage unit through the partition exchange context register group.
In step ②, the boot program executes system partition A based on the address of system partition A.
In step ③, during the execution of the system partition a, if the electronic device needs to be restarted, it is determined whether the reason for restarting the electronic device is that the firmware image file in the system partition needs to be updated, if yes, step ④ is executed, and if no, step ⑤ is executed.
In step ④, the bootstrap program reads the value of the partition exchange identifier from the second storage area of the partition mapping data storage unit as the second value, reads the address information of the system partition a from the first storage area, reads the data of the system partition a according to the address information of the system partition a, calculates the hash value of the data of the system partition a, determines that the data of the system partition a passes the integrity check if the hash value is consistent with the hash value a in the first storage area, further executes the system partition a, and prompts the electronic device for an error if the hash value is inconsistent with the hash value a in the first storage area, and then restarts the electronic device.
In step ⑤, the OTA program of the system receives the new firmware image file, writes the new firmware image file into the system partition B, calculates the hash value of the data of the system partition B, writes the obtained hash value B into the third storage area, and writes the address information of the system partition B into the partition logical address register set. In response to the partition exchange function being enabled, restarting the electronic device, after restarting the electronic device, the bootstrap program executing step 4 checks whether the partition exchange function is enabled, and because the partition exchange function is enabled, the actual address mapped by the address information of the system partition a stored in the first storage area is the address information of the system partition B, that is, the processor actually accesses the partition code data of the system partition B, and thus, the new firmware code of the system partition B is executed.
By adopting the method provided by the embodiment of the application, under the condition of not carrying out partition data erasure, data copying and the like, the execution access of different partitions can be carried out based on the unified address by the partition mapping mechanism of the processor, thereby improving the response time of the system and reducing the maintenance cost of the system software. In addition, the embodiment of the application also supports chained mapping management of the two system partitions, and the bootstrap program can access the partition code data of the activated system partition in the two system partitions through the same address, so that the unactivated system partition is hidden. Partition code data within an activated system partition may still be running while writing data to an inactive system partition, thus enabling a switch to both system partition contexts.
Any combination of the above optional solutions may be adopted to form an optional embodiment of the present application, which is not described herein.
Referring to fig. 4, a schematic structural diagram of a firmware online upgrade apparatus according to an embodiment of the present application is provided, where the apparatus may be implemented by software, hardware, or a combination of both, and may be all or a part of an electronic device, and the apparatus includes:
The first writing module 401 is configured to, in a process of executing the first system partition, when it is determined that the first firmware image file needs to be upgraded, write the second firmware image file into the second system partition, where the second firmware image file is an upgraded version of the first firmware image file, and the first system partition and the second system partition are two system partitions with different address information;
a second writing module 402, configured to write second address information of a second system partition into a first register, where the first register is configured to store actual address information mapped by first address information of a first system partition in a first storage area;
a first configuration module 403, configured to configure the partition exchange identifier in the second register to be a first value, where the second register is configured to configure a value of the partition exchange related identifier, the first value is used to indicate that a partition exchange function is started, and the partition exchange function is a function of reading, from the first register, second address information mapped by the first address information in the first storage area;
a third writing module 404 for writing the first value of the partition exchange identifier into the second storage area
A first restarting module 405, configured to restart the electronic device;
A query module 406, configured to query the numerical value of the partition exchange identifier in the first storage area after the electronic device is restarted;
A first reading module 407, configured to read, when the partition exchange identifier is queried to be a first value, second address information mapped by the first address information in the first storage area from the first register;
The first execution module 408 is configured to execute the second firmware image file in the second system partition based on the second address information.
In another embodiment of the present application, the apparatus further comprises:
the initialization module is used for initializing the partition exchange function when the electronic equipment is started for the first time;
And the second execution module is used for executing the first system partition after the partition exchange function is initialized.
In another embodiment of the present application, an initialization module is configured to write first address information into a first register and write first address information into a first storage area when an electronic device is first started;
The first computing module is used for carrying out hash computation on the data of the first system partition to obtain a first hash value;
The second configuration module is used for configuring the partition exchange identifier in the second register as a second value and configuring the partition signature identifier in the second register as a third value, wherein the second value is used for indicating that the partition exchange function is closed, the third value is used for indicating that the partition signature function is opened, and the partition signature function is a function of writing a hash value corresponding to a firmware image file in a system partition into a third storage area;
The fourth writing module is used for writing the second numerical value of the partition exchange identifier and the third numerical value of the partition signature identifier into the second storage area;
And a fifth writing module, configured to write the first hash value into the third storage area in response to the partition signature being identified as the third value.
In another embodiment of the present application, the apparatus further comprises:
The second computing module is used for carrying out hash computation on the data in the second system partition to obtain a second hash value;
and the updating module is used for updating the first hash value in the third storage area to the second hash value.
In another embodiment of the present application, the apparatus further comprises:
The second reading module is used for reading the data of the second system partition according to the second address information;
The third calculation module is used for carrying out hash calculation on the data of the second system partition to obtain a third hash value;
a third reading module, configured to read the second hash value from the third storage area;
And the second execution module is used for executing the second firmware image file in the second system partition when the second hash value is matched with the third hash value.
In another embodiment of the present application, the apparatus further comprises:
And the third execution module is used for executing the first firmware image file in the first system partition after the electronic equipment is restarted when the first firmware image file is determined not to need to be updated in the process of executing the first system partition.
In another embodiment of the present application, the apparatus further comprises:
A fourth reading module, configured to read, from the second storage area, a numerical value of the partition exchange identifier;
A fifth reading module, configured to read the first address information in the first storage area in response to the value of the partition exchange identifier being the second value;
the sixth reading module is used for reading the data of the first system partition according to the first address information;
The fourth calculation module is used for carrying out hash calculation on the data of the first system partition to obtain a fourth hash value;
a seventh reading module, configured to read the first hash value from the third storage area;
And the third execution module is used for executing the first firmware image file in the first system partition when the first hash value is matched with the fourth hash value.
In another embodiment of the present application, the apparatus further comprises:
The prompting module is used for prompting errors of the electronic equipment when the first hash value is not matched with the fourth hash value;
and the second restarting module is used for restarting the electronic equipment.
The embodiment of the application configures two system partitions, namely a first system partition and a second system partition, and the address information of the first system partition and the address information of the second system partition are different, but when the electronic equipment is started for the first time, the first address information of the first system partition is written into a first storage area, the first address information in the first storage area is actually logic address information, and the address information of different system partitions can be mapped according to whether a partition exchange function is started or not, so that the access to the different system partitions is carried out according to the address information of the mapped system partitions. For example, when it is determined that the partition exchange function is on based on the data stored in the second storage area, the first address information in the first storage area is hidden, and the second address information mapped by the first address information in the first storage area is read from the first register; and when it is determined that the partition exchange function is not turned on based on the data stored in the second storage area, first address information is stored in the first storage area. When the firmware image file is updated subsequently, no matter in which system partition the firmware image file of the updated version is, the embodiment of the application only stores and reads the first address information in the first storage area to access the corresponding system partition. Because the different system partitions do not need to be managed respectively when the firmware online upgrade operation is executed each time, the management cost is reduced, and meanwhile, the system partition selection error can be avoided, and the equipment brick change is effectively prevented.
Fig. 5 shows a block diagram of an electronic device 500 according to an exemplary embodiment of the application. Generally, the electronic device 500 includes: a processor 501 and a memory 502.
The processor 501 may be implemented in at least one hardware form of DSP (DIGITAL SIGNAL Processing), FPGA (Field-Programmable gate array), PLA (Programmable Logic Array ). The processor 501 may also include a main processor and a coprocessor, the main processor being a processor for processing data in an awake state; a coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 501 may integrate a GPU (Graphics Processing Unit, image processor) for rendering and drawing of content required to be displayed by the display screen. In some embodiments, the processor 501 may also include an artificial intelligence processor for processing computing operations related to machine learning.
Memory 502 may include one or more computer-readable storage media, which may be non-transitory computer-readable storage media, such as CD-ROM (Compact Disc Read-Only Memory), ROM, RAM (Random Access Memory ), magnetic tape, floppy disk, optical data storage device, and the like. The computer readable storage medium stores at least one computer program which, when executed, enables the firmware online upgrade method described above.
Of course, the electronic device described above may necessarily also include other components, such as input/output interfaces, communication components, and the like. The input/output interface provides an interface between the processor and a peripheral interface module, which may be an output device, an input device, etc. The communication component is configured to facilitate wired or wireless communication between the electronic device and other devices, and the like.
Those skilled in the art will appreciate that the structure shown in fig. 5 is not limiting of the electronic device 500 and may include more or fewer components than shown, or may combine certain components, or may employ a different arrangement of components.
The embodiment of the application provides a computer readable storage medium, wherein at least one computer program is stored in the computer readable storage medium, and the at least one computer program can realize the firmware online upgrading method when being executed by a processor.
Embodiments of the present application provide a computer program product comprising a computer program capable of implementing the firmware online upgrade method described above when executed by a processor.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims (12)
1. A method for online upgrading firmware, the method comprising:
In the process of executing the first system partition, when it is determined that the first firmware image file needs to be upgraded, writing a second firmware image file into the second system partition, and writing second address information of the second system partition into a first register, wherein the second firmware image file is an upgrade version of the first firmware image file, the first system partition and the second system partition are two system partitions with different address information, and the first register is used for storing actual address information mapped by the first address information of the first system partition in a first storage area;
Configuring a partition exchange identifier in a second register as a first value, and writing the first value of the partition exchange identifier into a second storage area, wherein the second register is used for configuring the value of a partition exchange related identifier, the first value is used for indicating that a partition exchange function is started, and the partition exchange function is a function of reading second address information mapped by first address information in the first storage area from the first register;
restarting the electronic equipment, and after restarting the electronic equipment, inquiring the numerical value of the partition exchange identifier in the first storage area;
When the partition exchange identifier is inquired to be a first numerical value, reading the second address information mapped by the first address information in the first storage area from the first register;
And executing the second firmware image file in the second system partition based on the second address information.
2. The method of claim 1, wherein, during execution of the first system partition, before determining that the first firmware image needs to be upgraded and writing the second firmware image to the second system partition, further comprises:
initializing the partition exchange function when the electronic equipment is started for the first time;
and after the partition exchange function is initialized, executing the first system partition.
3. The method of claim 2, wherein initializing the partition exchange function when the electronic device is first booted comprises:
when the electronic equipment is started for the first time, writing the first address information into the first register, and writing the first address information into the first storage area;
carrying out hash calculation on the data of the first system partition to obtain a first hash value;
Configuring a partition exchange identifier in the second register as a second value, and configuring a partition signature identifier in the second register as a third value, wherein the second value is used for indicating that the partition exchange function is closed, the third value is used for indicating that a partition signature function is opened, and the partition signature function is a function of writing a hash value corresponding to a firmware image file in a system partition into a third storage area;
Writing a second value of the partition exchange identifier and a third value of the partition signature identifier into the second storage area;
and in response to the partition signature being identified as a third value, writing the first hash value to the third storage area.
4. The method of claim 3, further comprising, prior to restarting the electronic device:
Carrying out hash calculation on the data of the second system partition to obtain a second hash value;
and updating the first hash value in the third storage area to the second hash value.
5. The method of claim 4, wherein prior to executing the second firmware image in the second system partition based on the second address information, comprising:
reading the data of the second system partition according to the second address information;
carrying out hash calculation on the data of the second system partition to obtain a third hash value;
Reading the second hash value from the third storage area;
and executing the second firmware image file in the second system partition when the second hash value is matched with the third hash value.
6. A method according to claim 3, characterized in that the method further comprises:
And in the process of executing the first system partition, executing the first firmware image file in the first system partition after the electronic equipment is restarted after determining that the first firmware image file does not need to be updated.
7. The method of claim 6, wherein after the electronic device reboots, prior to executing the first firmware image in the first system partition, further comprising:
reading the numerical value of the partition exchange identifier from the second storage area;
reading the first address information in the first storage area in response to the value of the partition exchange identifier being a second value;
reading the data of the first system partition according to the first address information;
carrying out hash calculation on the data of the first system partition to obtain a fourth hash value;
Reading the first hash value from the third storage area;
And executing the first firmware image file in the first system partition when the first hash value is matched with the fourth hash value.
8. The method of claim 7, wherein the method further comprises:
and when the first hash value is not matched with the fourth hash value, carrying out error prompt on the electronic equipment, and restarting the electronic equipment.
9. An on-line firmware upgrade apparatus, the apparatus comprising:
The first writing module is used for writing a second firmware image file into a second system partition when the first firmware image file is determined to be updated in the process of executing the first system partition, wherein the second firmware image file is an updated version of the first firmware image file, and the first system partition and the second system partition are two system partitions with different address information;
The second writing module is used for writing second address information of the second system partition into a first register, and the first register is used for storing actual address information mapped by first address information of the first system partition in the first storage area;
The first configuration module is used for configuring the partition exchange identifier in the second register as a first value, the second register is used for configuring the value of the partition exchange related identifier, the first value is used for indicating that a partition exchange function is started, and the partition exchange function is a function of reading the second address information mapped by the first address information in the first storage area from the first register;
A third writing module for writing the first value of the partition exchange identifier into the second storage area
The first restarting module is used for restarting the electronic equipment;
The inquiring module is used for inquiring the numerical value of the partition exchange identifier in the first storage area after the electronic equipment is restarted;
a first reading module, configured to read, when it is queried that the partition exchange identifier is a first value, the second address information mapped by the first address information in the first storage area from the first register;
And the first execution module is used for executing the second firmware image file in the second system partition based on the second address information.
10. An electronic device comprising a processor and a memory; the memory stores at least one piece of program code; the at least one program code is for being invoked and executed by the processor to implement the firmware online upgrade method of any one of claims 1 to 8.
11. A computer readable storage medium, wherein at least one computer program is stored in the computer readable storage medium, and when the at least one computer program is executed by a processor, the at least one computer program is capable of implementing the firmware online upgrade method according to any one of claims 1 to 8.
12. A computer program product, characterized in that the computer program product comprises a computer program which, when executed by a processor, enables the firmware online upgrade method according to any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410131409.0A CN117931251A (en) | 2024-01-30 | 2024-01-30 | Firmware online upgrading method and device, electronic equipment, storage medium and product |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410131409.0A CN117931251A (en) | 2024-01-30 | 2024-01-30 | Firmware online upgrading method and device, electronic equipment, storage medium and product |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117931251A true CN117931251A (en) | 2024-04-26 |
Family
ID=90755548
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410131409.0A Pending CN117931251A (en) | 2024-01-30 | 2024-01-30 | Firmware online upgrading method and device, electronic equipment, storage medium and product |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117931251A (en) |
-
2024
- 2024-01-30 CN CN202410131409.0A patent/CN117931251A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6073206A (en) | Method for flashing ESCD and variables into a ROM | |
EP3764237A1 (en) | System startup method and apparatus, electronic device and storage medium | |
KR920008445B1 (en) | An apparatus and method for decreasing the memory requirment for bios in a personal computer system | |
US8086839B2 (en) | Authentication for resume boot path | |
CN109478135A (en) | The UEFI of optimization reboots process | |
KR20010006749A (en) | Storing system-level mass storage configuration data in non-volatile memory on each mass storage device to allow for reboot/power-on reconfiguration of all installed mass storage devices to the same configuration as last use | |
TW201419153A (en) | Electronic device and booting method | |
CN101145107A (en) | Maintaining early hardware configuration state | |
JP2020535504A (en) | How to upgrade system version and equipment | |
US20030084232A1 (en) | Device and method capable of changing codes of micro-controller | |
CN101739272A (en) | Electronic device, and method and system for starting basic input-output system | |
WO2022046105A1 (en) | Bios update | |
US8122205B2 (en) | Structured virtual registers for embedded controller devices | |
CN117931251A (en) | Firmware online upgrading method and device, electronic equipment, storage medium and product | |
EP4296860A1 (en) | Method for running startup program of electronic device, and electronic device | |
JP4735765B2 (en) | Linux program startup system | |
CN113032008B (en) | Electronic processing device and memory control method | |
CN111159123B (en) | Embedded reliable parameter storage file system and method | |
JP2001306307A (en) | Method for processing firmware | |
US20040255075A1 (en) | Apparatus and method for flash ROM management | |
CN110858145B (en) | BIOS updating method and device under Linux operating system | |
US11650930B2 (en) | Reconfigurable memory mapped peripheral registers | |
CN112540889B (en) | Method, device, equipment and medium for adjusting hard disk starting sequence in user mode | |
CN118152311B (en) | Data processing method, device, system, electronic equipment and storage medium | |
CN110941452B (en) | Configuration method, BIOS chip and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |