A firmware upgrading method of a storage device and an electronic device

The method of copying and activating new firmware in the storage device by means of read-only memory code solves the problems of failure and long time consumption caused by power failure or restart during the firmware upgrade process of storage devices, and realizes an efficient and stable firmware upgrade process.

CN122489101APending Publication Date: 2026-07-31合肥康芯威存储技术有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
合肥康芯威存储技术有限公司
Filing Date
2026-07-01
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

During the firmware upgrade process of existing storage devices, there are failure issues caused by power failure or restart failure, and the automatic reset operation takes a long time, which reduces the upgrade efficiency and stability of the system.

Method used

By using read-only memory code, without relying on the operating system, the starting address and data length of the backend interface and main function of the new firmware are recorded, copied to the runtime address, and the new firmware is activated without the need for storage device reset or power failure. The linker script is used to set the main function and backend interface in the same memory segment, ensuring the security and reliability of the upgrade process.

Benefits of technology

It ensures the security and reliability of the firmware upgrade process, improves upgrade efficiency, avoids storage device reset or power failure operations, and ensures system stability and seamless communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122489101A_ABST
    Figure CN122489101A_ABST
Patent Text Reader

Abstract

This invention discloses a firmware upgrade method and electronic device for storage devices, belonging to the field of storage technology. The firmware upgrade method includes: after the new firmware is downloaded, updating the firmware read address; recording the start address and data length of the backend interface and main function of the new firmware; copying the backend interface and main function of the new firmware to the execution address using read-only memory (ROM) code based on the start address and data length of the backend interface and main function of the new firmware; and the ROM code jumping to the execution address to execute the main function of the new firmware, activating the new firmware; when the new firmware is activated, the host remains powered on, and the storage device does not need to perform a reset or restart operation. The firmware upgrade method and electronic device for storage devices provided by this invention can improve firmware upgrade efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage technology, and in particular to a firmware upgrade method and electronic device for a storage device. Background Technology

[0002] After a field firmware update (FFU) upgrade is completed in storage devices, some require the host to perform a power-down or power-on reset operation. This not only increases the complexity of the upgrade process but also can lead to storage device failure due to power instability or restart failure during the power-down process. Others use an automatic reset operation without power loss, which avoids host power loss, but the storage device upgrade process takes a long time, reducing system upgrade efficiency. Summary of the Invention

[0003] The purpose of this invention is to provide a firmware upgrade method and electronic device for a storage device, which can improve firmware upgrade efficiency and ensure system stability.

[0004] This invention provides a firmware upgrade method for a storage device, comprising at least: Once the new firmware is downloaded, update the firmware read address; Record the starting address and data length of the backend interface and main function of the new firmware; and Based on the starting address and data length of the backend interface and main function of the new firmware, the read-only memory code copies the backend interface and main function of the new firmware to the execution address; The read-only memory code jumps to the runtime address to execute the main function of the new firmware, thereby activating the new firmware.

[0005] In one embodiment of the present invention, the firmware upgrade method for the storage device further includes the following steps: Determine whether to perform a firmware upgrade operation; If a firmware upgrade operation is performed, the new firmware will be downloaded; and If a firmware upgrade is not being performed, the read-only memory code executes the main function of the original firmware to complete the operation.

[0006] In one embodiment of the present invention, a firmware upgrade operation is performed based on an upgrade flag.

[0007] In one embodiment of the present invention, after downloading the new firmware, the firmware upgrade method for the storage device further includes the following steps: Determine whether the new firmware has been downloaded successfully; If the new firmware download is complete, update the firmware read address; If the new firmware is not downloaded completely, determine whether the download time of the new firmware exceeds the download threshold; If the download time of the new firmware exceeds the download threshold, the new firmware will be downloaded again; and If the download time of the new firmware does not exceed the download threshold, continue to determine whether the download of the new firmware is complete.

[0008] In one embodiment of the present invention, the main function and the backend interface are set in the same memory segment by a linker script.

[0009] In one embodiment of the present invention, after recording the starting address and data length of the backend interface and main function of the new firmware, the firmware upgrade method of the storage device further includes the following step: recording the verification value of the backend interface and main function of the new firmware.

