A firmware upgrade method for storage device, control device and storage device
By sending firmware activation and reset instructions to the storage device and using the response information for preparation and reset, the problem of traditional firmware upgrades requiring power outage and restart is solved, online firmware upgrades are realized, and work efficiency is improved and business continuity is ensured.
Patent Information
- Application Number
- CN202011289132.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-17
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2040-11-17
AI Technical Summary
The upgrade of the firmware of traditional solid-state drives requires the suspension of current services, power outage and restart, resulting in business interruption, especially in special occasions such as servers, and operation is troublesome, affecting work efficiency.
By sending firmware activation instructions and reset instructions to the storage device, and using the response information for preparation and reset, online firmware upgrades are achieved, avoiding power outage and restarting, and ensuring business continuity.
It realizes the online upgrade of the storage device firmware, improves work efficiency, avoids business interruption, and is suitable for occasions where power outages and restarts are not allowed.
Smart Images

Figure CN112540785B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of mobile storage hard disks, and in particular to a firmware upgrade method for a storage device, a control device, and a storage device. Background Art
[0002] With the development of computer technology, solid state drives (SSDs) have appeared on the market. When SSDs leave the factory, their internal chips are equipped with firmware programs developed by the manufacturer by default to meet the read and write access of the client-related drivers to the SSDs. However, in actual use, it is sometimes necessary to upgrade the firmware program of the SSD to a new version to fix related bugs in the old version of the firmware, optimize firmware performance, or meet new functions and new requirements, etc., which can bring performance improvements to the SSD or add new functions, so firmware upgrades are very necessary.
[0003] In the traditional upgrade method, the firmware upgrade of the SSD requires stopping the current business, downloading the firmware to the specified location of the SSD through the upgrade tool on the host side, and further disconnecting and reconnecting the SSD by restarting the host or hot plugging to load the newly upgraded firmware. The power failure of the SSD will cause the interruption of the current business, which is not allowed in many special occasions such as servers. At the same time, it is also very troublesome to operate, which brings inconvenience to business processing. Summary of the invention
[0004] In order to solve the above problems, the present application provides a storage device firmware upgrade method, a control device and a storage device, which can complete the firmware upgrade of the storage device online without powering on and off again.
[0005] To solve the above technical problems, a technical solution adopted in the present application is to provide a firmware upgrade method for a storage device, the method comprising: sending a firmware activation instruction to the storage device so that the storage device can make preparations before activation, and feeding back a response information to the control device after the preparation is completed, the response information being used to indicate that the storage device will activate the new firmware at the next reset; after receiving the response information, sending a reset instruction to the storage device to reset the storage device; after the firmware upgrade of the storage device is completed, establishing a communication connection with the storage device.
[0006] Before sending the firmware activation instruction to the storage device, the method further includes: sending new firmware to the storage device so that the storage device stores the new firmware.
[0007] Wherein, after receiving the response information, a reset instruction is sent to the storage device to reset the storage device, including: after receiving the response information, the enable field of the controller configuration register of the storage device is cleared to 0 to reset the storage device and the preparation field of the controller status register of the storage device is cleared to 0; wherein the response information is fed back in the status field of the completion command queue; the enable field of the controller configuration register of the storage device is set to 1 to load new firmware to the storage device.
[0008] After clearing the enable field of the controller configuration register of the storage device to 0 to reset the storage device and clearing the preparation field of the controller status register of the storage device to 0, the method further includes: suspending communication with the storage device.
[0009] Wherein, after the storage device firmware upgrade is completed, a communication connection with the storage device is established, including: when it is detected that the preparation field of the controller status register of the storage device is set to 1, a communication connection with the storage device is established; wherein the storage device sets the preparation field of the controller status register of the storage device to 1 after the new firmware initialization operation is completed.
[0010] Wherein, establishing a communication connection with the storage device includes: sending a management command to recreate a read-write communication queue and establishing a communication connection with the storage device.
[0011] Among them, the number of initialization operations is less than two.
[0012] To solve the above technical problems, another technical solution adopted in the present application is: to provide a control device, which includes a control unit and a storage unit, the storage unit is used to store a computer program, and when the computer program is executed by the control unit, it is used to implement the firmware upgrade method of the above storage device.
[0013] To solve the above technical problems, another technical solution adopted in the present application is: to provide a firmware upgrade method for a storage device, the method comprising: receiving a firmware activation instruction to perform pre-activation preparations, and feeding back response information to the control device after the preparations are completed, the response information being used to indicate that the storage device will activate the new firmware at the next reset; receiving a reset instruction to reset the storage device; and establishing a communication connection with the control device after the firmware upgrade of the storage device is completed.
[0014] Before receiving the firmware activation instruction, the method further includes: receiving and storing new firmware.
[0015] Wherein, receiving a reset instruction to reset the storage device includes: receiving a reset instruction, clearing the enable field of the controller configuration register to 0 to reset the storage device, and clearing the preparation field of the controller status register to 0; setting the enable field of the controller configuration register to 1 to load new firmware.
[0016] Among them, after the storage device firmware upgrade is completed, a communication connection with the control device is established, including: setting the preparation field of the controller status register to 1, and establishing a communication connection with the control device; wherein the storage device sets the preparation field of the controller status register to 1 after the new firmware initialization operation is completed.
[0017] The time difference between clearing the ready field of the controller status register to 0 and setting the ready field of the controller status register to 1 is less than the timeout time reported by the controller function register.
[0018] The response information is fed back in the status field of the completion queue command.
[0019] To solve the above technical problems, another technical solution adopted in the present application is: to provide a storage device, the control device includes a control unit and a storage unit, the storage unit is used to store a computer program, and when the computer program is executed by the control unit, it is used to implement the firmware upgrade method of the above storage device.
[0020] The beneficial effect of the embodiment of the present application is as follows: Different from the prior art, the present application provides a method for upgrading the firmware of a storage device, which sends a firmware activation instruction to the storage device so that the storage device prepares for activation, and after the preparation is completed, it feeds back a response message to the control device, and the response message is used to indicate that the storage device will activate the new firmware at the next reset, and after receiving the response message, the control device sends a reset instruction to the storage device so that the storage device is reset, and finally, after the storage device upgrade is completed, a communication connection with the storage device is established. In this way, the response message fed back by the storage device can be used, so that after the control device sends the reset instruction to the storage device, the firmware upgrade of the storage device can be completed online without the need to power on and off again, thereby improving work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0022] Figure 1 It is a flowchart of an embodiment of a firmware upgrade method for a storage device provided by the present application;
[0023] Figure 2 It is a flowchart of another embodiment of the firmware upgrade method of the storage device provided by the present application;
[0024] Figure 3 It is a flowchart of another embodiment of the firmware upgrade method of the storage device provided by the present application;
[0025] Figure 4 It is a flowchart of another embodiment of the firmware upgrade method of the storage device provided by the present application;
[0026] Figure 5 It is a structural schematic diagram of an embodiment of a control device provided by the present application;
[0027] Figure 6 is a structural schematic diagram of an embodiment of a storage device provided by the present application;
[0028] Figure 7 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION
[0029] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It will be understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only some but not all structures related to the present application are shown in the drawings. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0030] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0031] A solid-state drive is an external computer storage device made of an array of solid-state electronic storage chips. Compared with conventional hard disks, solid-state drives are widely used in portable and embedded computers, especially industrial control computers, due to their fast read and write speeds, low operating noise, wide operating temperature range, good shock resistance, light weight, and low power consumption. They are also gradually replacing conventional hard disks. The inventors of this application have found through long-term research that although solid-state drives have many features, they still have some shortcomings in their upgrade use. For example, the problem that solid-state drives need to be powered off again when upgrading their firmware has not been well solved. Based on this, the inventors of this application propose the following multiple embodiments:
[0032] See also Figure 1 , Figure 11 is a flow chart of an embodiment of a method for upgrading the firmware of a storage device provided by the present application. The method of this embodiment is applied to a control device, and the method specifically includes:
[0033] Step 11: Send a firmware activation instruction to the storage device so that the storage device performs pre-activation preparations, and feeds back response information to the control device after the preparations are completed. The response information is used to indicate that the storage device will activate the new firmware at the next reset.
[0034] It is understandable that the control device and the storage device can be coupled in a variety of ways, including but not limited to, for example, SATA (Serial Advanced Technology Attachment), SCSI (Small Computer System Interface), SAS (Serial Attached SCSI), IDE (Integrated Drive Electronics), USB (Universal Serial Bus), PCIE (Peripheral Component Interconnect Express, PCIe), NVMe (NVM Express), Ethernet, Fiber Channel, wireless communication network, etc. In this embodiment, the control device and the storage device mainly communicate based on the NVME protocol to implement a method for subsequent storage device firmware upgrade.
[0035] Among them, the control device can be an information processing device that can communicate with the storage device in the above manner, such as a personal computer, a tablet computer, a server, a portable computer, a network switch, a router, a cellular phone, a personal digital assistant, etc.
[0036] The storage device is composed of a storage unit and a control unit, and the control unit is composed of multiple CPUs (Central Processing Units) and auxiliary hardware units. The number of CPUs and auxiliary hardware units is not specifically limited here, and should be set by those skilled in the art according to actual conditions.
[0037] The firmware activation instruction is a standard management command (admin command) FirmwareActive sent by the control device to trigger the storage device to activate the new firmware, that is, to send the firmware activation instruction.
[0038] In this embodiment, after the control device sends a firmware activation instruction, the storage device will respond to the firmware activation instruction and turn off some idle processes (such as wear balancing, garbage collection, etc.) to prepare for activating the firmware. After the idle processing preparation of the storage device is completed, a response message can be fed back to the control device. The response message is the storage device's feedback to the control device through a standard protocol in the status field of the CQ (CompletionQueue) that responds to Firmware Active, which is used to indicate that the storage device will activate the new firmware at the next reset.
[0039] Step 12: After receiving the response information, a reset instruction is sent to the storage device to reset the storage device.
[0040] It can be understood that the firmware upgrade action of the storage device usually needs to be started after power is cut off and then restarted. In the present embodiment, since the storage device has informed the control device before the reset and upgrade, the new firmware will be loaded / activated after the next reset. At this time, the control device will suspend issuing all commands and only send a reset instruction to the storage device, so that the storage device can be reset directly in an online state without the need to perform the power-off reset action again. This enables the storage device to be upgraded without powering off, thus ensuring the continuity of matter processing.
[0041] Step 13: After the storage device is upgraded, the control device establishes a communication connection with the storage device.
[0042] After the storage device upgrade is completed, the control device can re-initialize the communication to re-establish the communication connection with the storage device for normal interaction.
[0043] Different from the prior art, the present application provides a method for upgrading the firmware of a storage device, which sends a firmware activation instruction to the storage device so that the storage device prepares for activation, and after the preparation is completed, it feeds back a response message to the control device, and the response message is used to indicate that the storage device will activate the new firmware at the next reset, and after receiving the response message, the control device sends a reset instruction to the storage device to reset the storage device, and finally establishes a communication connection with the storage device after the storage device upgrade is completed. In this way, the response message fed back by the storage device can be used, so that after the control device sends the reset instruction to the storage device, the firmware upgrade of the storage device can be completed online without the need to power on and off again, thereby improving work efficiency.
[0044] See also Figure 2 , Figure 2 1 is a flow chart of another embodiment of a method for upgrading the firmware of a storage device provided by the present application. This embodiment is applied to a control device, and the method specifically includes:
[0045] Step 21: Send the new firmware to the storage device so that the storage device stores the new firmware.
[0046] The new firmware is sent by the control device using an upgrade tool through the standard management command (admin command) Firmware Image Download. The upgrade tool is used to download the new firmware in batches to the storage device, and the storage device then writes the new firmware into the power-off protection chip for storage.
[0047] The Firmware Image Download packet size cannot exceed the maximum reported value and must be 4-byte aligned; otherwise, the download data packet will be abnormal.
[0048] In an actual scenario, a plurality of firmware slots are provided in the chip, such as firmware slot 1, firmware slot 2, firmware slot 3, firmware slot 4, etc., which are respectively used to store the same or different firmware. When the storage device receives new firmware, the new firmware can be stored in the designated firmware slot according to the instruction of the control device. When multiple firmwares are stored in the firmware slot of the storage device, the new firmware in the corresponding firmware slot can be loaded into the designated firmware slot according to the instruction. Optionally, in order to improve reliability, the same new firmware can be saved and written into multiple firmware slots at the same time, so that when one or more firmware slots fail, the valid new firmware to be run can still be obtained from other firmware slots.
[0049] Furthermore, after sending the new firmware to the storage device, the storage device can also determine the integrity of the new firmware. It can use algorithms including CRC check (Cyclic Redundancy Check), parity check, and cumulative check to calculate a result on the new firmware, and then compare the result with the result calculated when the control device is downloaded. If the results are consistent, it indicates that the new firmware is complete and the storage device can store it.
[0050] Before step 21, it is also possible to determine whether the storage device needs to be upgraded by comparing the firmware version of the current firmware of the storage device with the new firmware stored in the upgrade server corresponding to the control device. If the two are different, it means that the storage device needs to be upgraded, and then the new firmware is sent to the storage device; if the two are the same, it means that the storage device does not need to be upgraded.
[0051] Step 22: Send a firmware activation instruction to the storage device so that the storage device performs pre-activation preparations, and feeds back response information to the control device after the preparations are completed. The response information is used to indicate that the storage device will activate the new firmware at the next reset.
[0052] The firmware activation instruction is used by the control device to instruct the storage device to use the firmware slot when it is reset next time, that is, to activate which new firmware to perform the firmware upgrade. For example, different new firmwares are stored in firmware slot 1 and firmware slot 2. Through the instruction of the firmware activation instruction, the storage device can select the new firmware corresponding to the firmware slot to be used for subsequent firmware upgrades.
[0053] In this embodiment, after receiving the firmware activation instruction sent by the control device, the storage device will prepare for the activation of the new firmware by shutting down some of its own idle processes (such as wear balancing, garbage collection, etc.) to put the storage device in an idle state. After that, the storage device will feedback through the standard protocol in the status field of the completion command queue in response to Firmware Active, indicating that the storage device will activate the new firmware at the next reset.
[0054] It should be noted that not all NVME storage drivers support this response method. Currently, only the Windows 10 built-in driver supports this handshake protocol. Drivers provided by other open source drivers (such as Marvel) do not support this method (when the storage device sets the corresponding activation method in the status field of the completion command queue, the control device cannot generate a reset behavior).
[0055] Step 23: After receiving the response information, clear the enable field of the controller configuration register of the storage device to 0 to reset the storage device and clear the ready field of the controller status register of the storage device to 0.
[0056] When the control device receives the response information fed back by the storage device through the status field of the completion command queue, it immediately issues an instruction to clear the enable field of the controller configuration (Controller Configuration, CC) register of the storage device to 0, that is, CC.EN (Controller Configuration Enable) = 0, which means that the EN segment in the CC register is cleared to zero, indicating that the control device suspends all command communications with the storage device to reset the storage device. Further, the storage device clears the ready field of its own controller status (Controller Status, CSTS) register to 0, that is, CSTS.RDY (Controller Status Ready) = 0, which means that the RDY segment in the CSTS register is cleared to 0, which is used to indicate whether the status of the storage device is ready.
[0057] In this embodiment, under the instruction of the response message fed back by the storage device, the control device suspends all command communications with the storage device, and only issues an instruction to reset the storage device, so that the storage device can directly perform firmware upgrades in an online state without the need to re-power on and off and reset the device. This enables the storage device to be upgraded without powering off, thereby ensuring the continuity of matter processing.
[0058] Among them, when the control device clears the CC.EN register of the storage device to 0 to trigger a reset of the storage device, the storage device needs to immediately clear the CSTS.RDY register to 0. Since the control device will quickly enable the CC.EN register and query the status of the CSTS.RDY register, if the CSTS.RDY register is not cleared to 0 in time, the storage device will not be fully prepared, but the control device will have started creating a new queue, which will ultimately lead to upgrade failure.
[0059] Step 24: Set the enable field of the controller configuration register of the storage device to 1 to enable the storage device to load the new firmware.
[0060] Among them, after the enable field of the controller configuration register of the storage device changes from 0 to 1, the storage device will generate an interrupt. It is assumed that the interrupt occurs in the blind area of loading the new firmware (the blind area of the code reboot), that is, when the interrupt is not enabled, the storage device will be abnormal at this time. Based on this, in this embodiment, the action of loading the new firmware to the storage device, that is, the action of the reboot code, needs to be performed after the control device sets the enable field of the controller configuration register of the storage device to 1, otherwise it will affect the upgrade process.
[0061] Furthermore, after setting the enable field of the controller configuration register of the storage device to 1, the storage device can prepare to communicate with the control device and immediately perform a firmware jump, that is, load the new firmware and perform initialization operations associated with the new firmware and communication, including initialization operations such as PCIE and NVME, such as determining the PCIE layer communication attributes through messages, and the mapping relationship between the registers between the storage device and the control device, etc., and for example, initializing NVME-related registers ASQ (Admin Submission Queue Base Address, management command queue base address), ACQ (AdminCompletion Queue Base Address, completion management command queue base address), AQA (Admin QueueAttributes, management command queue attributes), etc.
[0062] After the new firmware initialization operation of the storage device is completed, the storage device can set the ready field of the controller status register to 1 to inform the control device that the new firmware has been completely loaded and is ready for communication.
[0063] The number of the above initialization operations is less than two, that is, it cannot be performed again. Specifically, the number of physical layer initializations of PCIE cannot exceed two times, otherwise the PCIE will be link down and the link will be disconnected. Therefore, when the new firmware is loaded, during the initialization operation phase, the storage device must distinguish whether it is a reboot or a normal power-on, otherwise it will lead to a failure to communicate. For the method of distinguishing, some specific registers can be used to distinguish reboots. If there are no such registers, a special memory can be used for status identification to distinguish whether it is a normal power-on or a reboot.
[0064] Step 25: When it is detected that the ready field of the controller status register of the storage device is set to 1, a communication connection with the storage device is established.
[0065] The control device identifies whether the firmware upgrade action is completed or whether the storage device is working by querying whether the status of the controller status register is ready. When the control device detects that the ready field of the controller status register of the storage device is set to 1, it indicates that the new firmware of the storage device has been activated and the firmware upgrade has been completed. At this time, the control device can send a management command to recreate the read and write communication queue to establish a communication connection with the storage device.
[0066] Specifically, the control device reconfigures the NVME registers, for example, resets the admin queue, so that the admin command can resynchronize the addressing communication, and then uses create I / Q CQ (Create I / O Completion Queue command) and create I / O SQ (Create I / O Submission Queue command) to create an IO command queue to provide a synchronous instruction base address for subsequent IO read and write commands.
[0067] Furthermore, after the control device completes resetting the admin queue and re-creates the IO queue, it can communicate with the storage device again.
[0068] It should be noted that the time difference between the time when the storage device clears the preparation field of the controller status register to 0 and the time when the storage device sets the preparation field of the controller status register to 1 is less than the timeout time reported by the CAP (Controller Capabilities) register, that is, it cannot exceed CAP.TO (Controller Capabilities Timeout). When the control device queries the controller status register for too long, it will give up the query. At this time, it will be considered that the storage device has an abnormal disk drop.
[0069] In this way, the present embodiment provides a method for upgrading the firmware of a storage device. After the control device downloads the new firmware to the storage device through a tool and sends a firmware activation instruction, the storage device informs the control device that the new firmware will be loaded after the next reset by responding to the corresponding status field of the firmware activation instruction. In this way, the driver of the control device will suspend sending all commands and reset the storage device, and then shake hands with the storage device again to create a new communication queue. This can solve the problem of needing to power off or force a jump in the previous storage device firmware upgrade.
[0070] See also Figure 3 , Figure 3 FIG. 1 is a flow chart of another embodiment of a method for upgrading the firmware of a storage device provided by the present application. The method of this embodiment is applied to a storage device, and the method specifically includes:
[0071] Step 31: Receive a firmware activation instruction to perform pre-activation preparation, and feed back response information to the control device after the preparation is completed. The response information is used to indicate that the storage device will activate the new firmware at the next reset.
[0072] After receiving the firmware activation instruction, the storage device responds to the instruction by shutting down some idle processes to prepare for activating the firmware. After the idle process preparation is completed, the response information can be fed back to the control device through the standard protocol in the status field of the CQ that responds to Firmware Active, indicating that the storage device will activate the new firmware at the next reset.
[0073] Step 32: Receive a reset instruction to reset the storage device.
[0074] After receiving the response information, the control device will suspend all command communications because it already knows the next action of the storage device, and only send a reset instruction to the storage device. The storage device can be reset directly in the online state under the instruction of the reset instruction. Therefore, under the reset instruction of the control device, the storage device can perform firmware upgrades without powering off, ensuring the continuity of matter processing.
[0075] Step 33: After the storage device firmware upgrade is completed, a communication connection with the control device is established.
[0076] After the storage device upgrade is completed, the control device can re-initialize the communication to re-establish the communication connection with the storage device for normal interaction.
[0077] See also Figure 4 , Figure 4 : is a flowchart of another embodiment of the firmware upgrade method of the storage device provided by the present application. The method of this embodiment is applied to the storage device, and the method specifically includes:
[0078] Step 41: Receive and store new firmware.
[0079] The new firmware is sent by the control device using an upgrade tool through the standard management command (admin command) Firmware Image Download. The upgrade tool is used to download the new firmware in batches to the storage device, and the storage device then writes the new firmware into the power-off protection chip for storage.
[0080] The Firmware Image Download packet size cannot exceed the maximum reported value and must be 4-byte aligned; otherwise, the download data packet will be abnormal.
[0081] Step 42: Receive a firmware activation instruction to perform pre-activation preparations, and feed back response information to the control device after the preparations are completed. The response information is used to indicate that the storage device will activate the new firmware at the next reset.
[0082] In this embodiment, after receiving the firmware activation instruction sent by the control device, the storage device will prepare for the activation of the new firmware by shutting down some of its own idle processes (such as wear balancing, garbage collection, etc.) to make itself idle. After that, the storage device will feedback through the standard protocol in the status field of the completion command queue in response to Firmware Active, indicating that the storage device will activate the new firmware at the next reset.
[0083] It should be noted that not all NVME storage drivers support this response method. Currently, only the Windows 10 built-in driver supports this handshake protocol. Drivers provided by other open source drivers (such as Marvel) do not support this method (when the storage device sets the corresponding activation method in the status field of the completion command queue, the control device cannot generate a reset behavior).
[0084] Step 43: Receive a reset instruction, clear the enable field of the controller configuration register to 0 to reset the storage device, and clear the ready field of the controller status register to 0.
[0085] After receiving the reset instruction sent by the control device, the storage device can clear the enable field of the controller configuration register to 0 to trigger a reset. At this time, the control device will suspend all command communications with the storage device; the storage device further clears the ready field of the controller status register to indicate whether the status of the memory is ready.
[0086] In this embodiment, since the control device suspends all command communications with the storage device after receiving the response message, the storage device is only capable of receiving the reset instruction at this time. The storage device can be reset directly in the online state under the instruction of the reset instruction without the need to re-perform the power-on and power-off reset action. The storage device can be upgraded without powering off, thereby ensuring the continuity of matter processing.
[0087] Among them, when the control device clears the CC.EN register of the storage device to 0 to trigger a reset of the storage device, the storage device needs to immediately clear the CSTS.RDY register to 0. Since the control device will quickly enable the CC.EN register and query the status of the CSTS.RDY register, if the CSTS.RDY register is not cleared to 0 in time, the storage device will not be fully prepared, but the control device will have started creating a new queue, which will ultimately lead to upgrade failure.
[0088] Step 44: Set the enable field of the controller configuration register to 1 to load the new firmware.
[0089] Among them, after the enable field of the controller configuration register of the storage device changes from 0 to 1, the storage device will generate an interrupt. Assuming that the interrupt occurs in the blind area of the new firmware loading (the blind area of the code reboot), that is, when the interrupt is not enabled, the storage device will be abnormal at this time. Based on this, the action of the storage device loading the new firmware in this embodiment, that is, the action of the reboot code, must be performed after the enable field of the controller configuration register is set to 1, otherwise it will affect the upgrade process.
[0090] Among them, the number of the above initialization operations is less than two times, that is, the initialization cannot be performed again. Specifically, the number of physical layer initializations of PCIE cannot exceed two times, otherwise the PCIE will be link down, that is, the link will be disconnected. Therefore, when the new firmware is loaded, during the initialization operation phase, the storage device must distinguish whether it is a reboot or a normal power-on, otherwise it will lead to a failure to communicate. For the method of distinguishing, some specific registers can be used to distinguish reboots. If there are no such registers, a special memory can be used for status identification to distinguish whether it is a normal power-on or a reboot.
[0091] Step 45: Set the ready field of the controller status register to 1, and establish a communication connection with the control device.
[0092] Among them, CSTS.RDY = 1 means that the new firmware of the storage device has been activated and the firmware upgrade has been completed. The query of the controller status register by the control device is usually intermittent. As long as the preparation field of the controller status register of the storage device is queried to change to 1, it can be confirmed that the storage device upgrade is completed. Further, the management command sent by the control device end is used to re-create the read-write communication queue to establish a communication connection with the control device end.
[0093] It should be noted that the time difference between the time when the storage device clears the preparation field of the controller status register to 0 and the time when the storage device sets the preparation field of the controller status register to 1 is less than the timeout time reported by the CAP (Controller Capabilities) register, that is, it cannot exceed CAP.TO (Controller Capabilities Timeout). When the control device queries the controller status register for too long, it will give up the query. At this time, it will be considered that the storage device has an abnormal disk drop.
[0094] In this way, the present embodiment provides a method for upgrading the firmware of a storage device. When the storage device receives the new firmware and the firmware activation instruction sent by the control device, the storage device informs the control device that the new firmware will be loaded after the next reset by responding to the corresponding status field of the firmware activation instruction. After that, the storage device and the control device shake hands again and create a new communication queue. This can solve the problem of needing to power off or force a jump in the previous storage device firmware upgrade.
[0095] See also Figure 5 , Figure 51 is a schematic diagram of the structure of an embodiment of a control device provided by the present application. The control device 50 of the present embodiment includes a control unit 51 and a storage unit 52. The control unit 51 is coupled to the storage unit 52. The storage unit 52 is used to store a computer program executed by the control unit 51. The control unit 51 is used to execute the computer program to implement the following method steps:
[0096] Send a firmware activation command to the storage device so that the storage device can prepare for activation, and after the preparation is completed, feedback response information to the control device, the response information is used to indicate that the storage device will activate the new firmware at the next reset; after receiving the response information, send a reset command to the storage device to reset the storage device; after the storage device firmware upgrade is completed, establish a communication connection with the storage device.
[0097] It should be noted that the control device 50 of this embodiment is a physical terminal based on any of the above method embodiments, and its implementation principles and steps are similar, which will not be repeated here. Therefore, when the computer program is executed by the control unit 51, it can also implement other method steps in any of the above embodiments, which will not be repeated here.
[0098] See also Figure 6 , Figure 6 1 is a schematic diagram of the structure of an embodiment of a storage device provided by the present application. The storage device 60 of the present embodiment includes a control unit 61 and a storage unit 62. The control unit 61 is coupled to the storage unit 62. The storage unit 62 is used to store a computer program executed by the control unit 61. The control unit 61 is used to execute the computer program to implement the following method steps:
[0099] Receive a firmware activation instruction to perform pre-activation preparations, and after the preparations are completed, feedback a response message to the control device, the response message being used to indicate that the storage device will activate the new firmware at the next reset; receive a reset instruction to reset the storage device; after the storage device firmware upgrade is completed, establish a communication connection with the control device.
[0100] It should be noted that the storage device 60 of this embodiment is a physical terminal based on any of the above method embodiments, and its implementation principles and steps are similar, which will not be repeated here. Therefore, when the computer program is executed by the control unit 61, it can also implement other method steps in any of the above embodiments, which will not be repeated here.
[0101] See also Figure 7 , Figure 7 1 is a schematic diagram of the structure of an embodiment of a computer-readable storage medium provided by the present application. The computer-readable storage medium 70 of the present embodiment is used to store a computer program 71. When the computer program 71 is executed by the control unit, it is used to implement the following method steps:
[0102] Send a firmware activation command to the storage device so that the storage device can prepare for activation, and after the preparation is completed, feedback response information to the control device, the response information is used to indicate that the storage device will activate the new firmware at the next reset; after receiving the response information, send a reset command to the storage device to reset the storage device; after the storage device firmware upgrade is completed, establish a communication connection with the storage device.
[0103] It should be noted that the method steps executed by the computer program 71 of this embodiment are based on the above method embodiments, and their implementation principles and steps are similar. Therefore, when the computer program 71 is executed by the control unit, it can also implement other method steps in any of the above embodiments, which will not be repeated here.
[0104] When the embodiments of the present application are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0105] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made according to the description and drawings of the present application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for upgrading firmware of a storage device, characterized in that: The method is applied to a control device, and the method comprises: Sending a firmware activation instruction to the storage device so that the storage device performs pre-activation preparation, and feeding back a response message to the control device after the preparation is completed, wherein the response message is used to indicate that the storage device will activate the new firmware at the next reset; After receiving the response information, suspend all command communications and only send a reset instruction to the storage device to reset the storage device, including: after receiving the response information, clear the enable field of the controller configuration register of the storage device to 0 to reset the storage device and clear the preparation field of the controller status register of the storage device to 0; wherein the response information is fed back in the status field of the completion command queue; set the enable field of the controller configuration register of the storage device to 1 to enable the storage device to load the new firmware; After the firmware upgrade of the storage device is completed, a communication connection with the storage device is established.
2. The method according to claim 1, characterized in that Before sending the firmware activation instruction to the storage device, the method further includes: The new firmware is sent to the storage device so that the storage device stores the new firmware.
3. The method according to claim 1, characterized in that After clearing the enable field of the controller configuration register of the storage device to 0 to reset the storage device and clearing the preparation field of the controller status register of the storage device to 0, the method further includes: Communications with the storage device are suspended.
4. The method according to claim 1, characterized in that: After the firmware upgrade of the storage device is completed, establishing a communication connection with the storage device includes: When detecting that the preparation field of the controller status register of the storage device is set to 1, establishing a communication connection with the storage device; wherein the storage device sets the preparation field of the controller status register of the storage device to 1 after the new firmware initialization operation is completed.
5. The method according to claim 4, characterized in that The establishing of a communication connection with the storage device comprises: Send a management command to recreate the read-write communication queue and establish a communication connection with the storage device.
6. The method according to claim 4, characterized in that The number of the initialization operations is less than two times.
7. A control device, characterized in that: It comprises a control unit and a storage unit, wherein the storage unit is used to store a computer program, and when the computer program is executed by the control unit, it is used to implement the firmware upgrade method of the storage device according to any one of claims 1 to 6.
8. A method for upgrading firmware of a storage device, characterized in that: The method is applied to a storage device, and the method comprises: receiving a firmware activation instruction to perform pre-activation preparation, and feeding back a response message to the control device after the preparation is completed, wherein the response message is used to indicate that the storage device will activate the new firmware at the next reset; Receiving a reset instruction to reset the storage device, including: receiving the reset instruction, clearing the enable field of the controller configuration register to 0 to reset the storage device, and clearing the preparation field of the controller status register to 0; setting the enable field of the controller configuration register to 1 to load the new firmware; After the firmware upgrade of the storage device is completed, a communication connection with the control device is established.
9. The method according to claim 8, characterized in that Before receiving the firmware activation instruction, the method further includes: The new firmware is received and stored.
10. The method according to claim 8, characterized in that After the firmware upgrade of the storage device is completed, establishing a communication connection with the control device includes: The preparation field of the controller status register is set to 1, and a communication connection with the control device is established; wherein the storage device sets the preparation field of the controller status register to 1 after the new firmware initialization operation is completed.
11. The method according to claim 10, characterized in that The time difference between clearing the ready field of the controller status register to 0 and setting the ready field of the controller status register to 1 is less than the timeout time reported by the controller function register.
12. The method according to claim 8, characterized in that The response information is fed back in the status field of the completion queue command.
13. A storage device, characterized in that: It comprises a control unit and a storage unit, wherein the storage unit is used to store a computer program, and when the computer program is executed by the control unit, it is used to implement the firmware upgrade method of the storage device according to any one of claims 8 to 12.
Citation Information
Patent Citations
Online firmware upgrading method and system
CN108170368A