Memory read / write-based embedded system upgrade method and apparatus
By reading memory partition data from the embedded system to the host computer and handling bad blocks and erased pages, the problem of data loss and corruption caused by changes in memory partitions is solved, enabling smooth upgrades of the embedded system.
Patent Information
- Application Number
- PCT/CN2025/096705
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-05-24
- Filing Date
- 2025-05-23
- Publication Date
- 2025-11-27
AI Technical Summary
During the upgrade process of an embedded system, changes in memory partitions may lead to the loss of backup data and misplacement of partition data, resulting in system upgrade failure.
By calling the read interface of the embedded system's memory, the partition data is backed up to the host computer, and after the upgrade, the write interface is called to restore the data to the memory. Bad blocks and erased pages are detected and processed to ensure data integrity and correctness.
This avoids the problem of backup data loss caused by changes in storage partitions, ensures data integrity and correct restoration during system upgrades, and achieves a smooth upgrade.
Smart Images

Figure CN2025096705_27112025_PF_FP_ABST
Abstract
Description
Embedded system upgrading method and device based on memory read and write
[0001] Reference of Related Applications
[0002] The present disclosure claims the full benefit of the Chinese Patent Application No. 202410657901.1, filed on May 24, 2024, entitled “Embedded system upgrading method and device based on memory read and write”, and incorporates by reference the entire contents of the Chinese Patent Application.
[0003] TECHNICAL FIELD
[0004] The present disclosure generally relates to the technical field of embedded systems, and more particularly to an embedded system upgrading method and device based on memory read and write.
[0005] BACKGROUND
[0006] The memory in an embedded system generally uses multiple partitions for data storage. Before upgrading, the embedded system needs to backup data to the memory or other devices. During the system upgrading process, the partitions of the memory can change. If the backup data is in the memory, the backup data cannot be guaranteed not to be lost in the case of partition changes. In addition, partition changes can also cause data position disorder when restoring the partition data to the memory, resulting in system upgrade failure.
[0007] SUMMARY
[0008] In a first aspect, the present disclosure provides an embedded system upgrading method based on memory read and write, comprising:
[0009] calling a read interface of a memory in an embedded system to read all partition data of the memory, and backing up the partition data to an upper computer;
[0010] calling a write interface of the memory to write an upgrade firmware to the memory to complete the upgrade of the embedded system; and
[0011] calling the write interface to restore the partition data in the upper computer to the memory, and detecting and processing bad blocks and erase pages of the partition data.
[0012] In some embodiments, detecting and processing the bad blocks and erase pages of the partition data comprises:
[0013] checking whether there is a bad block in the partition data according to a preset bad block identifier;
[0014] if there is no bad block in the partition data, checking whether there is an erase page in the partition data according to a preset erase page identifier, wherein the erase page is empty.
[0015] If there is an erase page in the partition data, then according to the start and end positions of the erase page, setting content is written at the position where the erase page is located in the memory, wherein the setting content indicates that the position is an erase page.
[0016] In some implementations, after checking for bad blocks in the partitioned data, the method further includes:
[0017] If bad blocks exist in the partition data, the partition data corresponding to the bad blocks will be filtered out when restoring the partition data to the memory, and the location of the bad blocks will be retained in the memory.
[0018] In some implementations, writing upgrade firmware to the memory by calling the memory's write interface includes:
[0019] Obtain the partition table file carried by the upgraded firmware, wherein the partition table file includes firmware partition information and data partition information;
[0020] Determine the partition capacity of each partition in the data partition information;
[0021] If the partition capacity of each partition is greater than or equal to the data storage size of the corresponding partition in the partition data, then according to the firmware partition information, the write interface of the memory is called to write the upgrade firmware into the memory.
[0022] In some implementations, after determining the partition capacity of each partition in the data partitioning information, the method further includes:
[0023] If the capacity of any partition is less than the data storage size of the corresponding partition in the partition data, then the embedded system cannot be upgraded.
[0024] In some implementations, calling the write interface to restore the partition data in the host computer to the memory includes:
[0025] Determine the file identifier of the backup file containing the partition data in the host computer, wherein each file identifier corresponds to a partition of the memory before the system upgrade;
[0026] Determine all partition identifiers in the data partition information after the system upgrade;
[0027] According to the correspondence between file identifiers and partition identifiers, the write interface is called to restore the partition data in the host computer to each partition of the memory.
[0028] In some embodiments, the method further includes:
[0029] When the partition data is backed up to the host computer, the entire partition data of the memory is read as the minimum unit of block;
[0030] When the partition data is restored to the memory, the partition data is written to the memory as the minimum unit of block.
[0031] In a second aspect, the present disclosure provides an embedded system upgrading device based on memory read and write, which comprises:
[0032] The reading module is configured to call the read interface of the memory in the embedded system, read the entire partition data of the memory, and backup the partition data to the host computer;
[0033] The upgrading module is configured to call the write interface of the memory to write the upgrading firmware to the memory, so as to complete the upgrading of the embedded system;
[0034] The restoring module is configured to call the write interface to restore the partition data in the host computer to the memory, and detect and process the bad block and the erased page of the partition data.
[0035] In a third aspect, the present disclosure provides an electronic device, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete the communication among each other through the communication bus; the memory is configured to store a computer program; the processor is configured to execute the program stored on the memory, so as to realize the embedded system upgrading method based on memory read and write provided by the present disclosure.
[0036] In a fourth aspect, the present disclosure further provides a computer storage medium, which stores computer executable instructions, and the computer executable instructions are used to execute the embedded system upgrading method based on memory read and write provided by the present disclosure.
[0037] In some embodiments, the partition data backed up in the present disclosure is transferred by the host computer, so that the problem of backup data loss caused by the change of memory partition during the upgrading of the embedded system can be avoided. In some embodiments, the present disclosure also processes the bad block and the erased page during the data restoring process, so as to avoid the disorder of data restoring. The present disclosure ensures the completeness and correctness of data during the upgrading of the system, and realizes the smooth upgrading of the system.
[0038] BRIEF DESCRIPTION OF DRAWINGS
[0039] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present disclosure and serve to explain the principles of the present disclosure together with the specification.
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required by the embodiments will be briefly introduced as follows. Obviously, for those of ordinary skill in the art, other drawings can be obtained based on these drawings without any creative effort.
[0041] One or more embodiments are illustrated by way of example with reference to the drawings, which are not limiting of the embodiments, and which illustrate the principles and operations of the embodiments. Like reference numbers refer to like elements throughout the drawings. The figures are not necessarily to scale, the emphasis instead being placed upon illustrating the principles of the embodiments.
[0042] Fig. 1 is a flowchart of a method for upgrading an embedded system based on memory read and write according to an embodiment of the present disclosure;
[0043] Fig. 2 is a schematic diagram of a method for upgrading an embedded system based on memory read and write according to an embodiment of the present disclosure;
[0044] Fig. 3 is a schematic diagram of a method for partition data backup and restoration according to an embodiment of the present disclosure;
[0045] Fig. 4 is a schematic diagram of a structure of an apparatus for upgrading an embedded system based on memory read and write according to an embodiment of the present disclosure; and
[0046] Fig. 5 is a schematic diagram of a structure of an electronic device according to an embodiment of the present disclosure.
[0047] Detailed description
[0048] In order to make the objects, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, any other embodiments obtained by those of ordinary skill in the art without any creative effort belong to the scope of the present disclosure.
[0049] The following disclosure provides many different embodiments, or examples, for implementing different structures of the present disclosure. For the purpose of simplicity, the components and arrangements of the various examples are shown in the following description. These are, of course, merely examples and are not intended to limit the present disclosure. Moreover, the present disclosure can be practiced with other specific arrangements also. The described embodiments are to be considered in a descriptive sense only and not for purposes of limitation. The present disclosure is directed to each individual feature, structure, characteristic, and / or property of the various examples described herein. In addition, any combination of two or more such features, structures, characteristics, and / or properties can be made unless otherwise stated.
[0050] The present disclosure provides a method for upgrading an embedded system based on memory read and write, which is applied to an upgrade tool. As shown in Fig. 1, the method comprises the following steps:
[0051] Step 101: calling a read interface of a memory in an embedded system to read all partition data of the memory and backup the partition data to an upper computer;
[0052] Step 102: calling a write interface of the memory to write the upgrade firmware into the memory to complete the upgrade of the embedded system; and
[0053] Step 103: calling the write interface to restore the partition data in the upper computer to the memory and detect and process bad blocks and erased pages in the partition data.
[0054] The upgrade tool reads all partition data of the memory and backs up the all partition data to the upper computer, then writes the upgrade firmware into the memory to complete the upgrade of the embedded system, and restores the partition data in the upper computer to the memory, and detects and processes bad blocks and erased pages in the partition data when restoring the data. The bad block in the disclosure refers to a used bad block caused by wear during use, and the content in the erased page is blank. The bad block and the erased page will cause data errors when restoring the data, so the bad block and the erased page need to be processed. The specific processing method is described in detail below, which is not repeated here.
[0055] In some embodiments, the upper computer refers to a device capable of running the upgrade tool and having a storage function, such as a mobile phone, a tablet, a computer, etc. The disclosure can be applied to devices using embedded systems, such as smart home appliances, smart cameras, car navigation, portable medical instruments, robots, etc. The embedded device can be applied in the fields of aerospace, security systems, transportation, military equipment, Internet of Things, etc.
[0056] In some embodiments, the partition data backed up in the disclosure is transferred by the upper computer, which can avoid the problem of loss of backup data caused by changes in memory partitions during the upgrade of the embedded system. In some embodiments, the disclosure also processes bad blocks and erased pages during data restoration to avoid data restoration disorder. The disclosure ensures that the data is complete and correct during system upgrade, and realizes smooth system upgrade.
[0057] In the related art, data backup and restoration based on a file system has the following problems: 1. Different file systems of different subsystems are difficult to implement with the same interface; 2. A large number of interfaces need to be provided for mutual access between file systems of different subsystems; 3. Different data files have different permissions, and an additional subsystem needs to be provided to support the permissions of the backup files; and 4. The file list contains data required by each customer, but the data required by the customer changes in real time, and if the data of a single customer is to be backed up, the file list needs to be refreshed from time to time, resulting in reduced efficiency. In the present disclosure, a unified read interface and write interface are set in the underlying storage, that is, data reading and writing are implemented at the drive layer of the embedded system, bypassing the embedded subsystem and the file system, and the interface is unified, which can avoid the problems of providing a large number of interfaces and increasing an additional subsystem caused by the file system. In addition, all partition data is backed up in the present disclosure, and there is no need to consider the problem of updating the data of a single customer, that is, there is no need to refresh the file list, zero maintenance cost is achieved, and system upgrade efficiency is improved.
[0058] In the related art, data backup and restoration based on an embedded system APP has the following problems: 1. The data backed up by the APP needs to separately occupy storage space; 2. The backup data is in the storage, and changes in the storage partition may cause data loss; and 3. The file list of the backup is fixed and cannot be changed. In the present disclosure, the data is backed up to the host computer, and there is no need to occupy storage space, and there is no problem of data loss caused by changes in the storage partition, and the partition data in the present disclosure can change and have real-time performance, solving the problem of fixed and unchangeable data in the related art.
[0059] In some embodiments, the checking and processing of the bad blocks and the erase pages of the partition data in the host computer include: checking whether there is a bad block in the partition data according to a preset bad block identifier; if there is no bad block in the partition data, checking whether there is an erase page in the partition data according to a preset erase page identifier, wherein the erase page is empty; and if there is an erase page in the partition data, writing a set content at a position of the storage erase page according to a start position and an end position of the erase page, wherein the set content indicates that the position is an erase page.
[0060] The data partition is composed of a plurality of blocks, the blocks are divided into good blocks and bad blocks, the bad blocks have corresponding identifiers such as "1xff", the bad blocks in the partition data can be detected by the bad block identifier, if there is a bad block, the partition data corresponding to the bad block is filtered out during data restoration, and the position of the bad block is still retained in the upgraded system. Since the bad block data is filtered out, the content of the bad block in the storage is empty. In some embodiments, filtering the partition data of the bad block can avoid the occurrence of error data in the storage, and retaining the position of the bad block in the storage can maintain the integrity of the partition.
[0061] If there is no bad block in the partition data, then it is necessary to continue to detect whether there is an erase page in the partition data, and the content in the erase page is empty, which is easy to cause data position disorder during data restoration. The erase page also has a corresponding identifier. If it is detected according to the erase page identifier that the partition data contains an erase page, then the starting position and the ending position of the erase page are recorded, and then the corresponding starting position and ending position are found in the memory, and a set content is written in the position, which indicates that the position is an erase page.
[0062] In some embodiments, by detecting the bad block and filtering out the bad block content, it is ensured that the partition data after system upgrade is valid. By writing the set content in the position of the erase page in the memory, it is avoided that the data position is disordered during the restoration of the erase page, and the correctness and effectiveness of data restoration are improved.
[0063] In some embodiments, writing the upgrade firmware into the memory by calling the write interface of the memory includes: obtaining a partition table file carried by the upgrade firmware, wherein the partition table file includes firmware partition information and data partition information; determining the partition capacity of each partition in the data partition information; if the partition capacity of any one partition is less than the data storage size of the corresponding partition in the partition data, it is determined that the embedded system cannot complete the upgrade; if the partition capacity of each partition is greater than or equal to the data storage size of the corresponding partition in the partition data, then according to the firmware partition information, the write interface of the memory is called to write the upgrade firmware into the memory.
[0064] In some embodiments, after the partition data of the memory is backed up to the host computer, the upgrade tool obtains the upgrade firmware, the upgrade tool carries a partition table file, the partition table file includes firmware partition information and data partition information, and system upgrade can bring at least one of the following four situations, including: increase in the number of partitions, decrease in the number of partitions, increase in the partition capacity, and decrease in the partition capacity. The data partition information indicates the content capacity of each partition after system upgrade. The memory first determines whether each partition can accommodate the corresponding partition data according to the data partition information after system upgrade. If it can accommodate, then the upgrade firmware is written into the firmware partition of the memory according to the firmware partition information, and the system upgrade is completed. If it cannot accommodate, then the upgrade firmware does not need to be written, and this upgrade fails.
[0065] The process of determining whether each partition can accommodate corresponding partition data after system upgrade is as follows: the upgrade tool determines the partition capacity of each partition in the data partition information and the data storage size of the backup data corresponding to the partition. If the partition capacity of any one partition is less than the data storage size of the corresponding partition in the partition data, the backup data cannot be restored to the memory, and thus the embedded system cannot complete the upgrade. If the partition capacity of each partition is greater than or equal to the data storage size of the corresponding partition in the partition data, it indicates that the partition data can be restored to the memory, and then the write interface of the memory is called to write the upgrade firmware into the memory.
[0066] In some embodiments, before the upgrade firmware is formally written, it is determined according to the data partition information whether the backup data can be normally restored to the memory. If the data cannot be restored due to the reduced partition capacity, the upgrade firmware does not need to be written, and the invalid step is omitted.
[0067] In some embodiments, restoring the partition data in the host computer to the memory by calling the write interface includes: determining the file identifier of the backup file in which the partition data in the host computer is located, wherein each file identifier corresponds to a partition of the memory before system upgrade; determining all partition identifiers in the data partition information after system upgrade; and according to the correspondence between the file identifiers and the partition identifiers, calling the write interface to restore the partition data in the host computer to each partition of the memory.
[0068] The memory stores data in multiple partitions, each of which has a corresponding partition identifier. When the data in the memory is backed up to the host computer, the data in each partition is stored in a file, and the identifier of the file is set to be the same as the identifier of the partition where the data originally locates. Thus, each file corresponds to a partition in the memory, and the identifiers used by the corresponding file and partition are also the same.
[0069] When the data is restored to the memory, each partition in the data partition information is also divided into identifiers in the same way as before system upgrade. Thus, when the data is restored, the partition data can be restored to the corresponding memory partition according to the file identifier.
[0070] In some embodiments, by setting the file identifier when the data is backed up to be the same as the partition identifier when the data is restored, it can be ensured that the partition where the partition data is located is consistent before and after system upgrade, and the position of the partition data is accurate when the data is restored.
[0071] In some embodiments, when the partition data is backed up to the host computer, the entire partition data in the memory is read in blocks (block_size) as the minimum unit. Similarly, when the partition data is restored to the memory, the partition data is written to the memory in blocks as the minimum unit.
[0072] 1block is composed of a plurality of pages, and the block size is defined differently in different systems. In the embodiments of the present disclosure, 1 block = 64 pages = 64 * (page size).
[0073] FIG. 2 is a schematic diagram of a memory read-write-based embedded system upgrading method provided in the present disclosure. As can be seen, the present disclosure involves three parts, namely, an upper computer, an upgrading tool, and an embedded system.
[0074] Embedded system (ES): generally a Linux system or a Linux-like system, and the specific operating system may differ, but the upgrading function thereof should be similar. The embedded system provides two underlying interfaces, namely, a memory read interface ES.inf1 and a memory write interface ES.inf2.
[0075] Upper computer: configured to run the upgrading tool and save the backup partition data.
[0076] Upgrading tool: configured to upgrade the firmware into the embedded system while ensuring that the data of the embedded system is not lost. Before upgrading, ES.inf1 is called to backup the partition data in the upper computer, and after upgrading, ES.inf2 is called to restore the backup partition data in the upper computer to the memory partition.
[0077] FIG. 3 is a schematic diagram of the flow of partition data backup and restoration, including the following steps:
[0078] Step 3001: Call the memory read interface to backup all the partition data in the memory to the upper computer;
[0079] Step 3002: Call the memory write interface to write the upgrading firmware into the memory;
[0080] Step 3003: Check whether there is a bad block in the partition data, if yes, execute step 3004, and if not, execute step 3005;
[0081] Step 3004: Filter out the partition data corresponding to the bad block;
[0082] Step 3005: Check whether there is an erase page in the partition data, if yes, execute step 3006, and if not, execute step 3007;
[0083] Step 3006: Write a set of content between the positions of the erase pages in the memory;
[0084] Step 3007: Determine the partition capacity of each partition in the data partition information;
[0085] Step 3008: judging whether the partition capacity of each partition is greater than or equal to the data size of the corresponding partition in the partition data, if yes, executing step 3009, if not, executing step 3010;
[0086] Step 3009: calling a memory write interface to write the upgrade firmware into the memory; and
[0087] Step 3010: the embedded system fails to complete the upgrade.
[0088] The present disclosure provides an embedded system upgrade device based on memory read and write, as shown in FIG. 4, the device comprises:
[0089] A reading module 401 configured to call a read interface of a memory in an embedded system, read all partition data of the memory, and backup the partition data to an upper computer;
[0090] An upgrade module 402 configured to call a write interface of the memory to write upgrade firmware into the memory, so as to complete the upgrade of the embedded system; and
[0091] A restoring module 403 configured to call the write interface to restore the partition data in the upper computer to the memory, and detect and process bad blocks and erased pages of the partition data.
[0092] In some embodiments, the restoring module 403 is configured to:
[0093] According to a preset bad block identifier, check whether there is a bad block in the partition data;
[0094] If there is no bad block in the partition data, according to a preset erased page identifier, check whether there is an erased page in the partition data, wherein the erased page is empty;
[0095] If there is an erased page in the partition data, according to the start position and the end position of the erased page, write a set content at the position of the erased page in the memory, wherein the set content indicates that the position is an erased page.
[0096] In some embodiments, the device is further configured to:
[0097] If there is a bad block in the partition data, filter out the partition data corresponding to the bad block when restoring the partition data to the memory, and keep the position of the bad block in the memory.
[0098] In some embodiments, the upgrade module 402 is configured to:
[0099] Obtain a partition table file carried by the upgrade firmware, wherein the partition table file comprises firmware partition information and data partition information;
[0100] determining a partition capacity of each partition in the data partition information;
[0101] if the partition capacity of each partition is greater than or equal to the data size of the corresponding partition in the partition data, then according to the firmware partition information, calling a write interface of the memory to write the upgraded firmware into the memory.
[0102] In some embodiments, the device is further configured to:
[0103] if the partition capacity of any one partition is less than the data size of the corresponding partition in the partition data, then determining that the embedded system cannot complete the upgrade.
[0104] In some embodiments, the restoring module 403 is configured to:
[0105] determining a file identifier of a backup file of the partition data in the host computer, wherein each file identifier corresponds to a partition of the memory before the system upgrade;
[0106] determining all partition identifiers in the data partition information after the system upgrade;
[0107] according to the correspondence between the file identifiers and the partition identifiers, calling the write interface to restore the partition data in the host computer into each partition of the memory.
[0108] In some embodiments, the device is further configured to:
[0109] when backing up the partition data into the host computer, reading all partition data of the memory in blocks as the minimum unit;
[0110] when restoring the partition data into the memory, writing the partition data into the memory in blocks as the minimum unit.
[0111] As shown in FIG. 5, the embodiment of the present disclosure provides an electronic device, which includes a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502 and the memory 503 complete mutual communication through the communication bus 504.
[0112] The memory 503 is configured to store a computer program.
[0113] In an embodiment of the present disclosure, the processor 501 is configured to execute the program stored in the memory 503, and implement the embedded system upgrade method based on memory reading and writing as described in the present disclosure, which includes the following steps:
[0114] calling a read interface of the memory in the embedded system to read all partition data of the memory, and backing up the partition data into the host computer;
[0115] calling a write interface of the memory to write the upgrade firmware into the memory to complete the upgrade for the embedded system; and
[0116] calling the write interface to restore the partition data in the host computer into the memory, and detecting and processing bad blocks and erase pages of the partition data.
[0117] In some embodiments, the detecting and processing of the bad blocks and the erase pages of the partition data comprises:
[0118] checking whether there is a bad block in the partition data according to a preset bad block identifier;
[0119] if there is no bad block in the partition data, checking whether there is an erase page in the partition data according to a preset erase page identifier, wherein the erase page is empty;
[0120] if there is an erase page in the partition data, writing a setting content into a position of the memory where the erase page is located according to a start position and an end position of the erase page, wherein the setting content indicates that the position is the erase page.
[0121] In some embodiments, after checking whether there is a bad block in the partition data, the method further comprises:
[0122] if there is a bad block in the partition data, filtering out the partition data corresponding to the bad block when restoring the partition data into the memory, and reserving a position of the bad block in the memory.
[0123] In some embodiments, calling the write interface of the memory to write the upgrade firmware into the memory comprises:
[0124] obtaining a partition table file carried by the upgrade firmware, wherein the partition table file comprises firmware partition information and data partition information;
[0125] determining a partition capacity of each partition in the data partition information;
[0126] if the partition capacity of each partition is greater than or equal to a data storage size of a corresponding partition in the partition data, calling the write interface of the memory to write the upgrade firmware into the memory according to the firmware partition information.
[0127] In some embodiments, after determining the partition capacity of each partition in the data partition information, the method further comprises:
[0128] if the partition capacity of any one partition is less than the data storage size of the corresponding partition in the partition data, determining that the embedded system cannot complete the upgrade.
[0129] In some embodiments, calling the write interface to restore the partition data in the host computer into the memory comprises:
[0130] Determine the file identifier of the backup file in which the partition data in the host computer is located, wherein each file identifier corresponds to a partition of the memory before system upgrade;
[0131] Determine all partition identifiers in the data partition information after system upgrade;
[0132] According to the correspondence between the file identifier and the partition identifier, call the write interface to restore the partition data in the host computer to each partition of the memory.
[0133] In some embodiments, the method further comprises:
[0134] When backing up the partition data to the host computer, read all the partition data of the memory in a block as the minimum unit;
[0135] When restoring the partition data to the memory, write the partition data to the memory in a block as the minimum unit.
[0136] The embodiments of the present disclosure further provide a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the memory read-write-based embedded system upgrade method.
[0137] The apparatus embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the present embodiment.
[0138] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.
[0139] It is to be understood that the terminology used herein is for the purpose of describing particular example embodiments only and is not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. The terms "comprises", "comprising", "includes", "including" and "has" are inclusive and therefore specify the presence of stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or groups thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring their performance in the particular order
[0140] The above description is that of current embodiments of the disclosure. Various modifications and changes can be made thereto without departing from the spirit and scope of the disclosure as set forth. The disclosure is not to be limited to the embodi ments described herein but is to cover any and all changes and modifications within the scope and spirit of the disclosure as described.
Claims
1. A method for upgrading an embedded system based on memory read and write, comprising: calling a read interface of a memory in the embedded system to read all partition data of the memory and backup the partition data to a host computer; calling a write interface of the memory to write an upgrade firmware into the memory to complete the upgrade of the embedded system; and calling the write interface to restore the partition data in the host computer to the memory and detect and process bad blocks and erased pages of the partition data.
2. The method of claim 1, wherein the detecting and processing of the bad blocks and the erased pages of the partition data comprises: checking whether there is a bad block in the partition data according to a preset bad block identifier; if there is no bad block in the partition data, checking whether there is an erased page in the partition data according to a preset erased page identifier, wherein the erased page is empty; if there is an erased page in the partition data, writing a preset content into a position of the memory where the erased page is located according to a start position and an end position of the erased page, wherein the preset content indicates that the position is an erased page.
3. The method of claim 2, wherein after checking whether there is a bad block in the partition data, the method further comprises: if there is a bad block in the partition data, filtering out the partition data corresponding to the bad block when restoring the partition data to the memory and reserving the position of the bad block in the memory.
4. The method of any one of claims 1 to 3, wherein the calling of the write interface of the memory to write the upgrade firmware into the memory comprises: obtaining a partition table file carried by the upgrade firmware, wherein the partition table file comprises firmware partition information and data partition information; determining a partition capacity of each partition in the data partition information; if the partition capacity of each partition is greater than or equal to a data storage size of a corresponding partition in the partition data, calling the write interface of the memory to write the upgrade firmware into the memory according to the firmware partition information.
5. The method of claim 4, wherein after determining the partition capacity of each partition in the data partition information, the method further comprises: if the partition capacity of any one partition is less than the data storage size of the corresponding partition in the partition data, determining that the embedded system cannot complete the upgrade.
6. The method of claim 4 or 5, wherein the calling of the write interface to restore the partition data in the host computer to the memory comprises: determining a file identifier of a backup file in which the partition data in the host computer is located, wherein each file identifier corresponds to one partition in the memory before system upgrade; determining all partition identifiers in the data partition information after system upgrade; and according to a correspondence between the file identifier and the partition identifier, calling the write interface to restore the partition data in the host computer to each partition of the memory.
7. The method of any one of claims 1 to 6, wherein the method further comprises: when backing up the partition data to the host computer, reading all partition data of the memory in a block as a minimum unit. When restoring the partition data to the memory, the partition data is written to the memory in blocks as minimum units.
8. An apparatus for upgrading an embedded system based on memory read and write, comprising: a reading module configured to call a read interface of a memory in the embedded system, read all partition data of the memory, and backup the partition data to a host computer; an upgrading module configured to call a write interface of the memory to write an upgrading firmware to the memory, so as to complete the upgrading of the embedded system; and a restoring module configured to call the write interface to restore the partition data in the host computer to the memory, and detect and process bad blocks and erased pages of the partition data.
9. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; the memory is configured to store a computer program; the processor is configured to execute the program stored in the memory, so as to implement the method in any one of claims 1 to 7.
10. A computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method in any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for upgrading firmware of storage equipment
CN102650949A
Embedded Linux partitioning and data recovery method, embedded Linux partitioning and data recovery system and system development method
CN103473067A
Method and device for remotely updating DSP program through Ethernet and storage medium
CN117667163A
Embedded system upgrading method and device based on memory read-write
CN118605916A
Embedded electronic device and firmware updating method thereof
US20110004871A1