Method, device and computer readable storage medium for over-the-air upgrade
Patent Information
- Application Number
- CN202111163417.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2041-09-30
AI Technical Summary
In existing technologies, embedded devices are not allowed to modify the Flash partition table when upgrading via over-the-air download, which can lead to data loss or system failure.
An over-the-air (OTA) upgrade method is provided, which detects whether partition table information needs to be changed and updates the partition table information when necessary, including deleting, adding or adjusting partition sizes, to ensure that the normal use of the device is not affected during the upgrade process.
It enables over-the-air download and upgrade without loss of backup data and resolves the issue of subsequent adjustments caused by improper initial partitioning planning.
Smart Images

Figure CN115904424B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to over-the-air (OTA) upgrade technology, and in particular to an OTA upgrade method, apparatus, and computer-readable storage medium. Background Technology
[0002] Currently, embedded devices already in mass production on the market are not allowed to change the Flash partition table during over-the-air upgrades. The reason given is that changing the partition table will prevent data from being read normally from all partitions, leading to the loss of important device information or even causing the system to fail to boot. Summary of the Invention
[0003] In view of the above, it is necessary to provide an over-the-air (OTA) upgrade method, apparatus, and computer-readable storage medium that can solve the problem of OTA upgrade partition table changes without affecting normal device use or causing data loss.
[0004] This invention provides an over-the-air (OTA) upgrade method applied to a device. The method includes: when an OTA upgrade is detected, detecting and determining whether existing partition table information needs to be changed; when the partition table information does not need to be changed, performing an OTA upgrade on the existing partition table information; when the partition table information needs to be changed, updating the partition table information according to the partition table change scenario, and performing an OTA upgrade according to the updated partition table information.
[0005] Optionally, the partition table modification scenarios include deleting a partition, adding a partition, increasing the size of an existing partition, and decreasing the size of an existing partition.
[0006] Optionally, the device includes a MIBIB partition, which includes a first region, a second region, and a third region.
[0007] Optionally, the first area is used to store whether the partition table needs to be changed during over-the-air download upgrades and the currently used partition table, while the second and third areas are used to store different partition tables.
[0008] Optionally, when the partition table change scenario involves deleting a partition, the method further includes: Determine the size of the target partition to be deleted; if the target partition to be deleted is smaller than a preset threshold, retain and erase the target partition; if the target partition to be deleted is not smaller than the preset threshold, merge the target partition to be deleted into a neighboring partition and update the partition table information to the MIBIB partition.
[0009] Optionally, when the partition table change scenario is the addition of a new partition, the method further includes: determining whether there is a deleted partition before the addition of the new partition; if there is a deleted partition and the size of the new partition is smaller than the size of the deleted partition, the new partition is directly added to the interval where the deleted partition is located, and the partition table information is updated to the MIBIB partition; otherwise, the new partition is added to the last partition, and the partition table information is updated to the MIBIB partition.
[0010] Optionally, when the partition table change scenario is to expand the size of an existing partition, the method further includes: merging the target partition into an adjacent partition, determining whether the merged partition can meet the preset requirements, and if so, updating the partition table information to the MIBIB partition; if not, deleting the target partition, adding a new partition to the last partition, and updating the partition table information to the MIBIB partition.
[0011] Optionally, when the partition table change scenario is to reduce the size of an existing partition, the method further includes: taking a partition from the target partition as a new partition and updating the partition table information to the MIBIB partition; or taking a partition from the target partition as a new partition, merging the new partition into adjacent partitions, and updating the partition table information to the MIBIB partition.
[0012] This invention also provides an apparatus comprising a memory, a processor, and an over-the-air (OTA) upgrade program stored in the memory and executable on the processor. When the access point switching program is executed by the processor, it implements the steps of the OTA upgrade method as described above.
[0013] This invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the over-the-air (OTA) upgrade method described above.
[0014] Compared to existing technologies, the aforementioned over-the-air upgrade method, apparatus, and computer-readable storage medium can solve the problem of embedded devices changing partition tables through over-the-air upgrades without losing backup data. It can also solve the problem of embedded devices needing to adjust partitioning later due to poor initial partitioning planning. Attached Figure Description
[0015] Figure 1 This is a diagram illustrating the operating environment of a device according to a preferred embodiment of the present invention.
[0016] Figure 2 This is a program module diagram of a preferred embodiment of the over-the-air (OTA) upgrade system for the router of the present invention.
[0017] Figure 3This is a flowchart of an over-the-air (OTA) upgrade method according to a preferred embodiment of the present invention.
[0018] Figure 4 This is a structural diagram of the partition table in a preferred embodiment of the present invention.
[0019] Figure 5 This is a scenario diagram of partition table changes during partition deletion according to a preferred embodiment of the present invention.
[0020] Figure 6 This is a scenario diagram of partition table changes for adding a new partition according to a preferred embodiment of the present invention.
[0021] Figure 7 This is a scenario diagram illustrating a preferred embodiment of the present invention involving a partition table modification that expands the size of an existing partition.
[0022] Figure 8 This is a scenario diagram illustrating a preferred embodiment of the present invention involving partition table changes that reduce the size of existing partitions.
[0023] Explanation of main component symbols The following detailed description, in conjunction with the accompanying drawings, will further illustrate this application. Detailed Implementation
[0024] See Figure 1 The diagram shown illustrates the operating environment of a preferred embodiment of device 1 according to the present invention. Device 1 includes an over-the-air (OTA) upgrade system 10. Device 1 also includes a memory 20 and a processor 30, etc.
[0025] The memory 20 includes at least one type of readable storage medium, such as flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. The processor 30 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip.
[0026] See Figure 2 The diagram shown is a program block diagram of a preferred embodiment of the over-the-air download upgrade system 10 of the present invention.
[0027] The over-the-air (OTA) upgrade system 10 includes a judgment module 101, a first upgrade module 102, and a second upgrade module 103. The modules are configured to be executed by one or more processors (in this embodiment, one processor 30) to complete the invention. A module, as referred to in this invention, is a computer program segment that executes a specific instruction. The memory 20 is used to store program code and other data of the OTA upgrade system 10. The processor 30 is used to execute the program code stored in the memory 20.
[0028] The judgment module 101 is used to detect and determine whether the existing partition table information needs to be changed when an over-the-air download upgrade is detected. If the partition table information does not need to be changed, step S302 is executed; if the partition table information needs to be changed, step S304 is executed.
[0029] Over-the-Air (OTA) technology refers to a general term for remote upgrade technologies, including Firmware-over-the-air (FOTA) and Software-over-the-air (SOTA). FOTA is for firmware upgrade packages or upgrades to Narrow Band Internet of Things (NB-IoT) modules. SOTA is for application software upgrades on terminals or for upgrading microcontroller units (MCUs) via NB-IoT modules.
[0030] The device 1 includes a MIBIB partition, which comprises a first region, a second region, and a third region. For example... Figure 4 The MIBIB partition comprises three areas. The first area is Logic data, used to store whether the partition table needs to be changed during over-the-air (OTA) upgrades and the currently used partition table. The second and third areas are Partition layout 1 and Partition layout 2, respectively, used to store different partition tables. The Logic data in the first area indicates whether the partition table needs to be changed and whether Partition layout 1 or Partition layout 2 is currently being used.
[0031] In this embodiment, the partition information is detected by reading relevant data from the logic data to determine whether the partition table needs to be changed during the upgrade. This data is already recorded in the logic data area when the OTA image is packaged. After the OTA upgrade, the partition table information needs to be updated. The logic data area records which partition table should be used for booting after the upgrade. For example, a field named "flag" is defined in the logic data. When "flag=1" is read, it indicates that the partition table needs to be changed, and when "flag=0" is read, it indicates that the partition table does not need to be changed. In this embodiment, the logic data is defined by the developers and is not limited to this embodiment.
[0032] When the judgment module 101 determines that the partition table information does not need to be changed, the first upgrade module 102 is used to perform an over-the-air upgrade based on the existing partition table information.
[0033] Specifically, if Partition layout 1 is currently being used, the system will boot according to Partition layout 1 after an over-the-air upgrade. If Partition layout 2 is currently being used, the system will boot according to Partition layout 2 after an over-the-air upgrade.
[0034] When the judgment module 101 determines that the partition table information needs to be changed, the second upgrade module 103 is used to update the partition table information according to the partition table change scenario, and perform an over-the-air download upgrade according to the updated partition table information.
[0035] In this embodiment, the partition table modification scenarios include deleting partitions, adding partitions, increasing the size of existing partitions, and decreasing the size of existing partitions. After device 1 is powered on, the updated partition table information will be used.
[0036] When the partition table change scenario is partition deletion, the method further includes: The size of the target partition to be deleted is determined; if the target partition is smaller than a preset threshold, the target partition is retained and erased. In this case, no changes to the partition table are needed; the partition is simply no longer accessed. Therefore, the first area displays "No need to change the partition table," meaning the logic data indicates that no changes to the partition table are required.
[0037] When the target partition to be deleted is not smaller than a preset threshold, the target partition to be deleted is merged into a neighboring partition, and the partition table information is updated in the MIBIB partition. Specifically, depending on actual needs, it can be merged into the previous partition or the next partition, in which case the partition table information must be updated.
[0038] like Figure 5As shown in Figure A, the data partition is the partition to be deleted. If the data partition size is below a preset threshold, the data partition is retained; only the data in the data partition is erased, and the logic data information does not need to be changed. If the data partition size is below the preset threshold, then the data partition needs to be merged into a neighboring partition. For example, in Figure B, the data partition is merged into the previous partition, the boot partition, or in Figure C, the data partition is merged into the next partition, the modem partition. Whether merging into the previous partition, the boot partition, or the next partition, the modem partition, the logic data information needs to be changed, indicating that the partition table information needs to be updated.
[0039] When the partition table change scenario is the addition of a new partition, the method further includes: determining whether there is a deleted partition before the addition of the new partition; when there is a deleted partition and the size of the new partition is smaller than the size of the deleted partition, the new partition is directly added to the interval where the deleted partition is located, and the partition table information is updated to the MIBIB partition. Otherwise, if there is no partition to be deleted, or if the size of the new partition is not less than the size of the deleted partition, the new partition will be added to the last partition, and the partition table information will be updated to the MIBIB partition.
[0040] For example, such as Figure 6 As shown in Figure A, when a deleted partition (data partition) exists, and the size of the newly added partition (Newpartition) is smaller than the size of the deleted partition (data partition), the newly added partition (Newpartition) is directly added to the interval where the deleted partition (data partition) is located, and the partition table information is updated in the logicdata of the MIBIB partition.
[0041] That is, when there is no partition to be deleted, or when the size of the new partition is not less than the size of the deleted data partition, the new partition is added to the last partition, the system partition, and the partition table information is updated in the logic data of the MIBIB partition.
[0042] For example, in the backup area, as the number of customers increases, the amount of data that needs to be backed up also increases, necessitating the expansion of the backup partition. When the partition table change scenario involves expanding the size of an existing partition, the method further includes: The target partition is merged into a neighboring partition. It is then determined whether the merged partition can meet the preset requirements. If it can, the partition table information is updated to the MIBIB partition. If not, the target partition is deleted, a new partition is added to the last partition, and the partition table information is updated to the MIBIB partition.
[0043] For example, such as Figure 7 As shown in Figure A, the EFS partition is merged into the adjacent boot partition (the boot partition can be placed in the last partition, the system partition). It is then determined whether the merged EFS partition meets the preset requirements. If it does, the partition table information is updated in the logic data of the MIBIB partition. If not, as in Figure B, the EFS partition is deleted, a new EFS partition is added to the last partition, the system partition, and the partition table information is updated in the logic data of the MIBIB partition.
[0044] When the partition table change scenario involves reducing the size of an existing partition, the method further includes: Alternatively, a new partition can be created from the target partition and its partition table information can be updated in the MIBIB partition (specifically, this is unnecessary if the new partition has no other purpose); or a new partition can be created from the target partition and its partition table information can be merged into the adjacent partitions and its partition table information can be updated in the MIBIB partition.
[0045] For example, such as Figure 8 As shown in Figure A, a new partition (New Partition) is created from the EFS partition and updated to the logic data of the MIBIB partition. In Figure B, a new partition (not shown in the figure) is created from the EFS partition and merged into the data partition. The partition table information is then updated to the logic data of the MIBIB partition.
[0046] By applying the above method to the above device, the problem of changing the partition table of embedded devices through OTA upgrades without causing the loss of backup data can be solved. It can also solve the problem of embedded devices needing to be adjusted later due to poor initial partition planning.
[0047] See Figure 3 The diagram shown is a flowchart of an over-the-air (OTA) upgrade method according to a preferred embodiment of the present invention. The OTA upgrade method is applied to device 1. The OTA upgrade method can be executed by the processor 30. Figure 2 It is implemented by modules 101 to 103 shown.
[0048] Step S300: When an over-the-air (OTA) upgrade is detected, check and determine whether the existing partition table information needs to be changed. If the partition table information does not need to be changed, proceed to step S302; if the partition table information needs to be changed, proceed to step S304.
[0049] Over-the-Air (OTA) technology refers to a general term for remote upgrade technologies, including Firmware-over-the-air (FOTA) and Software-over-the-air (SOTA). FOTA is for firmware upgrade packages or upgrades to Narrow Band Internet of Things (NB-IoT) modules. SOTA is for application software upgrades on terminals or for upgrading microcontroller units (MCUs) via NB-IoT modules.
[0050] The device 1 includes a MIBIB partition, which comprises a first region, a second region, and a third region. For example... Figure 4 The MIBIB partition comprises three areas. The first area is Logic data, used to store whether the partition table needs to be changed during over-the-air (OTA) upgrades and the currently used partition table. The second and third areas are Partition layout 1 and Partition layout 2, respectively, used to store different partition tables. The Logic data in the first area indicates whether the partition table needs to be changed and whether Partition layout 1 or Partition layout 2 is currently being used.
[0051] In this embodiment, the partition information is detected by reading relevant data from the logic data to determine whether the partition table needs to be changed during the upgrade. This data is already recorded in the logic data area when the OTA image is packaged. After the OTA upgrade, the partition table information needs to be updated. The logic data area records which partition table should be used for booting after the upgrade. For example, a field named "flag" is defined in the logic data. When "flag=1" is read, it indicates that the partition table needs to be changed, and when "flag=0" is read, it indicates that the partition table does not need to be changed. In this embodiment, the logic data is defined by the developers and is not limited to this embodiment.
[0052] Step S302: Perform an over-the-air upgrade based on the existing partition table information.
[0053] Specifically, if Partition layout 1 is currently being used, the system will boot according to Partition layout 1 after an over-the-air upgrade. If Partition layout 2 is currently being used, the system will boot according to Partition layout 2 after an over-the-air upgrade.
[0054] Step S304: Update the partition table information according to the partition table change scenario, and perform an over-the-air upgrade based on the updated partition table information.
[0055] In this embodiment, the partition table modification scenarios include deleting partitions, adding partitions, increasing the size of existing partitions, and decreasing the size of existing partitions. After device 1 is powered on, the updated partition table information will be used.
[0056] When the partition table change scenario is partition deletion, the method further includes: The size of the target partition to be deleted is determined; if the target partition is smaller than a preset threshold, the target partition is retained and erased. In this case, no changes to the partition table are needed; the partition is simply no longer accessed. Therefore, the first area displays "No need to change the partition table," meaning the logic data indicates that no changes to the partition table are required.
[0057] When the target partition to be deleted is not smaller than a preset threshold, the target partition to be deleted is merged into a neighboring partition, and the partition table information is updated in the MIBIB partition. Specifically, depending on actual needs, it can be merged into the previous partition or the next partition, in which case the partition table information must be updated.
[0058] like Figure 5 As shown in Figure A, the data partition is the partition to be deleted. If the data partition size is below a preset threshold, the data partition is retained; only the data in the data partition is erased, and the logic data information does not need to be changed. If the data partition size is below the preset threshold, then the data partition needs to be merged into a neighboring partition. For example, in Figure B, the data partition is merged into the previous partition, the boot partition, or in Figure C, the data partition is merged into the next partition, the modem partition. Whether merging into the previous partition, the boot partition, or the next partition, the modem partition, the logic data information needs to be changed, indicating that the partition table information needs to be updated.
[0059] When the partition table change scenario is the addition of a new partition, the method further includes: determining whether there is a deleted partition before the addition of the new partition; when there is a deleted partition and the size of the new partition is smaller than the size of the deleted partition, the new partition is directly added to the interval where the deleted partition is located, and the partition table information is updated to the MIBIB partition. Otherwise, if there is no partition to be deleted, or if the size of the new partition is not less than the size of the deleted partition, the new partition will be added to the last partition, and the partition table information will be updated to the MIBIB partition.
[0060] For example, such as Figure 6 As shown in Figure A, when a deleted partition (data partition) exists, and the size of the newly added partition (Newpartition) is smaller than the size of the deleted partition (data partition), the newly added partition (Newpartition) is directly added to the interval where the deleted partition (data partition) is located, and the partition table information is updated in the logicdata of the MIBIB partition.
[0061] That is, when there is no partition to be deleted, or when the size of the new partition is not less than the size of the deleted data partition, the new partition is added to the last partition, the system partition, and the partition table information is updated in the logic data of the MIBIB partition.
[0062] For example, in the backup area, as the number of customers increases, the amount of data that needs to be backed up also increases, necessitating the expansion of the backup partition. When the partition table change scenario involves expanding the size of an existing partition, the method further includes: The target partition is merged into a neighboring partition. It is then determined whether the merged partition can meet the preset requirements. If it can, the partition table information is updated to the MIBIB partition. If not, the target partition is deleted, a new partition is added to the last partition, and the partition table information is updated to the MIBIB partition.
[0063] For example, such as Figure 7 As shown in Figure A, the EFS partition is merged into the adjacent boot partition (the boot partition can be placed in the last partition, the system partition). It is then determined whether the merged EFS partition meets the preset requirements. If it does, the partition table information is updated in the logic data of the MIBIB partition. If not, as in Figure B, the EFS partition is deleted, a new EFS partition is added to the last partition, the system partition, and the partition table information is updated in the logic data of the MIBIB partition.
[0064] When the partition table change scenario involves reducing the size of an existing partition, the method further includes: Alternatively, a new partition can be created from the target partition and its partition table information can be updated in the MIBIB partition (specifically, this is unnecessary if the new partition has no other purpose); or a new partition can be created from the target partition and its partition table information can be merged into the adjacent partitions and its partition table information can be updated in the MIBIB partition.
[0065] For example, such as Figure 8As shown in Figure A, a new partition (New Partition) is created from the EFS partition and updated to the logic data of the MIBIB partition. In Figure B, a new partition (not shown in the figure) is created from the EFS partition and merged into the data partition. The partition table information is then updated to the logic data of the MIBIB partition.
[0066] By applying the above method to the above device, the problem of changing the partition table of embedded devices through OTA upgrades without causing the loss of backup data can be solved. It can also solve the problem of embedded devices needing to be adjusted later due to poor initial partition planning.
[0067] It is worth noting that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. An over-the-air (OTA) upgrade method, applied to a device, characterized in that, The method includes: When an over-the-air (OTA) upgrade is detected, the system checks and determines whether the existing partition table information needs to be changed. When the partition table information does not need to be changed, an over-the-air upgrade is performed based on the existing partition table information. When the partition table information needs to be changed, the partition table information is updated according to the partition table change scenario, and an over-the-air download upgrade is performed according to the updated partition table information. The device includes a MIBIB partition, which includes a first region, a second region, and a third region. The first region is used to store whether the partition table needs to be changed during over-the-air (OTA) upgrades and whether the currently used partition table is the one stored in the second region or the third region. The second region and the third region are used to store different partition tables. The partition table change scenarios include deleting a partition, adding a partition, increasing the size of an existing partition, and decreasing the size of an existing partition.
2. The over-the-air (OTA) upgrade method as described in claim 1, characterized in that, When the partition table change scenario is partition deletion, the method further includes: Determine the size of the target partition to be deleted; When the target partition to be deleted is smaller than a preset threshold, the target partition is retained and erased. When the target partition to be deleted is not less than a preset threshold, the target partition to be deleted is merged into a neighboring partition, and the partition table information is updated to the MIBIB partition.
3. The over-the-air (OTA) upgrade method as described in claim 1, characterized in that, When the partition table change scenario involves adding a new partition, the method further includes: Determine if any partitions were deleted before the new partition was created; When a deleted partition exists and the size of the new partition is smaller than the size of the deleted partition, the new partition is directly added to the interval where the deleted partition is located, and the partition table information is updated to the MIBIB partition. Otherwise, add the new partition to the last partition and update the partition table information to the MIBIB partition.
4. The over-the-air (OTA) upgrade method as described in claim 1, characterized in that, When the partition table change scenario involves expanding the size of an existing partition, the method further includes: Merge the target partition into a neighboring partition, determine whether the merged partition can meet the preset requirements, and if so, update the partition table information to the MIBIB partition. If not, delete the target partition, add a new partition to the last partition, and update the partition table information to the MIBIB partition.
5. The over-the-air (OTA) upgrade method as described in claim 1, characterized in that, When the partition table change scenario involves reducing the size of an existing partition, the method further includes: Treat a new partition as a separate partition from the target partition, and update the partition table information in the MIBIB partition; or Take a partition from the target partition as a new partition, merge the new partition into the adjacent partitions, and update the partition table information to the MIBIB partition.
6. An apparatus, characterized in that, The apparatus includes a memory, a processor, and an over-the-air (OTA) update program stored in the memory and executable on the processor, wherein the OTA update program, when executed by the processor, implements the steps of the OTA update method as described in any one of claims 1 to 5.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the over-the-air (OTA) upgrade method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
System upgrade method and system upgrade device
CN103176824A
Subarea adjustment method, device, terminal, server and system
CN103455348A