[0010] In one embodiment of the present invention, after the read-only memory code copies the backend interface and main function of the new firmware to the runtime address, the firmware upgrade method of the storage device further includes the following steps: Obtain the actual verification values ​​of the backend interface and main function of the new firmware within the running address; Determine whether the actual check value is the same as the recorded check value; If the actual verification value is the same as the recorded verification value, the read-only memory code jumps to the execution address to execute the main function of the new firmware, activating the new firmware; and If the actual verification value is different from the recorded verification value, download the new firmware again.

[0011] In one embodiment of the present invention, after the new firmware is activated, the upgrade flag is cleared.

[0012] In one embodiment of the present invention, when the new firmware is activated, the host remains powered on, and the storage device does not need to perform a reset or restart operation.

[0013] The present invention also provides an electronic device, the electronic device comprising: Memory, which stores computer programs; and The processor runs the computer program to implement the firmware upgrade method for the storage device as described in any of the above descriptions.

[0014] In summary, this invention provides a firmware upgrade method and electronic device for a storage device. The read-only memory code copies the backend interface and main function to a specified execution address and jumps to execute them based on the starting address and data length of the new firmware's backend interface and main function. This fundamentally ensures the security of the upgrade process and allows firmware upgrades to be completed without requiring a storage device reset or power failure, thus improving upgrade efficiency. Furthermore, by using a linker script to place the main function and backend interface in the same memory segment, the reliability and security of the upgrade process are guaranteed.

[0015] Of course, any product implementing this invention does not necessarily need to achieve all of the advantages described above at the same time. Attached Figure Description

[0016] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 This is a schematic diagram of a firmware upgrade method for a storage device in one embodiment.

[0018] Figure 2 This is a schematic diagram illustrating the specific steps of a firmware upgrade method for a storage device in one embodiment.

[0019] Figure 3 This is a schematic diagram of an electronic device in one embodiment.

[0020] Label Explanation: 11. Processor; 12. Memory. Detailed Implementation

[0021] To facilitate understanding of this application, a more complete description will be provided below with reference to the accompanying drawings. Preferred embodiments of this application are shown in the drawings. However, this application can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the disclosure of this application.

[0022] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the specification of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application.

[0023] In the description of this invention, it should be understood that the terms "center," "upper," "lower," "front," "rear," "left," and "right," etc., indicating orientation or positional relationships, are based on the orientation or positional relationships shown in the accompanying drawings and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or component referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Similarly, the terms "high" and "low," indicating degree, are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or component referred to must have a high or low position, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0024] In embedded multi-media cards (EMMCs), field firmware update technology allows devices to upgrade the firmware inside the storage device without disassembling it. A complete field firmware upgrade process includes downloading the new firmware and activating it. When activating the new firmware by actively performing a power-down or power-on reset operation by the host, additional hardware control signals are required, making the operation cumbersome. Furthermore, during a power-down, unstable voltage and timing anomalies can easily lead to incorrect storage device status, firmware corruption, or even permanent failure, resulting in low reliability. When activating the new firmware by automatically triggering a reset operation inside the storage device, although a host power-down is not required, a complete initialization process including bus re-enumeration, register resetting, and driver reloading must be completed, which takes a long time and reduces the upgrade efficiency of the storage device. Therefore, this invention provides a firmware upgrade method and electronic device for storage devices, which can improve firmware upgrade efficiency and ensure system stability.

[0025] Please see Figure 1 As shown, the present invention provides a firmware upgrade method for a storage device, which includes at least steps S110 to S140.

[0026] Step S110: After the new firmware is downloaded, update the firmware read address.

[0027] Step S120: Record the starting address and data length of the backend interface and main function of the new firmware.

[0028] Step S130: Based on the starting address and data length of the backend interface and main function of the new firmware, the read-only memory code copies the backend interface and main function of the new firmware to the running address.

[0029] Step S140: The read-only memory code jumps to the running address to execute the main function of the new firmware and activates the new firmware.

[0030] Please see Figure 1As shown, in one embodiment of the present invention, the read-only memory code (ROM Code) is an unmodifiable low-level boot program permanently stored in the read-only memory inside the storage device controller. In this application, the read-only memory code does not depend on any operating system and is executed first after power-on or upon receiving a software jump instruction. It is responsible for performing upgrade status determination, new firmware copying, new firmware integrity verification, and control flow jumps, etc.

[0031] Please see Figure 2 As shown, in one embodiment of the present invention, before downloading the new firmware, the firmware upgrade method for the storage device further includes determining whether to perform a firmware upgrade operation. If a firmware upgrade operation is performed, the new firmware is downloaded. If a firmware upgrade operation is not performed, the original firmware is executed, and the operation is completed. Specifically, this includes steps S101 to S103.

