Firmware upgrading method and storage equipment

文档序号:1963501 发布日期:2021-12-14 浏览:15次 中文

阅读说明:本技术 一种固件升级方法和存储设备 (Firmware upgrading method and storage equipment ) 是由 纪大峣 于 2021-08-02 设计创作,主要内容包括:本发明涉及固件升级技术领域,特别涉及一种固件升级方法和存储设备。所述一种固件升级方法,包括步骤:获取用于第一次升级的固件升级包;执行第一次升级,在当前设备的预设位置增加新分区,所述新分区包括:预留包分区,所述预留包分区用于:存放第二次升级的固件升级包;执行第二次升级,读取所述第二次升级的固件升级包并存储至设备Memory,基于所述设备Memory中的第二次升级的固件升级包进行升级操作。上述方法,通过两次的固件升级使得在不需要借助外部存储介质的情况下,实现对设备整块存储介质进行变更升级,支持分区表任意变更,克服了对外置存储介质的依赖,从而满足某些特殊场景的固件升级需求。(The present invention relates to the field of firmware upgrading technologies, and in particular, to a firmware upgrading method and a storage device. The firmware upgrading method comprises the following steps: acquiring a firmware upgrading package for first upgrading; executing first upgrading, and adding a new partition at a preset position of the current equipment, wherein the new partition comprises: a reserved packet partition to: storing the firmware upgrade package of the second upgrade; and executing second upgrade, reading the firmware upgrade package of the second upgrade, storing the firmware upgrade package of the second upgrade into the device Memory, and performing upgrade operation based on the firmware upgrade package of the second upgrade in the device Memory. According to the method, the whole storage medium of the equipment is changed and upgraded through two times of firmware upgrading without the help of an external storage medium, the partition table is supported to be changed randomly, the dependence on the external storage medium is overcome, and therefore the firmware upgrading requirements of certain special scenes are met.)

1. A method for upgrading firmware, comprising the steps of:

acquiring a firmware upgrading package for first upgrading;

executing first upgrading, and adding a new partition at a preset position of the current equipment, wherein the new partition comprises: a reserved packet partition to: storing the firmware upgrade package of the second upgrade;

and executing second upgrade, reading the firmware upgrade package of the second upgrade, storing the firmware upgrade package of the second upgrade into the device Memory, and performing upgrade operation based on the firmware upgrade package of the second upgrade in the device Memory.

2. The firmware upgrading method according to claim 1, before acquiring the firmware upgrading package for the first upgrading, further comprising the steps of:

making a first-time upgraded firmware upgrade package, wherein the content of the first-time upgraded firmware upgrade package comprises: a new upgrade mode complete mirror image file and a partition table configuration file;

the new complete image file of the upgrade mode comprises a new instruction: before exiting the upgrading mode, checking whether a partition table change marking file exists in a reserved position, if so, reformatting a last user data partition of a partition table and rebuilding a file system, and meanwhile, checking whether an equipment partition node has a reserved packet partition node, and if so, formatting the reserved packet partition to build a readable and writable file system;

the partition table configuration file comprises: when the virtual partition mark is configured to be empty, adding a reserved packet partition in the partition table of the current old firmware, wherein the reserved packet partition is positioned behind all firmware partitions of the current partition table and in front of the last user data partition, and the size of the reserved packet partition is larger than that of the firmware upgrading packet upgraded for the second time;

or when the virtual partition marker is not empty, the virtual partition marker comprises: a first parameter, a second parameter, and a third parameter, the first parameter representing a virtual partition mode including, but not limited to: in the mode 1 and the mode 2, the second parameter represents the size of the firmware upgrade package upgraded for the second time, and the third parameter represents the size of the storage space occupied by all partitions before the last user data area in the new platform firmware partition table to be upgraded.

3. The firmware upgrading method according to claim 2, wherein when the virtual partition flag is configured to be null, the old partition table is provided with a reserved location, the reserved location is an unencrypted readable and writable user data area, and the size of the reserved location is not smaller than the size of the difference packet;

a boot communication partition is arranged in the old partition table and used for communication among the firmware in different stages;

the last partition of the old partition table is a user data partition;

if the firmware upgrade package upgraded for the first time is a complete package, the firmware upgrade package upgraded for the first time comprises: if the firmware upgrade package upgraded for the first time is a difference package, the firmware upgrade package upgraded for the first time comprises: the difference file of the firmware existing in the equipment for the firmware upgrade comprises the following contents: and after entering the system, mounting the instruction of the reserved packet partition.

4. A firmware upgrade method according to any one of claims 1 to 3, wherein before "performing the first upgrade", the method specifically comprises the following steps:

judging whether the size of the firmware upgrading packet upgraded for the first time is larger than the available size of a reserved position of equipment, if so, exiting the upgrading process, if not, backing up the content of a user data area in the last subarea of a current equipment subarea table to a network server according to the requirement, storing the firmware upgrading packet upgraded for the first time in the reserved position of the current equipment, issuing a first upgrading instruction, writing the first upgrading instruction and the firmware upgrading packet upgraded for the first time in a position 1 of a guide communication subarea, and entering an upgrading mode.

5. The firmware upgrading method according to claim 4, wherein the "performing the first upgrade, adding a new partition at a preset position of the current device, the new partition includes: a reserved packet partition ", further comprising:

step S1: upgrading the new upgrade mode complete image file of the firmware upgrade package upgraded for the first time;

