A memory and a firmware upgrade method thereof
By building multiple firmware backup areas in memory and enhancing data integrity verification, the failure problems caused by bad blocks during firmware upgrade are solved, and the reliability and system stability of firmware upgrades are achieved.
Patent Information
- Application Number
- CN202411244381.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-09-06
AI Technical Summary
During the firmware upgrade process of electronic devices, bad blocks may appear in the firmware storage area, resulting in the firmware upgrade failure, which will make the memory unable to be used normally.
Design a memory, including the main storage area, the secondary storage area and the backup storage area, obtain and verify the firmware upgrade package through the main control unit, and select the best performance area from the user data area when bad blocks occur, Ensure the integrity and reliability of firmware upgrade packages.
It significantly reduces failures during firmware upgrades, enhances the reliability of firmware upgrades, ensures that the system returns to normal operation, avoids system suspension or crash caused by bad blocks, and improves system stability and availability.
Smart Images

Figure CN118760458B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage, and in particular to a memory and a firmware upgrade method thereof. Background Art
[0002] During the use of an electronic device, the memory may malfunction and become unusable due to differences in firmware algorithms or application scenarios. At this time, the firmware needs to be upgraded to restore normal use of the memory.
[0003] Under normal circumstances, the memory should ensure that the firmware storage area is available when performing a firmware upgrade. However, in actual complex application scenarios, it is inevitable that the firmware storage area will be unusable due to bad blocks during the firmware upgrade process, which will cause the firmware upgrade to fail and the memory to fail and become unusable. Therefore, there is room for improvement. Summary of the invention
[0004] The object of the present invention is to provide a memory and a firmware upgrade method thereof, which can upgrade the firmware even when bad blocks occur.
[0005] In order to solve the above technical problems, the present invention is achieved through the following technical solutions:
[0006] The present invention provides a memory, comprising:
[0007] A storage block, in which mutually isolated primary storage areas, secondary storage areas, backup storage areas, and user data areas are set; and
[0008] A main control unit, used to obtain a firmware upgrade package and load it into the secondary storage area, and the main control unit is also used to load the firmware upgrade package in the secondary storage area into the primary storage area and the backup storage area;
[0009] The main control unit is further used to load the firmware upgrade package from the primary storage area, the secondary storage area and the backup storage area respectively, restart the memory, and verify the integrity of the loaded firmware upgrade package;
[0010] When the main control unit determines that the firmware upgrade package in a certain storage area is incomplete, it selects a data area with the best performance from the user data area to replace the storage area, and loads the firmware upgrade packages in other storage areas into the data area.
[0011] In one embodiment of the present invention, the main control unit obtains the firmware upgrade package from the processing module, and the processing module is used to verify the integrity of the obtained firmware upgrade package and send it to the main control unit when it is determined that the firmware upgrade package is complete.
[0012] In one embodiment of the present invention, the main control unit is used to verify the integrity of the firmware upgrade package in the secondary storage area, and when it is determined that it is complete, load it into the main storage area and the backup storage area; when it is determined that it is incomplete, repeatedly obtain the firmware upgrade package from the processing module until the obtained firmware upgrade package is complete.
[0013] In one embodiment of the present invention, the main control unit is used to verify the integrity of the firmware upgrade package in the main storage area and the backup storage area respectively. When it is determined that the firmware upgrade package in a certain storage area is incomplete, the firmware upgrade package in the secondary storage area is repeatedly loaded into a certain storage area.
[0014] In one embodiment of the present invention, the main control unit loads the firmware upgrade package from the main storage area to restart the memory, and verifies the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold.
[0015] In an embodiment of the present invention, the main control unit loads the firmware upgrade package from the secondary storage area to restart the memory, and verifies the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold.
[0016] In an embodiment of the present invention, the main control unit loads the firmware upgrade package from the backup storage area to restart the memory, and verifies the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold.
[0017] In an embodiment of the present invention, the preset threshold is in the range of 500-1000.
[0018] In an embodiment of the present invention, the data area with the best performance is represented by the backup storage area with the shortest estimated completion time.
[0019] The present invention also provides a firmware upgrade method for a memory, wherein the memory includes a storage block, wherein the storage block is provided with a primary storage area, a secondary storage area, a backup storage area, and a user data area isolated from each other, and the firmware upgrade method includes:
[0020] Loading a firmware upgrade package into the secondary storage area;
[0021] Loading the firmware upgrade package in the secondary storage area into the primary storage area and the backup storage area respectively;
[0022] Loading a firmware upgrade package from the primary storage area, the secondary storage area, and the backup storage area respectively, restarting the memory, and verifying the integrity of the loaded firmware upgrade package;
[0023] When the firmware upgrade package in a certain storage area is incomplete, a data area with the best performance is selected from the user data area to replace the storage area, and the firmware upgrade packages in other storage areas are loaded into the data area.
[0024] As described above, the present invention provides a memory and a firmware upgrade method thereof, which significantly reduces the upgrade failures that may be caused by data loss or damage during the firmware upgrade process by constructing multiple firmware fast upgrade backup areas and enhancing the data integrity check of the firmware code, thereby enhancing the reliability of the firmware upgrade and ensuring that the system can be restored to a normal operating state. At the same time, an effective replacement strategy is proposed, which can replace and supplement blocks in time after detecting bad blocks during firmware upgrades, ensuring a continuous firmware upgrade supply, avoiding system hangs or freezes caused by bad blocks, and thus improving the stability and availability of the system.
[0025] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for describing the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0027] Figure 1 is a schematic diagram of an electronic device according to an embodiment of the present invention;
[0028] Figure 2 is a schematic diagram of a memory in one embodiment of the present invention;
[0029] Figure 3 A schematic diagram of a firmware upgrade package backup according to an embodiment of the present invention;
[0030] Figure 4 A flowchart of a method for upgrading the firmware of a memory device according to an embodiment of the present invention;
[0031] Figure 5 for Figure 4 Flow chart of step S10;
[0032] Figure 6 for Figure 4 Flow chart of step S20;
[0033] Figure 7 for Figure 6 Flow chart of step S21 in FIG.
[0034] Figure 8 for Figure 6 Flow chart of step S22;
[0035] Fig. 9 for Figure 4 Flow chart of step S30;
[0036] Fig.10 for Fig. 9 Flow chart of step S31 in FIG.
[0037] Fig.11 for Fig. 9 Flow chart of step S32;
[0038] Fig.12 for Fig. 9 Flowchart of step S33 in FIG.
[0039] In the figure: 100, processing module; 200, power module; 300, memory module; 400, interface module; 500, first transceiver interface; 600, memory;
[0040] 610, main control unit; 620, second transceiver interface; 630, transmission interface unit; 640, read-only storage unit; 650, random storage unit; 660, cache unit; 670, error correction unit; 680, storage block; 681, primary storage area; 682, secondary storage area; 683, backup storage area; 684, user data area. DETAILED DESCRIPTION
[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] See also Figure 1 The present invention provides an electronic device, which may include a processing module 100, a power module 200, a memory module 300, an interface module 400, a first transceiver interface 500, and a memory 600.
[0043] In one embodiment, the processing module 100 may be a central processing unit (CPU), which may be responsible for interpreting and executing instructions in a program, and controlling and processing data.
[0044] In one embodiment, the power module 200 can supply power to the processing module 100 , the memory module 300 , the memory 600 , etc., so as to drive the electronic device to work smoothly.
[0045] In one embodiment, the memory module 300 may be a dynamic random access memory (DRAM). The memory module 300 may be used to store data and program codes so that the processing module 100 can quickly access them.
[0046] In one embodiment, the interface module 400 may be a Universal Serial Bus (USB). The interface module 400 may be used to connect various peripheral devices (such as a keyboard, a mouse, a printer, a mobile hard disk, etc.). The processing module 100 may communicate data and provide power to the peripheral devices through the interface module 400.
[0047] In one embodiment, the first transceiver interface 500 may be a Universal Asynchronous Receiver / Transmitter (UART). The processing module 100 may communicate serially with the peripheral device through the first transceiver interface 500 to exchange data.
[0048] In one embodiment, the memory 600 may be an embedded MultiMediaCard (eMMC) or a Universal Flash Storage (UFS). The memory 600 may communicate with the processing module 100 via the CMD line and the DATA0~7 lines, and receive instructions from the processing module 100 to perform operations such as reading, writing, and erasing. The processing module 100 may send instructions via the CMD line and transmit data via the DATA0~7 lines. The communication protocol between the memory 600 and the processing module 100 may follow the JEDEC protocol.
[0049] See also Figure 2 The present invention also provides a memory 600, which may include a main control unit 610, a second transceiver interface 620, a transmission interface unit 630, a read-only storage unit 640, a random storage unit 650, a cache unit 660, an error correction unit 670, a storage block 680, and the like.
[0050] In one embodiment, the main control unit 610 may be a microcontroller unit (MCU). The main control unit 610 may be used to perform specific control tasks, such as reading data, processing instructions from the processing module 100, etc. The processing core of the main control unit 610 may be designed based on the RISC-V architecture to perform various control and computing tasks.
[0051] In one embodiment, the second transceiver interface 620 may be connected to the main control unit 610. The second transceiver interface 620 may also be an asynchronous transceiver transmitter. The main control unit 610 may communicate with the peripheral device via the second transceiver interface 620 to exchange data.
[0052] In one embodiment, the transmission interface unit 630 may be a transmission interface between the main control unit 610 and the processing module 100. The transmission interface unit 630 may receive instructions from the processing module 100, and return data or status information to the processing module 100. The transmission interface unit 630 may receive instructions from the processing module 100 through the CMD line and the DATA line, and return result data or execution status to the processing module 100 through the DATA line.
[0053] In one embodiment, the read-only storage unit 640 may be a non-volatile memory (ROM) for long-term data storage. A program may be stored in the read-only storage unit 640. The program may be a set of pre-written instructions that instruct the main control unit 610 on how to start and run. These instructions include device initialization, peripheral configuration, and a possible boot loader. The boot loader may be used to load an updated program or operating system, etc.
[0054] In one embodiment, the random access memory unit 650 may be a volatile memory (Random Access Memory, RAM) for temporarily storing data and program codes. The random access memory unit 650 may be used to temporarily store data. When the main control unit 610 executes a program, the program code may be loaded from the read-only storage unit 640 into the random access memory unit 650 for execution.
[0055] In one embodiment, the cache unit 660 can be used as a high-speed temporary storage area between the main control unit 610 and the random access storage unit 650 to store data and instructions frequently accessed by the main control unit 610 to achieve the function of accelerating data transmission.
[0056] In one embodiment, the error correction unit 670 can check the data integrity to detect and correct data errors in the memory 600 or during transmission. The error correction unit 670 can use a low-density parity check (LDPC) method for checking.
[0057] In one embodiment, the storage block 680 may be a physical unit for storing data in the memory 600. The memory 600 may be composed of a plurality of storage blocks 680. Each storage block 680 may contain a plurality of pages. Each page is the minimum unit of a read / write operation, and a block is the minimum unit of an erase operation. Data is usually read and written in units of pages, and the entire block needs to be erased when erasing.
[0058] In one embodiment, a primary storage area 681, a secondary storage area 682, a backup storage area 683, and a user data area 684 may be pre-set in the storage block 680. The primary storage area 681, the secondary storage area 682, the backup storage area 683, and the user data area 684 may be set in the same storage block 680 or in different storage blocks 680. The primary storage area 681, the secondary storage area 682, the backup storage area 683, and the user data area 684 may be isolated from each other.
[0059] In one embodiment, the main storage area 681 (CODE0 Block) may be a separate storage area in the storage block 680. The main storage area 681 may be used to store firmware to be upgraded. The firmware to be upgraded refers to program code that controls and manages the operation of the memory 600. When the memory 600 is powered on, the main control unit 610 may preferentially access the main storage area 681 to load the firmware to be upgraded, thereby controlling the initialization process and subsequent operations of the memory 600. The firmware to be upgraded refers to the current firmware running in the memory 600.
[0060] In one embodiment, the secondary storage area 682 (CODE1 Block) may also be a separate storage area in the storage block 680. The secondary storage area 682 may be used to store newly downloaded firmware upgrade packages, so as to facilitate subsequent updates of the firmware to be upgraded in the primary storage area 681. The secondary storage area 682 may avoid potential risks caused by directly overwriting the firmware to be upgraded in the primary storage area 681. The firmware upgrade package is first downloaded and stored in the secondary storage area 682, rather than being immediately written to the primary storage area 681. The purpose of this is to perform the actual firmware replacement operation only after the firmware upgrade package is completely downloaded and verified for correctness, thereby improving the security of the upgrade process. The firmware upgrade package refers to the firmware after the firmware to be upgraded in the memory 600 is upgraded.
[0061] In one embodiment, the number of the backup storage area 683 (CODE2 Block) may be at least one. The backup storage area 683 may also be a separate storage area in the storage block 680. The backup storage area 683 may also be used to store the firmware upgrade package, thereby backing up the firmware upgrade package.
[0062] In one embodiment, the user data area 684 may be a storage area in the storage block 680 for storing data from the host.
[0063] See also Figure 3 In one embodiment, when the firmware to be upgraded in the primary storage area 681 needs to be upgraded, the main control unit 610 can load the new firmware upgrade package into the secondary storage area 682 .
[0064] In one embodiment, the processing module 100 may first obtain a firmware upgrade package. Specifically, the processing module 100 may download the firmware upgrade package (FFU.bin) through the interface module 400 (USB) or network OTA (Over-The-Air). The firmware upgrade package refers to a binary file with firmware update information, which includes new firmware code and update instructions.
[0065] For example, the processing module 100 can connect the electronic device to another electronic device through a physical connection (using a USB cable), and then transfer the firmware upgrade package to the electronic device through a specific software tool.
[0066] For another example, the processing module 100 may remotely download the firmware update package via a wireless network (such as WiFi or a cellular network).
[0067] In one embodiment, after the processing module 100 obtains the downloaded firmware upgrade package, the integrity of the firmware upgrade package can be checked to determine whether the firmware upgrade package is complete. Specifically, the processing module 100 can use a cyclic redundancy check (CRC) to check the firmware upgrade package. The CRC check is performed by performing binary division of the firmware upgrade package with a predefined polynomial, and the remaining result is the CRC check code. This check code is usually attached to the end of the data.
[0068] For example, during the creation of a firmware upgrade package, a specific CRC algorithm is used to process the data in the firmware upgrade package (except for the last few bytes reserved for verification). This process generates a CRC checksum, usually a 4-byte value, which is then appended to the end of the firmware upgrade package.
[0069] After the processing module 100 downloads the firmware upgrade package, the processing module 100 will separate the last 4 bytes (storing the CRC check code) from the firmware upgrade package, and then perform the same CRC calculation on the rest of the file again. The calculated CRC value will be compared with the CRC check value attached to the end of the firmware upgrade package. If the two are consistent, it means that the firmware upgrade package has not been tampered with during the transmission process, and the data integrity is verified. If they are inconsistent, it means that the firmware upgrade package may be damaged or tampered with during the download process. The processing module 100 should reject this firmware upgrade package and need to re-download it until the newly downloaded firmware upgrade package is complete.
[0070] In one embodiment, after the processing module 100 verifies the downloaded firmware upgrade package, it is necessary to check whether the memory 600 supports the firmware upgrade function. If the memory 600 does not support the firmware upgrade function, the firmware upgrade instruction of the processing module 100 is responded to to enable the firmware upgrade function of the memory 600. If the memory 600 supports the firmware upgrade function, the firmware upgrade package is loaded into the secondary storage area 682.
[0071] Specifically, in the process of the processing module 100 checking whether the memory 600 supports the firmware upgrade function, the processing module 100 can send a CMD6 command to the main control unit 610 of the memory 600, which specifies that the support status of the FFU function is to be queried. CMD6 is a command for switching the working mode or setting of the memory 600. CMD6 can be used to query or change the status of the memory card, such as data transmission rate, bus width, etc. CMD6 can also be used to check whether the memory 600 supports the FFU upgrade function and enable the function.
[0072] Further, when the main control unit 610 receives the CMD6 command, a status byte may be returned, which contains information on whether the FFU function is supported or not. The processing module 100 may analyze the response received from the main control unit 610. If the response indicates that the memory 600 supports the FFU function, the processing module 100 continues to perform the subsequent firmware upgrade steps. If the response indicates that the memory 600 does not support the FFU function, the processing module 100 needs to further send a CMD6 command to enable the FFU function, such as sending a firmware upgrade instruction.
[0073] Furthermore, when the FFU function is not enabled by default in the memory 600, the processing module 100 needs to send a firmware upgrade instruction to the main control unit 610. The firmware upgrade instruction may include specific instructions for enabling the FFU function. The main control unit 610 may respond to the firmware upgrade instruction and enable the FFU function, and return a positive response to the processing module 100 after confirmation.
[0074] In one embodiment, when the FFU function is enabled in the memory 600, the processing module 100 may load the downloaded firmware upgrade package into the first upgrade area. Specifically, the processing module 100 may write the firmware upgrade package into the secondary storage area 682 by reliable writing. Reliable Write is a technology that ensures that data is correctly and reliably written into the storage medium.
[0075] In one embodiment, after the firmware upgrade package is loaded into the secondary storage area 682, the main control unit 610 needs to verify the integrity of the firmware upgrade package in the secondary storage area 682. When the firmware upgrade package in the secondary storage area 682 is incomplete, the firmware upgrade package is reloaded into the secondary storage area 682 until the firmware upgrade package in the secondary storage area 682 is complete.
[0076] Specifically, when verifying the firmware upgrade package in the secondary storage area 682 , the main control unit 610 may also verify the firmware upgrade package by using a cyclic redundancy check (CRC).
[0077] In one embodiment, when the firmware upgrade package in the secondary storage area 682 is complete, the main control unit 610 may return a positive response to the processing module 100. Afterwards, the processing module 100 may issue a firmware replacement instruction, and after receiving the firmware replacement instruction, the main control unit 610 may control the memory 600 to perform a firmware program upgrade and replacement.
[0078] Specifically, the processing module 100 may issue a CMD6 command to the memory 600. The CMD6 command may be attached with a specific parameter value (eg, 0x02) to trigger or execute the firmware installation process inside the memory 600. After receiving the command, the memory 600 starts to execute the firmware update strategy.
[0079] In one embodiment, when the memory 600 starts to execute the firmware update strategy, the main control unit 610 may first load the firmware upgrade package from the secondary storage area 682 , and then load the firmware upgrade package in the secondary storage area 682 into the primary storage area 681 .
[0080] Specifically, the main control unit 610 may first load the firmware upgrade package from the secondary storage area 682 to start the memory 600. Afterwards, the main control unit 610 may delete the firmware to be upgraded in the primary storage area 681 and load the firmware upgrade package in the secondary storage area 682 into the primary storage area 681.
[0081] Further, after loading the firmware upgrade package into the main storage area 681, the main control unit 610 may verify the integrity of the firmware upgrade package in the main storage area 681. When the firmware upgrade package in the main storage area 681 is incomplete, the main control unit 610 may repeatedly load the firmware upgrade package in the secondary storage area 682 into the main storage area 681 until the firmware upgrade package in the main storage area 681 is complete. When the firmware upgrade package in the main storage area 681 is complete, the memory 600 may be powered off at this time, and after powering on again, the main control unit 610 loads the firmware upgrade package from the secondary storage area 682 to start the memory 600.
[0082] In one embodiment, after the memory 600 is restarted, the main control unit 610 can load the firmware upgrade package in the secondary storage area 682 into the backup storage area 683 again.
[0083] Specifically, after the main control unit 610 loads the firmware upgrade package into the backup storage area 683, the main control unit 610 may verify the integrity of the firmware upgrade package in the backup storage area 683. When the firmware upgrade package in the backup storage area 683 is incomplete, the main control unit 610 may repeatedly load the firmware upgrade package in the secondary storage area 682 into the backup storage area 683 until the firmware upgrade package in the backup storage area 683 is complete. When the firmware upgrade package in the backup storage area 683 is complete, the memory 600 may be powered off at this time, and after powering on again, the main control unit 610 loads the firmware upgrade package from the secondary storage area 682 to start the memory 600.
[0084] In one embodiment, after the main control unit 610 loads the firmware upgrade package in the secondary storage area 682 into the main storage area 681 and the backup storage area 683 respectively, it is necessary to run the firmware upgrade packages in the main storage area 681, the secondary storage area 682 and the backup storage area 683 respectively to verify the integrity of the loaded firmware upgrade package and the stability of the corresponding storage area.
[0085] In one embodiment, the main control unit 610 may first verify any one of the primary storage area 681, the secondary storage area 682, and the backup storage area 683, and after completing the verification, verify the other storage areas. In this embodiment, the main control unit 610 verifies the primary storage area 681, the secondary storage area 682, and the backup storage area 683 as an example for explanation.
[0086] In one embodiment, when the main storage area 681 needs to be verified, the main control unit 610 can load a firmware upgrade package from the main storage area 681 to restart the memory 600, and verify the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold.
[0087] Specifically, the main control unit 610 can load the firmware upgrade package from the main storage area 681 to restart the memory 600. After the restart is completed, the memory 600 can be powered off, and after the power is off, it can be powered on again. After powering on, the main control unit 610 still loads the firmware upgrade package from the main storage area 681 to restart the memory 600. When the number of restarts reaches a preset threshold, it can be indicated that the number of times the firmware upgrade package is loaded from the main storage area 681 reaches the preset threshold. At this time, the main control unit 610 can verify the integrity of the firmware upgrade package in the main storage area 681. Among them, the preset threshold can be between the range of 500 and 1000, for example, it can be 500, 750, 1000, etc.
[0088] Further, when the number of restarts of the memory 600 reaches a preset threshold, the main control unit 610 can verify the integrity of the firmware upgrade package in the main storage area 681. When the firmware upgrade package in the main storage area 681 is incomplete, the main control unit 610 can select the data area with the best performance from the multiple user data areas 684 to replace the main storage area 681. Since the firmware upgrade package is not loaded in the user data area 684, the main control unit 610 can load the firmware upgrade package in the secondary storage area 682 or the backup storage area 683 into the data area.
[0089] In one embodiment, the data region with the best performance can be represented as selecting a data region with the smallest estimated completion time (ECT) from multiple user data regions 684. ECT can be used to evaluate the index of the length of time required to complete a task or operation to help optimize performance and resource allocation. When selecting a data region for processing, the ECT value can guide the main control unit 610 to prioritize tasks that are expected to be completed faster, thereby improving overall efficiency and response speed.
[0090] In one embodiment, when the main control unit 610 determines that the firmware upgrade package in the primary storage area 681 is complete, it needs to verify the secondary storage area 682 .
[0091] Specifically, the main control unit 610 may load the firmware upgrade package from the secondary storage area 682 to restart the memory 600, and verify the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold.
[0092] Further, the main control unit 610 may load the firmware upgrade package from the secondary storage area 682 to restart the memory 600. After the restart is completed, the memory 600 may be powered off, and after the power is off, it may be powered on again. After powering on, the main control unit 610 still loads the firmware upgrade package from the secondary storage area 682 to restart the memory 600. When the number of restarts reaches a preset threshold, it may indicate that the number of times the firmware upgrade package is loaded from the secondary storage area 682 reaches the preset threshold. At this time, the main control unit 610 may verify the integrity of the firmware upgrade package in the secondary storage area 682.
[0093] Furthermore, when the number of restarts of the memory 600 reaches a preset threshold, the main control unit 610 can verify the integrity of the firmware upgrade package in the secondary storage area 682. When the firmware upgrade package in the secondary storage area 682 is incomplete, the main control unit 610 can select a data area with the best performance from multiple user data areas 684 to replace the secondary storage area 682. Since the firmware upgrade package is not loaded in the user data area 684, the main control unit 610 can load the firmware upgrade package in the main storage area 681 or the backup storage area 683 into the data area.
[0094] In one embodiment, when the main control unit 610 determines that the firmware upgrade package in the secondary storage area 682 is complete, it needs to verify the backup storage area 683.
[0095] Specifically, the main control unit 610 may load the firmware upgrade package from the backup storage area 683 to restart the memory 600, and verify the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold.
[0096] Further, the main control unit 610 can load the firmware upgrade package from the backup storage area 683 to restart the memory 600. After the restart is completed, the memory 600 can be powered off, and after the power is off, it can be powered on again. After powering on, the main control unit 610 still loads the firmware upgrade package from the backup storage area 683 to restart the memory 600. When the number of restarts reaches a preset threshold, it can be indicated that the number of times the firmware upgrade package is loaded from the backup storage area 683 reaches the preset threshold. At this time, the main control unit 610 can verify the integrity of the firmware upgrade package in the backup storage area 683.
[0097] Furthermore, when the number of restarts of the memory 600 reaches a preset threshold, the main control unit 610 can verify the integrity of the firmware upgrade package in the backup storage area 683. When the firmware upgrade package in the backup storage area 683 is incomplete, the main control unit 610 can select a data area with the best performance from multiple user data areas 684 to replace the backup storage area 683. Since the firmware upgrade package is not loaded in the user data area 684, the main control unit 610 can load the firmware upgrade package in the main storage area 681 or the secondary storage area 682 into the data area.
[0098] In one embodiment, when the main control unit 610 determines that the firmware upgrade package in the backup storage area 683 is complete, it can indicate that the firmware upgrade packages in the primary storage area 681, the secondary storage area 682, and the backup storage area 683 in the memory 600 are all available. When the memory 600 is started, the firmware upgrade package can be loaded from any storage area of the primary storage area 681, the secondary storage area 682, and the backup storage area 683, and the firmware upgrade package can also be loaded from the primary storage area 681 first.
[0099] In one embodiment, when the main control unit 610 determines that the firmware upgrade package of any storage area among the main storage area 681, the secondary storage area 682 and the backup storage area 683 is incomplete, the main control unit 610 can select the data area with the best performance from the user data area 684 to replace the storage area, and load the firmware upgrade package in other storage areas into the data area.
[0100] It can be seen that in the above scheme, by constructing multiple firmware fast upgrade backup areas and enhancing the data integrity check of the firmware code, the upgrade failure caused by data loss or damage during the firmware upgrade process is significantly reduced, the reliability of the firmware upgrade is enhanced, and the system can be restored to normal operation. At the same time, an effective replacement strategy is proposed to replace and supplement the blocks in time after the bad blocks are detected during the firmware upgrade, ensuring the continuous firmware upgrade supply, avoiding the system hang or crash caused by the bad blocks, and thus improving the stability and availability of the system.
[0101] See also Figure 4 The present invention also provides a method for upgrading the firmware of a memory, which can be applied to the above electronic device to update the firmware in the memory 600. The upgrading method may include the following steps:
[0102] Step S10, loading the firmware upgrade package into the secondary storage area;
[0103] Step S20, loading the firmware upgrade package in the secondary storage area into the primary storage area and the backup storage area respectively;
[0104] Step S30, loading the firmware upgrade package from the primary storage area, the secondary storage area, and the backup storage area respectively, restarting the memory, and verifying the integrity of the loaded firmware upgrade package;
[0105] Step S40: When the firmware upgrade package in a certain storage area is incomplete, a data area with the best performance is selected from the user data area to replace the storage area, and the firmware upgrade packages in other storage areas are loaded into the data area.
[0106] See also Figure 5 In one embodiment, when executing step S10, specifically, step S10 may include the following steps:
[0107] Step S11, obtaining a firmware upgrade package and verifying the integrity of the firmware upgrade package;
[0108] Step S12: when the firmware upgrade package is incomplete, re-acquire it until the firmware upgrade package is complete;
[0109] Step S13: When the firmware upgrade package is complete, check whether the memory supports the firmware upgrade function;
[0110] Step S14: if the memory does not support the firmware upgrade function, responding to the firmware upgrade instruction of the processing module to enable the firmware upgrade function of the memory;
[0111] Step S15: if the memory supports the firmware upgrade function, then the firmware upgrade package is loaded into the secondary storage area;
[0112] Step S16, verifying the integrity of the firmware upgrade package in the secondary storage area;
[0113] Step S17: when the firmware upgrade package in the secondary storage area is incomplete, reload the firmware upgrade package into the secondary storage area until the firmware upgrade package in the secondary storage area is complete;
[0114] Step S18: When the firmware upgrade package in the secondary storage area is complete, responding to the firmware replacement instruction of the processing module, the memory is controlled to perform firmware program upgrade and replacement.
[0115] See also Figure 6 In one embodiment, when executing step S20, specifically, step S20 may include the following steps:
[0116] Step S21, loading the firmware upgrade package from the secondary storage area, and loading the firmware upgrade package in the secondary storage area into the primary storage area;
[0117] Step S22: Load the firmware upgrade package from the secondary storage area, and load the firmware upgrade package in the secondary storage area into the backup storage area.
[0118] See also Figure 7 In one embodiment, when executing step S21, specifically, step S21 may include the following steps:
[0119] Step S211, loading the firmware upgrade package from the secondary storage area, restarting the memory, and loading the firmware upgrade package in the secondary storage area into the primary storage area;
[0120] Step S212: Verify the integrity of the firmware upgrade package in the main storage area;
[0121] Step S213: When the firmware upgrade package in the primary storage area is incomplete, repeatedly loading the firmware upgrade package in the secondary storage area into the primary storage area until the firmware upgrade package in the primary storage area is complete;
[0122] Step S214: When the firmware upgrade package in the primary storage area is complete, the firmware upgrade package is loaded from the secondary storage area to restart the storage.
[0123] See also Figure 8 In one embodiment, when executing step S22, specifically, step S22 may include the following steps:
[0124] Step S221, loading the firmware upgrade package in the secondary storage area into the backup storage area;
[0125] Step S222: verifying the integrity of the firmware upgrade package in the backup storage area;
[0126] Step S223: when the firmware upgrade package in the backup storage area is incomplete, repeatedly loading the firmware upgrade package in the secondary storage area into the backup storage area until the firmware upgrade package in the backup storage area is complete;
[0127] Step S224: When the firmware upgrade package in the backup storage area is complete, the firmware upgrade package is loaded from the main storage area to restart the storage.
[0128] See also Fig. 9 In one embodiment, when executing step S30, specifically, step S30 may include the following steps:
[0129] Step S31, loading a firmware upgrade package from the main storage area to restart the memory, and when the number of restarts reaches a preset threshold, verifying the integrity of the loaded firmware upgrade package;
[0130] Step S32: Load the firmware upgrade package from the secondary storage area to restart the memory, and verify the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold;
[0131] Step S33: Load the firmware upgrade package from the backup storage area to restart the memory, and verify the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold.
[0132] See also Fig.10 In one embodiment, when executing step S31, specifically, step S31 may include the following steps:
[0133] Step S311: Load the firmware upgrade package from the main storage area to restart the memory, and when the number of restarts reaches a preset threshold, verify the integrity of the loaded firmware upgrade package;
[0134] Step S312: When the firmware upgrade package in the primary storage area is incomplete, a data area with the best performance is selected from the user data area to replace the primary storage area, and the firmware upgrade package in the secondary storage area or the backup storage area is loaded into the data area;
[0135] Step S313: When the firmware upgrade package in the primary storage area is complete, the firmware upgrade package is loaded from the secondary storage area to restart the storage.
[0136] See also Fig.11 In one embodiment, when executing step S32, specifically, step S32 may include the following steps:
[0137] Step S321: Load the firmware upgrade package from the secondary storage area to restart the memory, and verify the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold;
[0138] Step S312: When the firmware upgrade package in the secondary storage area is incomplete, a data area with the best performance is selected from the user data area to replace the secondary storage area, and the firmware upgrade package in the primary storage area or the backup storage area is loaded into the data area;
[0139] Step S313: When the firmware upgrade package in the secondary storage area is complete, the firmware upgrade package is loaded from the backup storage area to restart the storage.
[0140] See also Fig.12 In one embodiment, when executing step S33, specifically, step S33 may include the following steps:
[0141] Step S331, loading a firmware upgrade package from a backup storage area to restart the memory, and when the number of restarts reaches a preset threshold, verifying the integrity of the loaded firmware upgrade package;
[0142] Step S332: When the firmware upgrade package in the backup storage area is incomplete, a data area with the best performance is selected from the user data area to replace the backup storage area, and the firmware upgrade package in the primary storage area or the secondary storage area is loaded into the data area;
[0143] Step S333: When the firmware upgrade package in the backup storage area is complete, the firmware upgrade package is loaded from the main storage area to restart the storage.
[0144] The embodiments of the present invention disclosed above are only used to help illustrate the present invention. The embodiments do not describe all the details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. A memory, characterized in that: include: A storage block, in which mutually isolated primary storage areas, secondary storage areas, backup storage areas and user data areas are set; as well as A main control unit, used to obtain a firmware upgrade package and load it into the secondary storage area, and the main control unit is also used to load the firmware upgrade package in the secondary storage area into the primary storage area and the backup storage area; The main control unit is further used to load the firmware upgrade package from the primary storage area, the secondary storage area and the backup storage area respectively, restart the memory, and verify the integrity of the loaded firmware upgrade package; When the main control unit determines that the firmware upgrade package in a certain storage area is incomplete, it selects the data area with the best performance from the user data area to replace the storage area, and loads the firmware upgrade package in other storage areas into the data area; wherein the data area with the best performance is represented by the storage area with the shortest estimated completion time, and the estimated completion time refers to an indicator for evaluating the length of time required to complete a task or operation.
2. The memory according to claim 1, characterized in that: The main control unit obtains the firmware upgrade package from the processing module, and the processing module is used to verify the integrity of the obtained firmware upgrade package and send it to the main control unit when it is determined that the firmware upgrade package is complete.
3. The memory according to claim 2, characterized in that: The main control unit is used to verify the integrity of the firmware upgrade package in the secondary storage area. When it is determined that it is complete, it is loaded into the primary storage area and the backup storage area. When it is determined that it is incomplete, it is repeatedly used to obtain the firmware upgrade package from the processing module until the obtained firmware upgrade package is complete.
4. The memory according to claim 3, characterized in that: The main control unit is used to check the integrity of the firmware upgrade package in the main storage area and the backup storage area respectively, and when it is determined that the firmware upgrade package in a certain storage area is incomplete, repeatedly load the firmware upgrade package in the secondary storage area into a certain storage area.
5. The memory according to claim 1, characterized in that: The main control unit loads the firmware upgrade package from the main storage area to restart the memory, and checks the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold.
6. The memory according to claim 1, characterized in that: The main control unit loads the firmware upgrade package from the secondary storage area to restart the memory, and checks the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold.
7. The memory according to claim 1, characterized in that: The main control unit loads the firmware upgrade package from the backup storage area to restart the memory, and checks the integrity of the loaded firmware upgrade package when the number of restarts reaches a preset threshold.
8. The memory according to claim 7, characterized in that: The preset threshold is in the range of 500 to 1000.
9. A method for upgrading the firmware of a memory, characterized in that: The memory includes a storage block, wherein the storage block is provided with a mutually isolated primary storage area, a secondary storage area, a backup storage area, and a user data area, and the firmware upgrade method includes: Loading a firmware upgrade package into the secondary storage area; Loading the firmware upgrade package in the secondary storage area into the primary storage area and the backup storage area respectively; Loading a firmware upgrade package from the primary storage area, the secondary storage area, and the backup storage area respectively, restarting the memory, and verifying the integrity of the loaded firmware upgrade package; When a firmware upgrade package in a certain storage area is incomplete, a data area with the best performance is selected from the user data area to replace the storage area, and the firmware upgrade package in other storage areas is loaded into the data area; wherein the data area with the best performance is represented by the storage area with the shortest estimated completion time, and the estimated completion time refers to an indicator for evaluating the length of time required to complete a task or operation.
Citation Information
Patent Citations
Boot method and Boot device of electronic equipment and electronic equipment
CN112379932A
Storage device and control method thereof
CN118426815A