[0032] Step S101: Determine whether to perform a firmware upgrade operation. If a firmware upgrade operation is to be performed, proceed to step S102. If a firmware upgrade operation is not to be performed, proceed to step S103.

[0033] Step S102: Download the new firmware.

[0034] Step S103: Execute the main function of the original firmware to complete the operation.

[0035] Please see Figure 2 As shown, in one embodiment of the present invention, in steps S101 to S103, the read-only memory code determines whether to perform a firmware upgrade operation based on the upgrade flag bit. If the value of the upgrade flag bit is, for example, 0, the read-only memory code determines that this operation belongs to the normal operation mode and is not a firmware upgrade operation. The read-only memory code directly jumps to the main function entry address of the original firmware, transfers control to the original firmware, and the storage device starts normally and executes the operation. If the value of the upgrade flag bit is, for example, 1, it is determined to be a firmware upgrade operation, and the new firmware download process begins.

[0036] Please see Figure 2 As shown, in one embodiment of the present invention, after executing step S102, step S110 further includes determining whether the new firmware has been downloaded completely. If the new firmware has been downloaded completely, the firmware read address is updated. If the new firmware has not been downloaded completely, the process waits for the new firmware to be downloaded completely. Specifically, step S110 includes steps S111 to S113.

[0037] Step S111: Determine if the new firmware download is complete. If the new firmware download is complete, proceed to step S112. If the new firmware download is incomplete, proceed to step S113.

[0038] Step S112: Update firmware read address.

[0039] Step S113: Monitor whether the download time of the new firmware exceeds the download threshold. If the download time of the new firmware exceeds the download threshold, return to step S102. If the download time of the new firmware does not exceed the download threshold, return to step S111.

[0040] Please see Figure 2 As shown, in one embodiment of the present invention, in step S111, it is determined whether the new firmware has been downloaded successfully based on the download flag bit. If the read download flag bit is, for example, 1, it indicates that the new firmware has been downloaded successfully. If the read download flag bit is, for example, 0, it is read again after a preset time period until the read download flag bit is 1. The preset time period can be set according to the system real-time requirements and the storage device write speed. Only after confirming that the new firmware has been completely written to the storage device will subsequent firmware operation be performed to avoid loading incomplete or damaged new firmware, which could brick the storage device. In this embodiment, the preset time period is, for example, 5 seconds.

[0041] Please see Figure 2 As shown, in one embodiment of the present invention, in step S112, after the new firmware is downloaded to the storage device, the firmware read address is updated. The firmware read address refers to the starting block number where the new firmware is stored in the storage device. The updated firmware read address is the storage address of the new firmware, which is different from the storage address of the original firmware. After the new firmware is downloaded, updating the firmware read address ensures that the new firmware can be accurately and efficiently located and executed.

[0042] Please see Figure 2 As shown, in one embodiment of the present invention, in step S113, when the new firmware has not yet been downloaded completely, it is monitored whether the download time of the new firmware exceeds a download threshold. The download threshold is dynamically determined based on the size of the new firmware, the communication interface rate, and the write speed of the storage device. Setting a download threshold can prevent the system from freezing. When the download time of the new firmware exceeds the download threshold, it is determined that the firmware download has timed out or failed, and the download of the new firmware is re-executed. When the download time of the new firmware does not exceed the download threshold, the download flag bit is read again until the read download flag bit is 1, indicating that the new firmware download is complete.

[0043] Please see Figure 2 As shown, in one embodiment of the present invention, in step S120, the backend interface is the low-level communication interface in the storage device firmware responsible for physical layer, link layer, and protocol layer interaction with the host. In this application, the backend interface specifically includes a physical link management interface, a direct memory access control interface, and a communication protocol interface between the host and the storage device. The backend interface maintains consistency in physical address and call handle before and after firmware upgrade. The main function is the starting function pointer that guides the entire storage management system into the main loop program after the storage device initialization is completed.