step S2: reading the content of the position 2 of the boot communication partition, judging whether a success mark exists or not, if so, jumping to step S3, and if not, upgrading the new partition table of the device according to the partition table configuration file in the firmware upgrade package of the first upgrade, wherein the upgrading process of the new partition table of the upgrade device is as follows:

step S201: analyzing the partition table configuration file, checking whether a virtual partition mark exists or not, and if the virtual partition mark does not exist or the virtual partition mark is empty, updating an old partition table in the equipment according to a new partition table in the partition table configuration file;

step S202: if the virtual partition mark is not empty, further analyzing 3 parameters in the virtual partition mark, checking whether the first parameter value is a mode 1 or a mode 2, and if the first parameter value is not the mode 1 or the mode 2, updating an old partition table in the equipment according to a new partition table in the partition table configuration file;

when the first parameter is mode 1, checking whether a new partition table in a partition table configuration file has a specific reserved packet partition, if so, directly updating an old partition table in the equipment according to the new partition table in the partition table configuration file, if not, reading the old partition table in the current equipment to obtain the initial address and the length of the last partition of the old partition table, if the sum of the initial address of the last partition and the size of the second parameter is larger than the size of the flash space available for the equipment, exiting upgrading, if the sum of the initial address of the last partition and the size of the second parameter is not larger than the size of the flash space available for the equipment, inserting a reserved packet partition before the last partition of the partition table to be upgraded, wherein the initial address of the reserved packet partition is the initial address of the last partition of the previously obtained old partition table, the length of the reserved packet partition is greater than a second parameter, and the starting address and the length of the last partition are updated at the same time, wherein the new starting address is as follows: the starting address of the reserved packet partition + the length of the reserved packet partition, the new length being: the size of the flash space available to the device- (the starting address of the reserved packet partition + the length of the reserved packet partition);

when the first parameter is mode 2, checking whether a new partition table in the partition table configuration file has a specific virtual partition and a reserved packet partition, and if both the two partitions exist, directly updating an old partition table in the equipment according to the new partition table in the partition table configuration file; if the sum of the size of the third parameter and the second parameter is smaller than the size of the available flash space of the device, firstly reading an old partition table in the current device, obtaining the starting address and the length of the last partition of the old partition table, then inserting two new partitions, namely a virtual partition and a reserved packet partition, before the last partition of the partition table to be upgraded, wherein the starting address of the virtual partition is 0, and the length of the virtual partition is larger than the maximum value between the third parameter and the starting address of the last partition of the old partition table obtained previously; the starting address of the reserved packet partition is the starting address of the virtual partition plus the length of the virtual partition, and the length of the reserved packet partition needs to be greater than a second parameter; and simultaneously updating the starting address and the length of the last partition, wherein the new starting address is as follows: the starting address of the reserved packet partition + the length of the reserved packet partition, the new length being: the size of the flash space available to the device-the new starting address of the last partition;

