A method, device, electronic device and storage medium for updating hard disk firmware
By traversing the storage area header file in the target slot to determine and write the target firmware, the problem of long firmware upgrade time and interruption is solved, and the efficiency of firmware update and system reliability are improved.
Patent Information
- Application Number
- CN202111144007.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-09-28
AI Technical Summary
The firmware upgrade process is time-consuming and easily interrupted, causing the system to fail to start normally. Especially when there are multiple firmware versions, the bootloader needs to check and find the latest valid firmware one by one, which takes a lot of time.
Provides a hard disk firmware update method, by receiving the firmware update instruction sent by the host device, traversing the storage area header file in the target slot, determining the target storage area that meets the preset writing conditions, and writing the target firmware into the area. Optimize the firmware update process and improve efficiency.
Quickly determine and write the target storage area, reducing firmware update time, avoiding the need to check each storage area one by one when the system starts, and improving firmware update efficiency and system reliability.
Smart Images

Figure CN114020306B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for updating hard disk firmware. Background Art
[0002] SSD firmware is usually stored in eeprom or flash and can be upgraded by a specific refresh program. When the SSD system starts, the processor's firmware loads the boot loader, which initializes the hardware and then loads the firmware. If there is a problem with the current firmware program, the system cannot start normally and the disk is lost.
[0003] Different manufacturers have different management methods for firmware management, such as saving only the latest version of firmware and saving multiple versions of firmware. For the former, if there is a problem when upgrading the firmware, the SSD will not work properly. For the latter, when upgrading the firmware, you need to select a correct location to replace the original firmware to ensure that the latest valid firmware can be found when the system starts.
[0004] Regardless of the method, when upgrading, you first need to erase a space and then write the new firmware. This process may take a long time, and once it is interrupted abnormally, it will not start normally the next time it is powered on. When starting, you need to find the latest valid firmware from eprom or flash and load it. If there are multiple versions of firmware, the bootloader needs to verify the validity of each firmware and find the last upgraded firmware. The whole process is time-consuming. Summary of the invention
[0005] In order to solve the above technical problem or at least partially solve the above technical problem, the present application provides a hard disk firmware update method, device, electronic device and storage medium.
[0006] According to one aspect of an embodiment of the present application, a method for updating hard disk firmware is provided, which is applied to a solid state drive, and the method includes:
[0007] Receiving a firmware update instruction sent by a host device, wherein the firmware update instruction carries a target firmware;
[0008] Querying a target slot corresponding to the target firmware from the solid state drive, wherein the target slot includes a plurality of storage areas;
[0009] Traversing the header files corresponding to the storage areas in the target slot, determining the target storage area that meets the preset writing condition, and writing the target firmware into the target storage area to obtain an updated target slot;
[0010] After the solid state drive is powered on, the target firmware is run based on the updated target slot.
[0011] Further, traversing the header file corresponding to the storage area in the target slot, determining the target storage area that meets the preset writing condition, and writing the target firmware into the target storage area includes:
[0012] Traversing the storage area in the target slot to determine first state information of the storage area;
[0013] Determine the storage area whose first state information is an idle state as a target storage area that meets a preset writing condition;
[0014] Query the header files corresponding to each storage area to determine the historical maximum version number corresponding to the target firmware;
[0015] Determine the current maximum version number of the header file corresponding to the target storage area according to the historical maximum version number;
[0016] The target firmware is written into the target storage area, and the current maximum version number is stored in a header file corresponding to the target storage area.
[0017] Furthermore, in the case that there is no storage area in the target slot whose first state information is in an idle state, the method further includes:
[0018] Query the header files corresponding to each storage area to determine the historical maximum version number and the historical minimum version number corresponding to the target firmware;
[0019] Determine the current maximum version number of the header file corresponding to the target storage area according to the historical maximum version number;
[0020] Erasing the firmware stored in the storage area corresponding to the historical minimum version number, and determining the storage area after the firmware is erased as a target storage area that meets a preset write condition;
[0021] The target firmware is written into the target storage area, and the current maximum version number is stored in a header file corresponding to the target storage area.
[0022] Furthermore, after writing the target firmware into the target storage area and storing the current maximum version number into a header file corresponding to the target storage area, the method further includes:
[0023] Obtaining verification data corresponding to the target firmware;
[0024] The verification data is written into the header file and used as the file type code of the header file.
[0025] Further, after the solid state drive is powered on, the target firmware is loaded and run based on the updated target slot, including:
[0026] Receive power-on start command;
[0027] After the solid state drive is started according to the power-on startup instruction, the header files corresponding to each storage area in the updated target slot are queried to obtain the current maximum version number and verification data corresponding to the target firmware;
[0028] In the case where the verification data passes the verification, determining the current maximum version number as the valid maximum version number;
[0029] The target firmware is controlled to run according to the maximum effective version number.
[0030] Furthermore, after the solid state hard disk is powered on, the method further includes:
[0031] Querying the header files corresponding to each storage area to obtain the historical firmware that is not completely written into the storage area;
[0032] Continue to execute the writing operation of the historical firmware.
[0033] Further, after the target firmware is loaded and executed based on the updated target slot, the method further includes:
[0034] After the solid state hard disk is powered on, traversing the updated second state information of each storage area in the target slot;
[0035] In the case that there is no storage area whose second state information is in an idle state in the updated target slot, querying the header files corresponding to each storage area to determine the current minimum version number of the target firmware;
[0036] The firmware stored in the storage area corresponding to the current minimum version number is erased.
[0037] According to another aspect of the embodiment of the present application, there is also provided a hard disk firmware update device, including:
[0038] A receiving module, configured to receive a firmware update instruction sent by a host device, wherein the firmware update instruction carries a target firmware;
[0039] A query module, used for querying a target slot corresponding to the target firmware from the solid state drive, wherein the target slot includes a plurality of storage areas;
[0040] A traversal module, used for traversing the header file corresponding to the storage area in the target slot, determining the target storage area that meets the preset writing condition, and writing the target firmware into the target storage area to obtain an updated target slot;
[0041] An execution module is used to run the target firmware based on the updated target slot after the solid state drive is powered on.
[0042] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above steps are executed when the program is run.
[0043] According to another aspect of an embodiment of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the program stored in the memory.
[0044] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps in the above method.
[0045] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art: the embodiment of the present application can quickly determine whether the target storage area meets the writing conditions by traversing the header file corresponding to the storage area in the target slot, and directly write the target firmware into the target storage area. There is no need to check each storage area one by one, thereby improving the efficiency of firmware update. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0047] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0048] Figure 1 A flowchart of a hard disk firmware update method provided in an embodiment of the present application;
[0049] Figure 2 A flowchart of a hard disk firmware update method provided by another embodiment of the present application;
[0050] Figure 3A flowchart of a hard disk firmware update method provided by another embodiment of the present application;
[0051] Figure 4 A block diagram of a hard disk firmware update device provided in an embodiment of the present application;
[0052] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme 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. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0054] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another similar entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0055] The embodiments of the present application provide a method, device, electronic device and storage medium for updating hard disk firmware. The method provided by the embodiments of the present invention can be applied to any required electronic device, for example, it can be a server, terminal and other electronic devices, which are not specifically limited here. For the convenience of description, they are referred to as electronic devices in the following.
[0056] According to one aspect of the embodiments of the present application, a method embodiment of a method for updating hard disk firmware is provided. Figure 1 A flowchart of a method for updating hard disk firmware provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes:
[0057] Step S11, receiving a firmware update instruction sent by a host device, wherein the firmware update instruction carries a target firmware.
[0058] In an embodiment of the present application, the host device will determine the firmware that needs to be updated in the solid-state drive according to the configuration of the device. The firmware is also called FIRMWARE, which is stored in the EEPROM (electrically erasable programmable storage non-read-only chip) chip in the device and can be upgraded by the user through a specific refresh program. Its function is equivalent to the BIOS of the motherboard, which is written in assembly language. After the host device determines the firmware to be updated, it will send a firmware update instruction to the solid-state drive. The firmware update instruction carries the target firmware and the storage slot identifier (and slot number) of the target firmware in the solid-state drive.
[0059] In an embodiment of the present application, after obtaining the target firmware sent by the host device, the solid-state hard disk detects the validity of the target firmware, and if the target firmware is valid, performs a corresponding write operation on the target firmware.
[0060] Step S12, querying a target slot corresponding to the target firmware from the solid state drive, wherein the target slot includes a plurality of storage areas.
[0061] In an embodiment of the present application, a plurality of slots are provided in a solid-state hard disk, each slot is used to store the same type of firmware, and each slot includes a plurality of storage areas, and the storage areas are used to store firmware with different version numbers. It should be noted that, except for the factory firmware written into the first storage area, other storage areas are all erased and empty by default when not upgraded. When data is written therein, a fixed-length header file is written at the front by default. The header file contains the version number and the integrity verification data of the firmware. When the firmware is written, the version number is first written into the header file, and the integrity verification data of the data is written into the magic number. After all the firmware is written, the magic number is replaced with the real integrity verification data.
[0062] In an embodiment of the present application, the process of querying the target slot corresponding to the target firmware from the solid-state hard disk is as follows: the corresponding target slot is obtained from the solid-state hard disk according to the storage slot identifier issued by the host device, and the target slot includes multiple storage areas, each storage area stores historical firmware of the same type as the target firmware, and each historical firmware corresponds to a historical version number.
[0063] Step S13, traverse the header files corresponding to the storage areas in the target slot, determine the target storage area that meets the preset writing condition, and write the target firmware into the target storage area to obtain an updated target slot.
[0064] In an embodiment of the present application, traversing the header file corresponding to the storage area in the target slot, determining the target storage area that meets the preset write condition, and writing the target firmware into the target storage area include the following steps A1-A5:
[0065] Step A1, traverse the storage area in the target slot to determine the first state information of the storage area.
[0066] Step A2: determining a storage area whose first status information is an idle state as a target storage area that meets a preset writing condition.
[0067] Step A3, querying the header files corresponding to each storage area to determine the historical maximum version number corresponding to the target firmware.
[0068] Step A4, determining the current maximum version number of the header file corresponding to the target storage area according to the historical maximum version number.
[0069] Step A5, writing the target firmware into the target storage area, and storing the current maximum version number into the header file corresponding to the target storage area.
[0070] In an embodiment of the present application, after determining the target slot corresponding to the target firmware, the first status information of each storage area in the target slot is traversed, wherein the first status information may be a storage status and an idle status. When the first status information is a storage status, it indicates that the firmware has been written into the storage area; when the first status information is an idle status, it indicates that the firmware has not been written into the storage area.
[0071] In the embodiment of the present application, a storage area in the target slot whose first state information is an idle state is obtained, and the storage area in the target slot whose first state information is an idle state is determined as a target storage area that meets the preset write condition. If there are multiple idle storage areas in the target slot, the target firmware is randomly written to a storage area in an idle state.
[0072] In the embodiment of the present application, before writing the target firmware into the target storage area, it is also necessary to determine the target version number corresponding to the target firmware. The specific process is: query the header file corresponding to each storage area, determine the historical maximum version number N corresponding to the target firmware, and determine N+1 as the current maximum version number. Then write the current maximum version number into the header file, and write the target firmware into the target storage area. After the target firmware is written, the updated target slot is obtained.
[0073] In the embodiment of the present application, when there is no storage area whose first state information is an idle state in the target slot, the method further includes the following steps B1-B4:
[0074] Step B1, querying the header files corresponding to each storage area to determine the historical maximum version number and the historical minimum version number corresponding to the target firmware.
[0075] Step B2, determining the current maximum version number of the header file corresponding to the target storage area according to the historical maximum version number.
[0076] Step B3, erasing the firmware stored in the storage area corresponding to the historical minimum version number, and determining the storage area after the firmware is erased as the target storage area that meets the preset writing condition.
[0077] Step B4, write the target firmware into the target storage area, and store the current maximum version number into the header file corresponding to the target storage area.
[0078] In an embodiment of the present application, if there is no storage area in the target slot whose first state information is an idle state, it is determined that all storage areas in the target slot have been written with firmware. At this time, the header files corresponding to each storage area are queried to determine the historical maximum version number and the historical minimum version number corresponding to the target firmware. Then, the firmware in the storage area corresponding to the historical minimum version number is erased to make the storage area corresponding to the historical minimum version number idle. Then, the current maximum version number is determined based on the historical maximum version number, the current maximum version number is written into the header file of the storage area corresponding to the historical minimum version number, and the target firmware is written into the storage area corresponding to the historical minimum version number (i.e., the target storage area).
[0079] In an embodiment of the present application, after writing the target firmware into the target storage area and storing the current maximum version number in the header file corresponding to the target storage area, the method also includes: obtaining verification data corresponding to the target firmware, writing the verification data into the header file, and using it as the file type code of the header file.
[0080] The embodiment of the present application uses the verification data as the file type code of the header file, so as to perform verification according to the file type code when the target firmware is loaded and run.
[0081] Step S14, after the solid state drive is powered on, the target firmware is run based on the updated target slot.
[0082] In the embodiment of the present application, step S14, after the solid state drive is powered on and started, the target firmware is loaded and run based on the updated target slot, including the following steps C1-C4:
[0083] Step C1, receiving a power-on start instruction.
[0084] Step C2, after completing the startup of the solid state hard disk according to the power-on startup instruction, query the header files corresponding to each storage area in the updated target slot to obtain the current maximum version number and verification data corresponding to the target firmware.
[0085] Step C3: when the verification data passes the verification, the current maximum version number is determined as the valid maximum version number.
[0086] Step C4, controlling the target firmware to run according to the maximum valid version number.
[0087] In the embodiment of the present application, after the solid-state drive is powered on, it will read the target slot, then query the header file corresponding to each storage area in the target slot, read the current maximum version number M, and perform data integrity check according to the file type code. If the check passes, the firmware validity will continue to be checked. If it is valid, the firmware will be loaded to control the target firmware to run according to the valid maximum version number.
[0088] Otherwise, read the header file with version number M-1 and continue the above operation. If it still fails, continue to search for the header file with version number M-2 and repeat the above operation until a valid firmware is found. By checking the version and data integrity of the header files corresponding to each storage area, the latest version number can be searched first, and the validity of each firmware does not need to be rechecked every time, which saves loading time.
[0089] The embodiment of the present application can quickly determine whether the target storage area meets the write conditions by traversing the header file corresponding to the storage area in the target slot, and directly write the target firmware into the target storage area. There is no need to check each storage area one by one, thereby improving the efficiency of firmware update.
[0090] In the embodiment of the present application, after the solid state drive is powered on, Figure 2 As shown, the method also includes the following steps:
[0091] Step S21, querying the header files corresponding to each storage area to obtain the historical firmware that is not completely written into the storage area.
[0092] Step S22, continue to execute the writing operation of the historical firmware.
[0093] In the embodiment of the present application, during the firmware upgrade process, abnormal events such as power failures may occur, resulting in firmware upgrade failures, or firmware incomplete writing. Because the header file in the storage area exists, after the solid-state drive is powered on again, it can quickly scan and identify the historical firmware that was not written correctly, and determine a newest version number (the largest version number) that is normally used by the historical firmware to temporarily run, while continuing to execute the writing operation of the historical firmware.
[0094] By writing the version number into the header file corresponding to the storage area, the embodiment of the present application can quickly locate the latest version number that can be used normally when a sudden abnormal event causes the firmware to be incompletely written, and use the latest version of the firmware for temporary operation while continuing to execute the writing operation of the historical firmware.
[0095] In the embodiment of the present application, after the target firmware is loaded and run based on the updated target slot, as shown in FIG. Figure 3 As shown, the method also includes:
[0096] Step S31, after the solid state hard disk is powered on, traverse the updated second state information of each storage area in the target slot.
[0097] Step S32: when there is no storage area whose second status information is an idle state in the updated target slot, query the header files corresponding to each storage area to determine the current minimum version number of the target firmware.
[0098] Step S33, erasing the firmware stored in the storage area corresponding to the current minimum version number.
[0099] In the embodiment of the present application, after the SSD is powered on and running, it is queried whether the storage areas of the updated target slots in the SSD have all been written with header files. If all have been written with header files, the header files corresponding to the respective storage areas are queried to determine the current minimum version number of the target firmware, and the firmware stored in the storage area corresponding to the current minimum version number is erased.
[0100] The embodiment of the present application performs a pre-erase judgment after each power-on operation of the solid-state hard disk, and pre-erases an unused old version of the firmware, so that when the host device sends a firmware update instruction again, the firmware can be written directly because the space in the storage area has been cleared by the pre-erase, saving writing time.
[0101] Figure 4 This is a block diagram of a hard disk firmware update device provided in an embodiment of the present application. The device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 4 As shown, the device comprises:
[0102] The receiving module 41 is used to receive a firmware update instruction sent by a host device, wherein the firmware update instruction carries a target firmware.
[0103] The query module 42 is used to query the target slot corresponding to the target firmware from the solid state drive, wherein the target slot includes multiple storage areas.
[0104] The traversal module 43 is used to traverse the header files corresponding to the storage areas in the target slot, determine the target storage area that meets the preset writing condition, and write the target firmware into the target storage area to obtain the updated target slot.
[0105] The execution module 44 is used to run the target firmware based on the updated target slot after the solid state drive is powered on.
[0106] In an embodiment of the present application, the traversal module 43 is used to traverse the storage area in the target slot and determine the first state information of the storage area; determine the storage area whose first state information is an idle state as the target storage area that meets the preset write condition; query the header file corresponding to each storage area to determine the historical maximum version number corresponding to the target firmware; determine the current maximum version number stored in the header file corresponding to the target storage area based on the historical maximum version number; write the target firmware to the target storage area, and store the current maximum version number in the header file corresponding to the target storage area.
[0107] In an embodiment of the present application, the hard disk firmware update device also includes: a processing module, which is used to query the header files corresponding to each storage area, determine the historical maximum version number and the historical minimum version number corresponding to the target firmware; determine the current maximum version number stored in the header file corresponding to the target storage area according to the historical maximum version number; erase the firmware stored in the storage area corresponding to the historical minimum version number, and determine the storage area after the firmware is erased as the target storage area that meets the preset writing conditions; write the target firmware to the target storage area, and store the current maximum version number in the header file corresponding to the target storage area.
[0108] In an embodiment of the present application, the hard disk firmware update device also includes: a storage module, used to obtain verification data corresponding to the target firmware; write the verification data into a header file and use it as a file type code of the header file.
[0109] In an embodiment of the present application, an execution module 44 is used to receive a power-on startup instruction; after completing the startup of the solid-state hard disk according to the power-on startup instruction, query the header files corresponding to each storage area in the updated target slot to obtain the current maximum version number and verification data corresponding to the target firmware; if the verification data is verified, the current maximum version number is determined as the effective maximum version number; and the target firmware is controlled to run according to the effective maximum version number.
[0110] In an embodiment of the present application, the hard disk firmware update device also includes: a detection module, which is used to query the header files corresponding to each storage area to obtain the historical firmware that is not completely written into the storage area; and continue to execute the writing operation of the historical firmware.
[0111] In an embodiment of the present application, the hard disk firmware update device also includes: a troubleshooting module, which is used to traverse the second state information of each storage area in the updated target slot after the solid-state hard disk is powered on; if there is no storage area with the second state information being an idle state in the updated target slot, query the header file corresponding to each storage area to determine the current minimum version number of the target firmware; and erase the firmware stored in the storage area corresponding to the current minimum version number.
[0112] The present application also provides an electronic device, such as Figure 5 As shown, the electronic device may include: a processor 1501 , a communication interface 1502 , a memory 1503 and a communication bus 1504 , wherein the processor 1501 , the communication interface 1502 , and the memory 1503 communicate with each other via the communication bus 1504 .
[0113] Memory 1503, used for storing computer programs;
[0114] The processor 1501 is used to implement the steps of the above embodiment when executing the computer program stored in the memory 1503.
[0115] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0116] The communication interface is used for communication between the above terminal and other devices.
[0117] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0118] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0119] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is executed on a computer, the computer executes the hard disk firmware update method described in any of the above embodiments.
[0120] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the hard disk firmware updating method described in any one of the above embodiments.
[0121] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk SolidState Disk), etc.
[0122] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
[0123] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A method for updating hard disk firmware, It is characterized in that Applied to a solid state drive, the method comprises: Receiving a firmware update instruction sent by a host device, wherein the firmware update instruction carries a target firmware; Querying a target slot corresponding to the target firmware from the solid state drive, wherein the target slot includes a plurality of storage areas; Traversing the header files corresponding to the storage areas in the target slot, determining the target storage area that meets the preset writing condition, and writing the target firmware into the target storage area to obtain an updated target slot; After the solid state drive is powered on, running the target firmware based on the updated target slot; The traversing of the header file corresponding to the storage area in the target slot, determining the target storage area that meets the preset writing condition, and writing the target firmware into the target storage area, comprises: traversing the storage area in the target slot, determining the first state information of the storage area; determining the storage area whose first state information is an idle state as the target storage area that meets the preset writing condition; querying the header file corresponding to each storage area, determining the historical maximum version number corresponding to the target firmware; determining the current maximum version number stored in the header file corresponding to the target storage area according to the historical maximum version number; writing the target firmware into the target storage area, and storing the current maximum version number into the header file corresponding to the target storage area; after writing the target firmware into the target storage area, and storing the current maximum version number into the header file corresponding to the target storage area, the method further comprises: obtaining verification data corresponding to the target firmware; writing the verification data into the header file, and using the verification data as the file type code of the header file; In the case that there is no storage area in the target slot whose first state information is in an idle state, the method further includes: Query the header files corresponding to each storage area to determine the historical maximum version number and the historical minimum version number corresponding to the target firmware; determine the current maximum version number stored in the header file corresponding to the target storage area according to the historical maximum version number; erase the firmware stored in the storage area corresponding to the historical minimum version number, and determine the storage area after the firmware is erased as the target storage area that meets the preset writing condition; write the target firmware into the target storage area, and store the current maximum version number in the header file corresponding to the target storage area; After the solid state drive is powered on and started, the target firmware is loaded and run based on the updated target slot, including: Receive a power-on startup instruction; after completing the startup of the solid-state hard disk according to the power-on startup instruction, query the header files corresponding to each storage area in the updated target slot to obtain the current maximum version number and verification data corresponding to the target firmware; if the verification data is verified, determine the current maximum version number as the valid maximum version number; control the target firmware to run according to the valid maximum version number; after the solid-state hard disk is powered on, the method also includes: if an abnormal event occurs that causes the firmware upgrade to fail, or the firmware is not completely written, query the header files corresponding to each storage area to obtain the historical firmware that is not completely written to the storage area; continue to execute the writing operation of the historical firmware; After loading and running the target firmware based on the updated target slot, the method further includes: After the solid-state hard disk is powered on, the second state information of each storage area in the updated target slot is traversed; if there is no storage area in the updated target slot whose second state information is in an idle state, the header files corresponding to each storage area are queried to determine the current minimum version number of the target firmware; and the firmware stored in the storage area corresponding to the current minimum version number is erased.
2. A hard disk firmware update device, It is characterized in that include: A receiving module, configured to receive a firmware update instruction sent by a host device, wherein the firmware update instruction carries a target firmware; A query module, used for querying a target slot corresponding to the target firmware from the solid state drive, wherein the target slot includes a plurality of storage areas; A traversal module, used for traversing the header file corresponding to the storage area in the target slot, determining the target storage area that meets the preset writing condition, and writing the target firmware into the target storage area to obtain an updated target slot; An execution module, configured to run the target firmware based on the updated target slot after the solid state drive is powered on; The traversal module is used to traverse the storage area in the target slot to determine the first state information of the storage area; determine the storage area whose first state information is an idle state as the target storage area that meets the preset writing condition; query the header file corresponding to each storage area to determine the historical maximum version number corresponding to the target firmware; determine the current maximum version number stored in the header file corresponding to the target storage area according to the historical maximum version number; write the target firmware into the target storage area, and store the current maximum version number in the header file corresponding to the target storage area; The device also includes: a processing module, which is used to query the header files corresponding to each storage area, determine the historical maximum version number and the historical minimum version number corresponding to the target firmware; determine the current maximum version number stored in the header file corresponding to the target storage area according to the historical maximum version number; erase the firmware stored in the storage area corresponding to the historical minimum version number, and determine the storage area after the firmware is erased as the target storage area that meets the preset writing condition; write the target firmware into the target storage area, and store the current maximum version number into the header file corresponding to the target storage area; The execution module is used to receive a power-on startup instruction; after completing the startup of the solid-state hard disk according to the power-on startup instruction, query the header files corresponding to each storage area in the updated target slot to obtain the current maximum version number and verification data corresponding to the target firmware; if the verification data is verified, determine the current maximum version number as the effective maximum version number; control the target firmware to run according to the effective maximum version number; The hard disk firmware update device also includes: a storage module, which is used to obtain the verification data corresponding to the target firmware; write the verification data into the header file and use it as the file type code of the header file; The hard disk firmware update device also includes: a detection module, which is used to query the header files corresponding to each storage area, obtain the historical firmware that is not completely written into the storage area; and continue to execute the writing operation of the historical firmware; The hard disk firmware update device also includes: a troubleshooting module, which is used to traverse the second state information of each storage area in the updated target slot after the solid-state hard disk is powered on; if there is no storage area with the second state information being an idle state in the updated target slot, query the header file corresponding to each storage area to determine the current minimum version number of the target firmware; and erase the firmware stored in the storage area corresponding to the current minimum version number.
3. A storage medium, It is characterized in that The storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 2 when executed.
4. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; wherein: Memory, used to store computer programs; A processor, configured to execute the method according to any one of claims 1 to 3 by running a program stored in a memory.