[0044] Please see Figure 2 As shown, in one embodiment of the present invention, in step S120, the main function and the backend interface are set in the same specific memory segment by the linker script. The linker script is a configuration file that controls the linker to map segments in the input file to segments in the output file and controls the layout of the output file in memory. In this embodiment, by defining a dedicated memory segment in the linker script and using linker instructions to force the function pointer of the main function entry point and the communication protocol function of the backend interface to be specified to the starting physical address of that memory segment. When the firmware system of the storage device is built, configuring the backend interface and the main function in the same pre-allocated specific memory segment can ensure that the physical address and calling relationship of the backend interface remain unchanged before and after firmware jumps, thereby eliminating the risk of system crash due to address drift.

[0045] Please see Figure 2 As shown, in one embodiment of the present invention, in step S120, after the new firmware is downloaded to the storage medium in the storage device, the starting address and data length of the backend interface and main function in the storage medium are recorded. The starting address is the starting memory location of the backend interface and main function in the storage medium, and the data length is the number of bytes occupied by the backend interface and main function in the storage medium. Recording the starting address and data length of the backend interface and main function ensures that they can be accurately copied to the running address later, achieving efficient and secure firmware switching.

[0046] Please see Figure 2 As shown, in one embodiment of the present invention, after executing step S120, the firmware upgrade method further includes recording the verification values ​​of the backend interface and main function of the new firmware, which can ensure the correctness of subsequent firmware copying. Specifically, this includes step S121.

[0047] Step S121: Record the verification values ​​of the backend interface and main function of the new firmware.

[0048] Please see Figure 2 As shown, in one embodiment of the present invention, in step S130, the running address refers to the physical memory address where the backend interface and main function of the new firmware are actually executed. The running address is preset by the linker script during the compilation and linking stage and is fixed as a constant in the read-only code of the read-only memory code, ensuring the consistency of the running address each time.

[0049] Please see Figure 2 As shown, in one embodiment of the present invention, after copying the backend interface and main function to the runtime address, the firmware upgrade method further includes comparing the verification values ​​of the backend interface and main function copied to the runtime address with the previously recorded verification values. Only if the comparison passes can the process jump to the main function of the new firmware for execution and activate the new firmware. Specifically, this includes steps S131 to S132.

[0050] Step S131: Obtain the actual verification values ​​of the backend interface and main function within the running address.

[0051] Step S132: Determine whether the actual check value is the same as the recorded check value. If the actual check value is the same as the recorded check value, proceed to step S140. If the actual check value is different from the recorded check value, return to step S130.

[0052] Please see Figure 2 As shown, in one embodiment of the present invention, in steps S131 to S132, the read-only memory code will jump to the main function of the new firmware only after the backend interface and main function have been copied and the checksum comparison has passed. If the checksum comparison fails, the backend interface and main function are copied again from the storage medium according to the starting address and data length, providing a very high level of security for firmware upgrades. In this embodiment, when the checksum comparison fails, the number of times the backend interface and main function are copied again can be set. For example, if the checksum still fails after more than 3 recopying attempts, the new firmware is downloaded again.

[0053] Please see Figure 2 As shown, in one embodiment of the present invention, in step S140, the read-only memory code directly jumps to the main function entry point, and the new firmware officially takes over the system and begins running. Since the physical addresses of the main function entry point and the backend interface in a specific memory segment are completely consistent with those before the upgrade, the new firmware can directly inherit the interface context and communication state before the upgrade, achieving seamless continued communication with the host.

[0054] Please see Figure 2 As shown, in one embodiment of the present invention, after activating the new firmware, in order to ensure the one-way safe transition of the state machine, the read-only memory code clears the upgrade flag bit, preventing the read-only memory code from mistakenly determining that it is currently in a firmware upgrade operation when the storage device starts normally next time, thus ensuring the stability of system operation. At the same time, when activating the new firmware, the host remains powered on, and the storage device does not need to perform a reset or restart operation, maintaining an uninterrupted connection channel with the host at the physical level.

[0055] Please see Figure 3 As shown, the present invention provides an electronic device, which includes a processor 11, a memory 12, and a computer program stored on the memory 12 and executable on the processor 11. The processor 11 executes a firmware upgrade method for the aforementioned memory device.

[0056] Please see Figure 3As shown, the memory 12 includes at least one type of readable storage medium, including flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 12 can be an internal storage unit of an electronic device, such as a portable hard drive. In other embodiments, the memory 12 can be an external storage device of the electronic device, such as a plug-in portable hard drive, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. Furthermore, the memory 12 can include both internal and external storage units of the electronic device. The memory 12 can be used not only to store application software and various types of data installed on the electronic device, but also to temporarily store data that has been output or will be output.