if the third parameter + the second parameter > is the size of the available flash space of the equipment, reading an old partition table in the current equipment, acquiring the initial address and the length of the last partition of the old partition table, and if the initial address of the last partition + the second parameter > the size of the available flash space of the equipment, exiting upgrading; otherwise, before the last partition of the partition table to be upgraded, inserting a reserved packet partition, wherein the starting address of the reserved packet partition is the previously acquired starting address of the last partition of the old partition table, the partition length needs to be larger than a second parameter, and the starting address and the length of the last partition are updated at the same time, and the new starting address is: the starting address of the reserved packet partition plus the length of the reserved packet partition, the new length is: the size of the flash space available to the device- ("starting address of reserved packet partition +" length of reserved packet partition ");

step S203: after the partition table is upgraded, creating a specified path from the partition table change mark file to the reserved position, setting a success mark to the position 2 of the guide communication partition, restarting the device, reentering the upgrade mode, and executing the step S1 and the step S2 again, wherein the step S3 is directly executed because the success mark exists in the position 2 of the guide communication partition;

step S3: executing other upgrading operations in the upgrading packet, and updating the system partition;

step S4: before exiting the upgrade mode, executing a new instruction of the upgraded complete image file of the new upgrade mode in step S1;

step S5: and clearing the content of the position 1 of the boot communication partition and the position 2 of the communication partition, and restarting the system after the firmware upgrade package which enters the first upgrade is upgraded.

6. The firmware upgrade method according to claim 5, wherein before the "performing the second upgrade", the method further comprises:

mounting the newly added reserved packet partition;

judging whether a reserved partition success marking file exists in the appointed path of the reserved position, if not, exiting the program, and if so, acquiring a firmware upgrade package of the second upgrade and storing the firmware upgrade package into the reserved package partition;

and deleting the partition table change mark file and the reserved partition success mark file under the reserved position appointed path, writing a second upgrading instruction and a second upgraded firmware upgrading packet path in the position 1 of the guide communication partition, and entering the second upgrading.

7. The firmware upgrading method according to claim 6, wherein the "performing second upgrade, reading the firmware upgrade package of the second upgrade, storing the firmware upgrade package of the second upgrade into the device Memory, and performing upgrade operation based on the firmware upgrade package of the second upgrade in the device Memory" specifically includes the steps of:

reading the content of the position 1 of the guide communication partition, and triggering second upgrading according to the second upgrading instruction:

mounting a reserved packet partition, judging whether a firmware upgrading packet upgraded for the second time in the reserved packet partition exists, if not, exiting the upgrading process, if so, calculating the size of the firmware upgrading packet upgraded for the second time, judging whether the size of the firmware upgrading packet upgraded for the second time is larger than the available Memory of the current equipment, if so, exiting, otherwise, newly building a temporary file in the Memory, copying the content of the firmware upgrading packet upgraded for the second time to the temporary file, finally pointing the path of the firmware upgrading packet upgraded for the second time to the newly-built temporary file in the Memory, upgrading a new partition table in a flash storage medium of the equipment according to the content of the firmware upgrading packet upgraded for the second time in the Memory, upgrading all new firmware according to the mirror image in the firmware upgrading packet upgraded for the second time, and completing the complete upgrading of the equipment firmware.

8. A firmware upgrade method according to any one of claims 1 to 7, wherein the first upgrade comprises: a first FOTA upgrade, the second upgrade comprising: and (5) upgrading the FOTA for the second time.

9. A storage device having a set of instructions stored therein, the set of instructions being operable to perform: a firmware upgrade method as claimed in any one of claims 1 to 8.

Technical Field

The present invention relates to the field of firmware upgrading technologies, and in particular, to a firmware upgrading method and a storage device.

Background

The Firmware upgrading technology is realized by using an FOTA (Firmware Over-the-Air) Firmware upgrading engine and taking a Firmware upgrading package as input.

The existing FOTA firmware upgrading schemes can be mainly divided into the following categories:

1. the FOTA upgrade of the equipment physical partition table is not supported;

2. in the technical scheme supporting FOTA upgrade of the device physical partition table, the following two categories exist:

a. the first type of scheme supports partial partition table changes or supports some specific manner of change, such as the actual physical partition associated with the boot program cannot be changed or only the size of an existing partition can be adjusted. Most of the schemes need to use an external storage medium (SD/TF card or U disk), and some schemes which do not need to use the external storage medium only support partition adjustment in a specific mode, namely, the partition where the firmware upgrade package is located is not changed.

b. The second category supports substantially any partition table change. In such a scheme, generally, the whole device flash storage medium needs to be upgraded, so that the whole flash storage medium is invalid in the upgrading process and cannot store any form of firmware upgrade package in the device flash, and therefore, the firmware upgrade package needs to be stored by means of an external storage medium.

In some specific scenarios, it is desirable to upgrade firmware in a device to firmware of a completely new platform in a FOTA manner, in this process, any change and upgrade need to be performed on a physical partition table of the device, and in some scenarios, the device is not configured with external storage.

With the rapid development and evolution of AIoT (intelligent internet of things) devices, flash storage media and memories (device memories) collocated in the devices have larger and stronger functions, for example, the device memories of AIoT devices based on an Android system are usually more than 2 GB. However, the FOTA firmware upgrade engine cannot directly use these device memories to store data such as a firmware upgrade package, because in the FOTA upgrade process, it is usually necessary to restart the device to enter an upgrade mode (e.g., a recovery mode of android) to perform firmware upgrade, and in the restart process of the device, various DDR memories (device memories) are normally initialized, so that all data in the device memories are invalid.

Meanwhile, the capacity of the Flash storage medium carried by the device is also getting larger and larger, and usually comprises 8GB, 16GB, 32GB, 64GB, 128GB, 512GB and above, but in the FOTA upgrading process of arbitrarily changing the partition table of the whole Flash storage medium, because the whole Flash storage medium is invalid in the upgrading process, the firmware upgrading package in any form can not be stored in the Flash of the device.

Therefore, how to upgrade the firmware in one device to the firmware of a brand new platform in an FOTA manner without configuring external storage becomes an urgent problem to be solved in the process of arbitrarily changing and upgrading the physical partition table of the device.

Disclosure of Invention

Therefore, a firmware upgrading method needs to be provided, so as to solve the technical problem that in the FOTA upgrading process of supporting any change of the partition table when any change needs to be performed on the whole device flash storage medium, the whole flash storage medium is invalid in the upgrading process, and any form of firmware upgrading package cannot be stored in the device flash, so that the firmware upgrading package needs to be stored by means of an external storage medium. The specific technical scheme is as follows:

a firmware upgrade method, comprising the steps of:

acquiring a firmware upgrading package for first upgrading;

executing first upgrading, and adding a new partition at a preset position of the current equipment, wherein the new partition comprises: a reserved packet partition to: storing the firmware upgrade package of the second upgrade;

and executing second upgrade, reading the firmware upgrade package of the second upgrade, storing the firmware upgrade package of the second upgrade into the device Memory, and performing upgrade operation based on the firmware upgrade package of the second upgrade in the device Memory.

Further, before acquiring the firmware upgrade package for the first upgrade, the method further includes the steps of:

making a first-time upgraded firmware upgrade package, wherein the content of the first-time upgraded firmware upgrade package comprises: a new upgrade mode complete mirror image file and a partition table configuration file;

the new complete image file of the upgrade mode comprises a new instruction: before exiting the upgrading mode, checking whether a partition table change marking file exists in a reserved position, if so, reformatting a last user data partition of a partition table and rebuilding a file system, and meanwhile, checking whether an equipment partition node has a reserved packet partition node, and if so, formatting the reserved packet partition to build a readable and writable file system;

the partition table configuration file comprises: when the virtual partition mark is configured to be empty, adding a reserved packet partition in the partition table of the current old firmware, wherein the reserved packet partition is positioned behind all firmware partitions of the current partition table and in front of the last user data partition, and the size of the reserved packet partition is larger than that of the firmware upgrading packet upgraded for the second time;

or when the virtual partition marker is not empty, the virtual partition marker comprises: a first parameter, a second parameter, and a third parameter, the first parameter representing a virtual partition mode including, but not limited to: in the mode 1 and the mode 2, the second parameter represents the size of the firmware upgrade package upgraded for the second time, and the third parameter represents the size of the storage space occupied by all partitions before the last user data area in the new platform firmware partition table to be upgraded.

Further, when the virtual partition flag is configured to be null, the old partition table is provided with a reserved position, the reserved position is an unencrypted readable and writable user data area, and the size of the reserved position is not smaller than that of the difference packet;

a boot communication partition is arranged in the old partition table and used for communication among the firmware in different stages;

the last partition of the old partition table is a user data partition;

if the firmware upgrade package upgraded for the first time is a complete package, the firmware upgrade package upgraded for the first time comprises: if the firmware upgrade package upgraded for the first time is a difference package, the firmware upgrade package upgraded for the first time comprises: the difference file of the firmware existing in the equipment for the firmware upgrade comprises the following contents: and after entering the system, mounting the instruction of the reserved packet partition.

Further, before the "performing the first upgrade", the method specifically includes the following steps:

judging whether the size of the firmware upgrading packet upgraded for the first time is larger than the available size of a reserved position of equipment, if so, exiting the upgrading process, if not, backing up the content of a user data area in the last subarea of a current equipment subarea table to a network server according to the requirement, storing the firmware upgrading packet upgraded for the first time in the reserved position of the current equipment, issuing a first upgrading instruction, writing the first upgrading instruction and the firmware upgrading packet upgraded for the first time in a position 1 of a guide communication subarea, and entering an upgrading mode.

Further, the "performing the first upgrade" adds a new partition at a preset location of the current device, where the new partition includes: a reserved packet partition ", further comprising:

step S1: upgrading the new upgrade mode complete image file of the firmware upgrade package upgraded for the first time;

step S2: reading the content of the position 2 of the boot communication partition, judging whether a success mark exists or not, if so, jumping to step S3, and if not, upgrading the new partition table of the device according to the partition table configuration file in the firmware upgrade package of the first upgrade, wherein the upgrading process of the new partition table of the upgrade device is as follows:

step S201: analyzing the partition table configuration file, checking whether a virtual partition mark exists or not, and if the virtual partition mark does not exist or the virtual partition mark is empty, updating an old partition table in the equipment according to a new partition table in the partition table configuration file;

step S202: if the virtual partition mark is not empty, further analyzing 3 parameters in the virtual partition mark, checking whether the first parameter value is a mode 1 or a mode 2, and if the first parameter value is not the mode 1 or the mode 2, updating an old partition table in the equipment according to a new partition table in the partition table configuration file;

when the first parameter is mode 1, checking whether a new partition table in a partition table configuration file has a specific reserved packet partition, if so, directly updating an old partition table in the equipment according to the new partition table in the partition table configuration file, if not, reading the old partition table in the current equipment to obtain the initial address and the length of the last partition of the old partition table, if the sum of the initial address of the last partition and the size of the second parameter is larger than the size of the flash space available for the equipment, exiting upgrading, if the sum of the initial address of the last partition and the size of the second parameter is not larger than the size of the flash space available for the equipment, inserting a reserved packet partition before the last partition of the partition table to be upgraded, wherein the initial address of the reserved packet partition is the initial address of the last partition of the previously obtained old partition table, the length of the reserved packet partition is greater than a second parameter, and the starting address and the length of the last partition are updated at the same time, wherein the new starting address is as follows: the starting address of the reserved packet partition + the length of the reserved packet partition, the new length being: the size of the flash space available to the device- (the starting address of the reserved packet partition + the length of the reserved packet partition);

when the first parameter is mode 2, checking whether a new partition table in the partition table configuration file has a specific virtual partition and a reserved packet partition, and if both the two partitions exist, directly updating an old partition table in the equipment according to the new partition table in the partition table configuration file; if the sum of the size of the third parameter and the second parameter is smaller than the size of the available flash space of the device, firstly reading an old partition table in the current device, obtaining the starting address and the length of the last partition of the old partition table, then inserting two new partitions, namely a virtual partition and a reserved packet partition, before the last partition of the partition table to be upgraded, wherein the starting address of the virtual partition is 0, and the length of the virtual partition is larger than the maximum value between the third parameter and the starting address of the last partition of the old partition table obtained previously; the starting address of the reserved packet partition is the starting address of the virtual partition plus the length of the virtual partition, and the length of the reserved packet partition needs to be greater than a second parameter; and simultaneously updating the starting address and the length of the last partition, wherein the new starting address is as follows: the starting address of the reserved packet partition + the length of the reserved packet partition, the new length being: the size of the flash space available to the device-the new starting address of the last partition;

if the third parameter + the second parameter > is the size of the available flash space of the equipment, reading an old partition table in the current equipment, acquiring the initial address and the length of the last partition of the old partition table, and if the initial address of the last partition + the second parameter > the size of the available flash space of the equipment, exiting upgrading; otherwise, before the last partition of the partition table to be upgraded, inserting a reserved packet partition, wherein the starting address of the reserved packet partition is the previously acquired starting address of the last partition of the old partition table, the partition length needs to be larger than a second parameter, and the starting address and the length of the last partition are updated at the same time, and the new starting address is: the starting address of the reserved packet partition plus the length of the reserved packet partition, the new length is: the size of the flash space available to the device- ("starting address of reserved packet partition +" length of reserved packet partition ");

step S203: after the partition table is upgraded, creating a specified path from the partition table change mark file to the reserved position, setting a success mark to the position 2 of the guide communication partition, restarting the device, reentering the upgrade mode, and executing the step S1 and the step S2 again, wherein the step S3 is directly executed because the success mark exists in the position 2 of the guide communication partition;

step S3: executing other upgrading operations in the upgrading packet, and updating the system partition;

step S4: before exiting the upgrade mode, executing a new instruction of the upgraded complete image file of the new upgrade mode in step S1;

step S5: and clearing the content of the position 1 of the boot communication partition and the position 2 of the communication partition, and restarting the system after the firmware upgrade package which enters the first upgrade is upgraded.

Further, before the "performing the second upgrade", the method specifically includes the following steps:

mounting the newly added reserved packet partition;

judging whether a reserved partition success marking file exists in the appointed path of the reserved position, if not, exiting the program, and if so, acquiring a firmware upgrade package of the second upgrade and storing the firmware upgrade package into the reserved package partition;

and deleting the partition table change mark file and the reserved partition success mark file under the reserved position appointed path, writing a second upgrading instruction and a second upgraded firmware upgrading packet path in the position 1 of the guide communication partition, and entering the second upgrading.

Further, the "performing second upgrade, reading the firmware upgrade package of the second upgrade, storing the firmware upgrade package of the second upgrade in the device Memory, and performing upgrade operation based on the firmware upgrade package of the second upgrade in the device Memory" specifically includes the steps of:

reading the content of the position 1 of the guide communication partition, and triggering second upgrading according to the second upgrading instruction:

mounting a reserved packet partition, judging whether a firmware upgrading packet upgraded for the second time in the reserved packet partition exists, if not, exiting the upgrading process, if so, calculating the size of the firmware upgrading packet upgraded for the second time, judging whether the size of the firmware upgrading packet upgraded for the second time is larger than the available Memory of the current equipment, if so, exiting, otherwise, newly building a temporary file in the Memory, copying the content of the firmware upgrading packet upgraded for the second time to the temporary file, finally pointing the path of the firmware upgrading packet upgraded for the second time to the newly-built temporary file in the Memory, upgrading a new partition table in a flash storage medium of the equipment according to the content of the firmware upgrading packet upgraded for the second time in the Memory, upgrading all new firmware according to the mirror image in the firmware upgrading packet upgraded for the second time, and completing the complete upgrading of the equipment firmware.

Further, the first upgrade includes: a first FOTA upgrade, the second upgrade comprising: and (5) upgrading the FOTA for the second time.

In order to solve the technical problem, the storage device is further provided, and the specific technical scheme is as follows:

a storage device having stored therein a set of instructions for performing: any step in a firmware upgrade method mentioned above.

The invention has the beneficial effects that: a firmware upgrade method, comprising the steps of: acquiring a firmware upgrading package for first upgrading; executing first upgrading, and adding a new partition at a preset position of the current equipment, wherein the new partition comprises: a reserved packet partition to: storing the firmware upgrade package of the second upgrade; and executing second upgrade, reading the firmware upgrade package of the second upgrade, storing the firmware upgrade package of the second upgrade into the device Memory, and performing upgrade operation based on the firmware upgrade package of the second upgrade in the device Memory. According to the method, the whole storage medium of the equipment is changed and upgraded through two times of firmware upgrading without the help of an external storage medium, the partition table is supported to be changed randomly, the dependence on the external storage medium is overcome, and therefore the firmware upgrading requirements of certain special scenes are met.

Drawings

FIG. 1 is a flowchart of a firmware upgrade method according to an embodiment;

fig. 2 is a schematic overall flowchart of a firmware upgrade method according to an embodiment;

FIG. 3 is a flowchart illustrating a new partition table process of an upgrade device according to a partition table configuration file in a firmware upgrade package according to a first upgrade, in accordance with an exemplary embodiment;

fig. 4 is a block diagram of a storage device according to an embodiment.

Description of reference numerals:

400. a storage device.

Detailed Description

To explain technical contents, structural features, and objects and effects of the technical solutions in detail, the following detailed description is given with reference to the accompanying drawings in conjunction with the embodiments.

Referring to fig. 1 to fig. 3, in the present embodiment, a firmware upgrade method may be applied to a storage device, including but not limited to an intelligent internet of things device.

The core technical idea of the application is as follows: the mode of FOTA twice can support the change and upgrade of the whole storage medium of the equipment without the help of an external storage medium (SD/TF card or U disk), and supports the arbitrary change of the partition table. The firmware upgrading method includes the steps that 1 (reserved packet partition) is added to FOTA for the first time after all firmware partitions of a partition table of current equipment and before the last user data partition, wherein the reserved packet partition is used for storing a firmware upgrading packet of FOTA for the second time. And then after the FOTA enters the upgrading mode for the second time, reading the firmware upgrading packet from the new partition and storing the firmware upgrading packet in the device Memory, and then carrying out FOTA upgrading of any partition table change on the whole Flash based on the firmware upgrading packet in the device Memory. The following is a detailed description:

step S101: and acquiring a firmware upgrading package for first upgrading.

Step S102: executing first upgrading, and adding a new partition at a preset position of the current equipment, wherein the new partition comprises: a reserved packet partition to: and storing the firmware upgrading package upgraded for the second time.

Step S103: a second upgrade is performed.

Step S104: and reading the firmware upgrade package of the second upgrade and storing the firmware upgrade package of the second upgrade to the device Memory.

Step S105: and carrying out upgrading operation based on the firmware upgrading package upgraded for the second time in the device Memory.

In this embodiment, both the first upgrade and the second upgrade may be specifically FOTA upgrades.

In the present embodiment, the firmware upgrade package for the first upgrade is made by itself, and how to make the firmware upgrade package for the first upgrade (also called a temporary firmware package) is explained as follows:

before the firmware upgrade package for the first upgrade is acquired, the method further comprises the following steps:

making a first-time upgraded firmware upgrade package, wherein the content of the first-time upgraded firmware upgrade package comprises: and the new upgrade mode complete image file and the partition table configuration file. The firmware upgrade package of the first upgrade may be a complete package or a differential package, and if the firmware upgrade package of the first upgrade is a complete package, the firmware upgrade package of the first upgrade includes: if the firmware upgrade package upgraded for the first time is a difference package, the firmware upgrade package upgraded for the first time comprises: the difference file of the firmware existing in the equipment for the firmware upgrade comprises the following contents: and after entering the system, mounting the instruction of the reserved packet partition.

The new complete image file of the upgrade mode comprises a new instruction: before exiting the upgrade mode, checking whether a reserved position (also called a temporary packet partition) has a partition table change marking file (such as last _ parameter _ update), if so, reformatting a last user data partition of the partition table and rebuilding a file system, and simultaneously checking whether a device partition node has the reserved packet partition node, and if so, formatting the reserved packet partition to establish a readable and writable file system;

the partition table configuration file comprises: there are two possible configuration methods, partition table information and virtual partition marking, and one of them can be selected optionally.

The configuration method 1: the virtual partition flag is configured to be null. There are two specific partitioning methods at this time:

the partition method 1: when the virtual partition mark is configured to be empty, adding a reserved packet partition in a partition table of the current old firmware, wherein the reserved packet partition is positioned behind all firmware partitions of the current partition table and in front of the last user data partition, the size of the reserved packet partition needs to be larger than the size of a firmware upgrading packet (also called as a final firmware packet) upgraded for the second time, the old partition table is provided with a reserved position, the reserved position is an unencrypted readable and writable user data area, such as a cache partition of Android, and the size of the reserved position is not smaller than the size of the difference packet; an original partition is arranged in the old partition table and is called a boot communication partition, the boot communication partition is used for communication among firmware in different stages, and the last partition of the old partition table is a user data partition;

the partition method 2 comprises the following steps: or when the virtual partition mark is configured to be empty, adding a reserved packet partition and a virtual partition before the last user data partition of the current old firmware partition table, wherein the length of the virtual partition needs to be larger than the maximum value of the size of the storage space occupied by all partitions before the last user data partition in the new platform firmware partition table to be upgraded and the size of the storage space occupied by all partitions before the last user data partition of the current old firmware partition table, the reserved packet partition is located behind the virtual partition, the starting address of the reserved packet partition is the length of the virtual partition, and the length of the reserved packet partition is larger than the size of the firmware upgrade packet upgraded for the second time. The method specifically comprises the following steps:

the starting address of the virtual partition is 0x 0; the length is the size of the storage space occupied by all the partitions before the last user data partition in the new platform firmware partition table to be upgraded, and if the length is smaller than the size of the storage space occupied by all the partitions before the last user data partition in the current old firmware partition table, the length is set to be the size of the storage space occupied by all the partitions before the last user data partition in the current old firmware partition table. That is, the length of the virtual partition needs to be greater than the maximum of: the size of the storage space occupied by all the partitions before the last user data partition in the new platform firmware partition table to be upgraded and the size of the storage space occupied by all the partitions before the last user data partition in the current old firmware partition table.

The reserved packet partition is located behind the virtual partition, the starting address of the reserved packet partition is the length of the virtual partition, and the length of the reserved packet partition needs to be the size of the firmware upgrade packet to be upgraded for the second time, namely the size of the aforementioned final firmware packet.

In the same partition method 1, it is also required that the old partition table has an unencrypted readable and writable user data area, such as an Android cache partition, and the available size of the partition needs to be stored in the area where the FOTA is first updated at least: the differential packet version of the temporary firmware packet, hereinafter referred to as the partition, is the temporary packet partition. Meanwhile, an original partition, called a boot communication partition, is required in the old partition table and is used for communication between firmware in different stages of the system, and the last partition of the old partition table is a user data partition.

The configuration method 2 comprises the following steps:

or when the virtual partition marker is not empty, the virtual partition marker comprises: a first parameter, a second parameter, and a third parameter, the first parameter representing a virtual partition mode including, but not limited to: in the mode 1 and the mode 2, the second parameter represents the size of the firmware upgrade package (i.e., the final firmware package) upgraded for the second time, and the third parameter represents the size of the storage space occupied by all partitions before the last user data area in the new platform firmware partition table to be upgraded.

After the firmware upgrade package for the first upgrade is manufactured and before the first upgrade is executed, the method specifically comprises the following steps:

judging whether the size of the firmware upgrading packet upgraded for the first time is larger than the available size of a reserved position of equipment, if so, exiting the upgrading process, if not, backing up the content of a user data area in the last subarea of a current equipment subarea table to a network server according to the requirement, storing the firmware upgrading packet upgraded for the first time in the reserved position of the current equipment, issuing a first upgrading instruction, writing the first upgrading instruction and the firmware upgrading packet upgraded for the first time in a position 1 of a guide communication subarea, and entering an upgrading mode. The method specifically comprises the following steps:

and the upgrading client interacts with the upgrading server to obtain a first-time upgraded firmware upgrading packet to be upgraded, and if the size of the first-time upgraded firmware upgrading packet is larger than the available size of the reserved position of the equipment, the upgrading process is exited. Otherwise, backing up the content of the user data area in the last partition of the current equipment partition table to a network server according to the requirement, storing the firmware upgrade package of the first upgrade in a reserved position in the current equipment, issuing a common FOTA upgrade instruction, writing the upgrade instruction and the firmware upgrade package path of the first upgrade into a position 1 of a guide communication partition, and restarting to enter an upgrade mode (recovery under Android).

When the first-time upgrading condition is met, executing first-time upgrading, wherein the step of executing first-time upgrading is to add a new partition at a preset position of the current equipment, and the new partition comprises the following steps: a reserved packet partition ", further comprising:

step S1: upgrading a new upgrade mode complete image file (recovery.img under Android) in the firmware upgrade package of the first upgrade;

step S2: reading the content of the position 2 of the boot communication partition, judging whether a success mark exists or not, if so, jumping to step S3, and if not, upgrading the new partition table of the device according to the partition table configuration file in the firmware upgrade package of the first upgrade, wherein the upgrading process of the new partition table of the upgrade device is as follows:

step S201: analyzing the partition table configuration file, checking whether a virtual partition mark exists or not, and if the virtual partition mark does not exist or the virtual partition mark is empty, updating an old partition table in the equipment according to a new partition table in the partition table configuration file;

step S202: if the virtual partition mark is not empty, further analyzing 3 parameters in the virtual partition mark, checking whether the first parameter value is a mode 1 or a mode 2, and if the first parameter value is not the mode 1 or the mode 2, updating an old partition table in the equipment according to a new partition table in the partition table configuration file;

step S2021: when the first parameter is mode 1, checking whether a new partition table in a partition table configuration file has a specific reserved packet partition, if so, directly updating an old partition table in the equipment according to the new partition table in the partition table configuration file, if not, reading the old partition table in the current equipment to obtain the initial address and the length of the last partition of the old partition table, if the sum of the initial address of the last partition and the size of the second parameter is larger than the size of the flash space available for the equipment, exiting upgrading, if the sum of the initial address of the last partition and the size of the second parameter is not larger than the size of the flash space available for the equipment, inserting a reserved packet partition before the last partition of the partition table to be upgraded, wherein the initial address of the reserved packet partition is the initial address of the last partition of the previously obtained old partition table, the length of the reserved packet partition is greater than a second parameter, and the starting address and the length of the last partition are updated at the same time, wherein the new starting address is as follows: the starting address of the reserved packet partition + the length of the reserved packet partition, the new length being: the size of the flash space available to the device- (the starting address of the reserved packet partition + the length of the reserved packet partition);

step S2022: when the first parameter is mode 2, checking whether a new partition table in the partition table configuration file has a specific virtual partition and a reserved packet partition, and if both the two partitions exist, directly updating an old partition table in the equipment according to the new partition table in the partition table configuration file; otherwise:

if the sum of the size of the third parameter and the size of the second parameter is smaller than the size of the available flash space of the device, firstly reading an old partition table in the current device, obtaining the starting address and the length of the last partition of the old partition table, then inserting two new partitions, namely a virtual partition and a reserved packet partition, before the last partition of the partition table to be upgraded, wherein the starting address of the virtual partition is 0, and the length of the virtual partition is larger than the maximum value between the third parameter and the starting address of the last partition of the old partition table obtained previously; the starting address of the reserved packet partition is the starting address of the virtual partition plus the length of the virtual partition, and the length of the reserved packet partition needs to be greater than a second parameter; and simultaneously updating the starting address and the length of the last partition, wherein the new starting address is as follows: the starting address of the reserved packet partition + the length of the reserved packet partition, the new length being: the size of the flash space available to the device-the new starting address of the last partition;

if the third parameter + the second parameter > is the size of the available flash space of the equipment, reading an old partition table in the current equipment, acquiring the initial address and the length of the last partition of the old partition table, and if the initial address of the last partition + the second parameter > the size of the available flash space of the equipment, exiting upgrading; otherwise, before the last partition of the partition table to be upgraded, a reserved packet partition is inserted, the starting address of the reserved packet partition is the starting address of the last partition of the old partition table obtained previously, and the partition length needs to be larger than the second parameter. And simultaneously updating the starting address and the length of the last partition, wherein the new starting address is as follows: the starting address of the reserved packet partition plus the length of the reserved packet partition, the new length is: the size of the flash space available to the device- ("starting address of reserved packet partition +" length of reserved packet partition ");

step S203: after the partition table is upgraded, creating a specified path from the partition table change mark file to the reserved position, setting a success mark to the position 2 of the guide communication partition, restarting the device, re-entering the upgrade mode (the upgrade mode runs an instruction in a new upgrade mode complete image file), and re-executing the step S1 and the step S2, wherein the step S3 is directly executed because the success mark exists in the position 2 of the guide communication partition at this time;

step S3: executing other upgrading operations in the upgrading packet, and updating the system partition;

step S4: before exiting the upgrade mode, a new instruction of the upgraded complete image file of the new upgrade mode in step S1 is executed, that is, whether a "partition table change mark file" (for example, last _ parameter _ update) exists in the specified path of the reserved location is checked, if so, the last user data partition of the partition table is reformatted, the file system is reestablished, and meanwhile, whether a "reserved packet partition" node exists in the device partition node is checked, if so, the "reserved packet partition" is formatted, a readable and writable file system is established, and finally, a "reserved partition success mark file" is established in the specified path of the "temporary packet partition".

Step S5: and clearing the content of the position 1 of the boot communication partition and the position 2 of the communication partition, and restarting the system after the firmware upgrade package which enters the first upgrade is upgraded.

After the first upgrade is finished and before the second upgrade is started, the method specifically comprises the following steps:

mounting the newly added reserved packet partition;

judging whether a reserved partition success marking file exists in the appointed path of the reserved position, if not, exiting the program, and if so, acquiring a firmware upgrade package of the second upgrade and storing the firmware upgrade package into the reserved package partition;

and deleting the partition table change mark file and the reserved partition success mark file under the reserved position appointed path, writing a second upgrading instruction and a second upgraded firmware upgrading packet path in the position 1 of the guide communication partition, and entering the second upgrading. The method specifically comprises the following steps:

and entering a system after the upgrade of the temporary firmware package, and mounting the newly added reserved package partition.

The upgrading client checks whether a reserved partition success marking file exists in a designated path of a reserved position, if yes, the upgrading client interacts with an upgrading server to obtain a new platform firmware complete package to be upgraded, which is finally used for upgrading, namely a firmware upgrading package for second upgrading, the name, the size, the partition number and the like of each partition in a partition table of the firmware upgrading package for second upgrading can be completely different from those of a partition table of current equipment, but the last partition of the partition table is required to be a user data partition, and a guiding communication partition exists. And the upgrading client stores the acquired firmware upgrading packet for the second upgrading into a reserved packet partition, deletes the partition table change marking file and the reserved partition success marking file under the appointed path of the reserved position, finally writes a cross-platform complete upgrading instruction and the path of the firmware upgrading packet for the second upgrading into the position 1 of the guide communication partition, and restarts to enter an upgrading mode.

The second upgrade process is as follows:

the "performing the second upgrade, reading the firmware upgrade package of the second upgrade, storing the firmware upgrade package of the second upgrade in the device Memory, and performing the upgrade operation based on the firmware upgrade package of the second upgrade in the device Memory" specifically includes the following steps:

in the upgrading mode, the upgrading program reads the content of the position 1 of the guide communication partition, and triggers the second upgrading according to the second upgrading instruction, namely, triggers the cross-platform complete upgrading process according to the cross-platform complete upgrading instruction stored in the second upgrading instruction:

mounting a reserved packet partition, judging whether a firmware upgrading packet upgraded for the second time in the reserved packet partition exists, if not, exiting the upgrading process, and if so, judging whether a virtual partition exists through an equipment partition node;

if the virtual partition does not exist, calculating the size of the firmware upgrading packet upgraded for the second time, judging whether the size of the firmware upgrading packet upgraded for the second time is larger than the available Memory of the current equipment, if so, exiting, otherwise, newly building a temporary file in the Memory, copying the content of the firmware upgrading packet upgraded for the second time to the temporary file, finally pointing the path of the firmware upgrading packet upgraded for the second time to the newly-built temporary file in the Memory, upgrading a new partition table in a flash storage medium of the equipment according to the content of the firmware upgrading packet upgraded for the second time in the Memory, upgrading all new firmware according to a firmware image in the firmware upgrading packet upgraded for the second time, and completing the complete upgrading of the firmware of the equipment;

if the virtual partition exists, upgrading the new platform firmware to the virtual partition, and performing upgrading operation on the virtual partition through the second upgraded firmware upgrading package, specifically comprising the following steps:

if the virtual partition exists, upgrading a part of flash storage media represented by the virtual partition according to a firmware upgrading package upgraded for the second time in the reserved package partition, wherein the upgrading process comprises the following steps: and after all the new firmware is upgraded, extracting the partition table in the firmware upgrading package upgraded for the second time again, and directly upgrading the formal partition table without modifying the extracted partition table to finish the complete upgrading of the equipment firmware.

And after the upgrade is finished, entering a new system contained in the firmware upgrade package of the second upgrade, and restoring the data backed up in the network to a user data area corresponding to the equipment by the client according to the requirement.

The whole flow chart of the implementation of the above method is shown in fig. 2, wherein the flow chart of the new partition table of the device upgraded according to the partition table configuration file in the firmware upgrade package of the first upgrade is shown in fig. 3.

The method realizes the change and upgrade of the whole storage medium of the equipment by two times of FOTA without the help of an external storage medium (SD/TF card or U disk), supports the arbitrary change of the partition table, overcomes the dependence on the external storage medium, and meets the FOTA firmware upgrade requirements of certain special scenes. The method solves the problem that in the FOTA upgrading process supporting the arbitrary change of the partition table when the whole device flash storage medium needs to be changed arbitrarily, the firmware upgrading package needs to be stored by means of an external storage medium because the whole flash storage medium is invalid in the upgrading process and the firmware upgrading package in any form cannot be stored in the device flash.

Referring to fig. 4, in the present embodiment, a memory device 400 is implemented as follows:

a storage device 400 having stored therein a set of instructions for performing: any step in a firmware upgrade method mentioned above.

It should be noted that, although the above embodiments have been described herein, the invention is not limited thereto. Therefore, based on the innovative concepts of the present invention, the technical solutions of the present invention can be directly or indirectly applied to other related technical fields by making changes and modifications to the embodiments described herein, or by using equivalent structures or equivalent processes performed in the content of the present specification and the attached drawings, which are included in the scope of the present invention.

17页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种Android平台上生产预置更新方法、装置、设备和介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!