[0057] Please see Figure 3 As shown, in some embodiments, the processor 11 can be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits packaged with the same or different functions, including combinations of one or more central processing units, microprocessors, digital processing chips, graphics processors, and various control chips. The processor 11 is the control unit of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. It executes programs or modules stored in the memory 12 and calls data stored in the memory 12 (such as programs for firmware upgrade methods of storage devices) to perform various functions of the electronic device and process data.

[0058] In some embodiments, the processor 11 executes the operating system of the electronic device and various installed applications. The processor 11 executes the applications to implement the steps in the firmware upgrade method for the storage device described above.

[0059] In some embodiments, the computer program may be divided into one or more modules, one or more of which are stored in the memory 12 and executed by the processor 11 to perform the present invention. The one or more modules may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in an electronic device.

[0060] This invention provides a firmware upgrade method and electronic device for a storage device. The read-only memory code copies the backend interface and main function to a specified execution address and jumps to execute them based on the starting address and data length of the new firmware's backend interface and main function. This fundamentally ensures the security of the upgrade process and allows firmware upgrades to be completed without requiring a storage device reset or power failure, thus improving upgrade efficiency. By using a linker script to place the main function and backend interface in the same memory segment, the reliability and security of the upgrade process are guaranteed.

[0061] The embodiments of the present invention disclosed above are merely illustrative of the invention. The embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention. The invention is limited only by the claims and their full scope and equivalents.

Claims

1. A firmware upgrade method for a storage device, characterized in that, At least including: Once the new firmware is downloaded, update the firmware read address; Record the starting address and data length of the backend interface and main function of the new firmware; as well as Based on the starting address and data length of the backend interface and main function of the new firmware, the read-only memory code copies the backend interface and main function of the new firmware to the execution address; The read-only memory code jumps to the runtime address to execute the main function of the new firmware, thereby activating the new firmware.

2. The firmware upgrade method for a storage device according to claim 1, characterized in that, The firmware upgrade method for the storage device further includes the following steps: Determine whether to perform a firmware upgrade operation; If a firmware upgrade operation is performed, the new firmware will be downloaded; and If a firmware upgrade is not being performed, the read-only memory code executes the main function of the original firmware to complete the operation.

3. The firmware upgrade method for a storage device according to claim 2, characterized in that, The firmware upgrade operation is determined based on the upgrade flag.

4. The firmware upgrade method for a storage device according to claim 2, characterized in that, After downloading the new firmware, the firmware upgrade method for the storage device further includes the following steps: Determine whether the new firmware has been downloaded successfully; If the new firmware download is complete, update the firmware read address; If the new firmware is not downloaded completely, determine whether the download time of the new firmware exceeds the download threshold; If the download time of the new firmware exceeds the download threshold, the new firmware will be downloaded again; and If the download time of the new firmware does not exceed the download threshold, continue to determine whether the download of the new firmware is complete.

5. The firmware upgrade method for a storage device according to claim 1, characterized in that, The main function and the backend interface are placed in the same memory segment by linking the script.

6. The firmware upgrade method for a storage device according to claim 1, characterized in that, After recording the starting address and data length of the backend interface and main function of the new firmware, the firmware upgrade method for the storage device further includes the following step: recording the verification values ​​of the backend interface and main function of the new firmware.

7. The firmware upgrade method for a storage device according to claim 1, characterized in that, After the read-only memory code copies the backend interface and main function of the new firmware to the runtime address, the firmware upgrade method for the storage device further includes the following steps: Obtain the actual verification values ​​of the backend interface and main function of the new firmware within the running address; Determine whether the actual check value is the same as the recorded check value; If the actual verification value is the same as the recorded verification value, the read-only memory code jumps to the execution address to execute the main function of the new firmware, activating the new firmware; and If the actual verification value is different from the recorded verification value, download the new firmware again.

8. The firmware upgrade method for a storage device according to claim 1, characterized in that, After activating the new firmware, clear the upgrade flag.

9. The firmware upgrade method for a storage device according to claim 1, characterized in that, When the new firmware is activated, the host remains powered on, and the storage device does not need to be reset or restarted.

10. An electronic device, characterized in that, The electronic device includes: Memory, which stores computer programs; and The processor runs the computer program to implement the firmware upgrade method for the storage device as described in any one of claims 1 to 9.