CN118093028A - Firmware loading method, system and device of basic input/output system - Google Patents

Firmware loading method, system and device of basic input/output system Download PDF

Info

Publication number
CN118093028A
CN118093028A CN202311839874.1A CN202311839874A CN118093028A CN 118093028 A CN118093028 A CN 118093028A CN 202311839874 A CN202311839874 A CN 202311839874A CN 118093028 A CN118093028 A CN 118093028A
Authority
CN
China
Prior art keywords
check code
firmware
firmware volume
header
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311839874.1A
Other languages
Chinese (zh)
Inventor
邓朝阳
朱英澍
王安平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Metabrain Intelligent Technology Co Ltd
Original Assignee
Suzhou Metabrain Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Metabrain Intelligent Technology Co Ltd filed Critical Suzhou Metabrain Intelligent Technology Co Ltd
Priority to CN202311839874.1A priority Critical patent/CN118093028A/en
Publication of CN118093028A publication Critical patent/CN118093028A/en
Pending legal-status Critical Current

Links

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The invention relates to the technical field of computers, and discloses a firmware loading method, a system and a device of a basic input/output system, wherein the method comprises the following steps: after receiving a firmware loading instruction, acquiring a firmware volume header from a target flash memory chip; if the firmware volume header is empty, creating a new firmware volume header, and backing up the firmware volume of the basic input/output system according to the new firmware volume header; if the firmware volume header is not empty, judging whether the mark of the firmware volume header is a preset mark; if yes, obtaining a first current check code according to the firmware volume, obtaining a second current check code according to the table head of the firmware volume, and obtaining a first target check code and a second target check code; and if the first current check code is the same as the first target check code and the second current check code is the same as the second target check code, loading the firmware. The method solves the problem that under the condition that only one flash memory chip is used for backing up the firmware of the basic input/output system, the firmware cannot be subjected to integrity check and is loaded smoothly.

Description

Firmware loading method, system and device of basic input/output system
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, a system, and an apparatus for loading firmware of a basic input/output system.
Background
BIOS (Basic Input Output System) is a section of code stored in a Flash memory chip (Flash chip) of a main board, is also a program which is operated first when a computer system is started, is mainly responsible for the work such as the initialization of various hardware equipment resources in the chip set and the computer system, and is finally responsible for the loading and starting of an operating system. The BIOS Firmware is stored in the Flash chip in the form of a plurality of Firmware Volumes (FV), and if any one of the Firmware volumes stored in the Flash chip is damaged, it may cause the computer system to be unable to be started. Computer products such as a server generally have higher requirements on the integrity of BIOS firmware, require a computer system to provide a stable and reliable firmware data verification and recovery mechanism in the process of loading BIOS, and actively complete fault repair under the condition that the BIOS firmware is destroyed, ensure that the startup of the system is not affected, and reduce business and economic losses.
Currently, 2 Flash chips are usually used to store BIOS firmware, one storing main BIOS firmware (Master BIOS), and the other storing Slave BIOS firmware (Slave BIOS) as a backup of the main BIOS firmware. And detecting whether the main BIOS firmware is started successfully or not through a certain time period, and if the main BIOS firmware is not started successfully in the detection period, triggering overtime processing logic of the watchdog, switching a system link to a 2 nd Flash chip, and loading the auxiliary BIOS firmware to ensure normal loading of the system. However, this solution has certain drawbacks: on one hand, the scheme needs to rely on two Flash chips, so that the production cost is increased to a certain extent; on the other hand, when recovering data, an external ROM (Read-Only Memory) component storing original BIOS firmware is required to be inserted, and the data recovery operation is completed by loading the original BIOS firmware in the ROM component, so that the labor cost and the later equipment maintenance cost are increased.
Therefore, the related art has the problem that the firmware of the basic input/output system cannot be checked for integrity and loaded smoothly under the condition that only one flash memory chip is used for backing up the firmware of the basic input/output system.
Disclosure of Invention
In view of this, the present invention provides a method, a system and a device for loading firmware of a bios, so as to solve the problem that in the related art, when firmware of the bios is backed up by only one flash memory chip, the firmware of the bios cannot be checked for integrity and loaded smoothly.
In a first aspect, the present invention provides a firmware loading method of a basic input/output system, where the method includes:
under the condition of receiving a firmware loading instruction, acquiring a firmware volume header from a target flash memory chip, wherein the firmware loading instruction is used for indicating loading of firmware of a basic input/output system;
Under the condition that the firmware volume header is empty, creating a new firmware volume header, and backing up a firmware volume of the basic input output system according to the new firmware volume header, wherein the firmware volume contains codes of firmware;
judging whether a mark of the firmware volume header is a preset mark or not under the condition that the firmware volume header is not empty;
If the first target check code is the preset mark, a first current check code is obtained according to the firmware volume, a second current check code is obtained according to the firmware volume header, and a first target check code of the firmware volume and a second target check code of the firmware volume header are obtained from the firmware volume header;
and loading the firmware under the condition that the first current check code is the same as the first target check code and the second current check code is the same as the second target check code.
According to the firmware loading method of the basic input and output system, the firmware volume is actively backed up by creating the new firmware volume header, so that the firmware volume is convenient to repair subsequently, the labor input is reduced, and the maintenance cost of equipment is reduced. The backup of BIOS firmware is realized by using a single flash memory chip, and the production cost is saved. The current check code of the firmware is calculated before loading the firmware and is compared with the target check code recorded in the firmware volume header, the data integrity of the firmware is checked, and after the data integrity check is passed, the firmware is loaded again, so that the reliability of the machine is improved, the customer experience is optimized, and the smooth operation of each system startup is ensured. The method solves the problem that the firmware of the basic input/output system cannot be subjected to integrity check and smoothly loaded under the condition that only one flash memory chip is used for backing up the firmware of the basic input/output system.
In an alternative embodiment, in a case that the firmware volume header is empty, creating a new firmware volume header, and backing up the firmware volume of the basic input output system according to the new firmware volume header, including:
under the condition that the firmware volume header is empty, a new firmware volume header is created, and a preset mark is obtained;
Filling a preset mark into a first interval of the new firmware volume header to obtain a first intermediate firmware volume header;
Acquiring all firmware volumes, first offset addresses and first lengths of the firmware volumes, and obtaining a first target check code of the firmware volumes according to the firmware volumes, wherein the first offset addresses and the first lengths are used for positioning the firmware volumes, and the first target check code is used for determining whether the firmware volumes are complete or not;
filling the first offset address, the first length and the first target check code into a second section of the first intermediate firmware volume header to obtain a second intermediate firmware volume header;
acquiring a second offset address and a second length of the second intermediate firmware volume header, wherein the second offset address and the second length are used for positioning the second intermediate firmware volume header;
Determining a third offset address and a fourth offset address in the target flash memory chip, wherein the third offset address is used for backing up the second intermediate firmware volume table head, and the fourth offset address is used for backing up the firmware volume;
Filling the second offset address, the second length, the third offset address and the fourth offset address into a third section of the second intermediate firmware volume header to obtain a third intermediate firmware volume header;
Obtaining a second target check code of the third intermediate firmware volume header according to the third intermediate firmware volume header, and filling the second target check code into a fourth interval of the third intermediate firmware volume header to obtain the firmware volume header, wherein the second target check code is used for determining whether the firmware volume header is complete;
and in the target flash memory chip, backing up the firmware volume table head and all the firmware volumes.
In this embodiment, a new firmware volume header is created, and firmware volumes of the bios are backed up according to the new firmware volume header, and an offset address and a length of each firmware volume, an offset address of a backup firmware volume, an offset address and a length of the firmware volume header, and an offset address of the backup firmware volume header are recorded in the firmware volume header, so that positioning is facilitated. And the firmware volume header and the target verification of the firmware volume are recorded in the firmware volume header, so that the data integrity verification can be conveniently carried out subsequently.
In an alternative embodiment, after obtaining the first current check code according to the firmware volume, obtaining the second current check code according to the firmware volume header, and obtaining the first target check code of the firmware volume and the second target check code of the firmware volume header from the firmware volume header, the method further includes:
Judging whether the second current check code is the same as the second target check code or not;
Judging whether the first current check code is the same as the first target check code or not under the condition that the second current check code is the same as the second target check code;
If the first current check code is different from the first target check code, determining a first firmware volume to be repaired according to the first current check code and the first target check code, acquiring a backup firmware volume from a target flash memory chip, repairing the first firmware volume to be repaired by using the backup firmware volume, and loading firmware;
Under the condition that the second current check code is different from the second target check code, acquiring a backup firmware volume header from the target flash memory chip, and repairing the firmware volume header by using the backup firmware volume header;
Judging whether the first current check code is the same as the first target check code or not, if the first current check code is different from the first target check code, determining a first firmware volume to be repaired according to the first current check code and the first target check code, repairing the first firmware volume to be repaired by using the backup firmware volume, and loading the firmware;
if the first current check code is the same as the first target check code, the firmware is directly loaded.
In the embodiment, in the data integrity verification process, if the data of the firmware volume header is incomplete, the backup firmware volume header is utilized to repair, and if the data of the firmware volume is incomplete, the corresponding backup firmware volume is utilized to repair, so that the timely detection and repair of faults are realized, and the reliability of the computer is improved.
In an alternative embodiment, the method further comprises:
obtaining a third offset address and a fourth offset address according to the firmware volume header;
in the target flash memory chip, a backup firmware volume table head is obtained according to the third offset address, and a backup firmware volume is obtained according to the fourth offset address;
Obtaining a third current check code according to the backup firmware volume and obtaining a fourth current check code according to the backup firmware volume header, wherein the third current check code is used for determining whether the backup firmware volume is complete, and the fourth current check code is used for determining whether the backup firmware volume header is complete;
and judging whether the firmware can be loaded according to the first current check code, the second current check code, the third current check code, the fourth current check code, the first target check code and the second target check code.
In this embodiment, the third current check code of the backup firmware volume and the fourth current check code of the backup firmware volume header are calculated, so that when the data integrity of the BIOS firmware is checked later, the data integrity of the backup firmware volume and the backup firmware volume header are checked at the same time.
In an alternative embodiment, determining whether firmware can be loaded according to the first current check code, the second current check code, the third current check code, the fourth current check code, the first target check code, and the second target check code includes:
judging whether the second current check code is identical to the second target check code or not, and judging whether the fourth current check code is identical to the second target check code or not;
If the second current check code is different from the second target check code and the fourth current check code is the same as the second target check code, repairing the firmware volume header by using the backup firmware volume header;
If the second current check code is the same as the second target check code and the fourth current check code is different from the second target check code, repairing the backup firmware volume header by using the firmware volume header;
if the second current check code is the same as the second target check code and the fourth current check code is the same as the second target check code, judging whether the first current check code is the same as the first target check code or not, and judging whether the third current check code is the same as the first target check code or not;
if the first current check code is different from the first target check code and the third current check code is the same as the first target check code, determining a second firmware volume to be repaired according to the first current check code and the first target check code, repairing the second firmware volume to be repaired by using the backup firmware volume, and loading the firmware;
If the first current check code is the same as the first target check code and the third current check code is different from the first target check code, determining a backup firmware volume to be repaired according to the third current check code and the first target check code, repairing the backup firmware volume to be repaired by using the firmware volume, and loading the firmware;
if the first current check code is the same as the first target check code and the third current check code is the same as the first target check code, the firmware is directly loaded.
In this embodiment, the firmware volume header and the backup firmware volume header are backed up each other, and the firmware volume and the backup firmware volume are backed up each other, so that the firmware volume and the backup firmware volume can be repaired each other when a failure such as incomplete data occurs. The reliability of the computer is improved, the customer experience is optimized, and the smooth performance of each system startup is ensured.
In a second aspect, the present invention provides a firmware loading system for a basic input output system, the system comprising: an integrity measurement module and an active backup module;
under the condition that a firmware loading instruction is received, the integrity measurement module is used for acquiring a firmware volume header from the target flash memory chip, wherein the firmware loading instruction is used for indicating to load the firmware of the basic input and output system, and the firmware volume header is used for determining whether the firmware is complete or not;
The integrity measurement module is used for judging whether the firmware volume header is empty, creating a new firmware volume header and calling the active backup module under the condition that the firmware volume header is empty, and backing up the firmware volume of the basic input and output system according to the new firmware volume header by using the active backup module, wherein the firmware volume contains codes of firmware;
And under the condition that the firmware volume header is not empty, the integrity measurement module judges whether the mark of the firmware volume header is a preset mark, if so, a first current check code is obtained according to the firmware volume, a second current check code is obtained according to the firmware volume header, a first target check code of the firmware volume and a second target check code of the firmware volume header are obtained from the firmware volume header, and the firmware is loaded under the condition that the first current check code is identical to the first target check code and the second current check code is identical to the second target check code.
The firmware loading system of the basic input/output system provided by the embodiment performs data integrity verification on BIOS firmware according to the firmware volume header by utilizing the integrity measurement module; and if the firmware volume header is empty, calling an active backup module to backup the firmware volume of the BIOS firmware. When the firmware volume header is empty, the firmware volume is actively backed up, and when the computer system is started each time, the integrity check of BIOS firmware is automatically carried out, so that the stable operation of the system is ensured, the production cost can be reduced to a certain extent, and the labor input and the later equipment maintenance cost are reduced. The method solves the problem that the firmware of the basic input/output system cannot be subjected to integrity check and smoothly loaded under the condition that only one flash memory chip is used for backing up the firmware of the basic input/output system.
In an alternative embodiment, the system further comprises: a fault repair module;
And the integrity measurement module invokes the fault restoration module to restore the firmware volume header and/or the firmware volume by using the fault restoration module under the condition that the first current check code is different from the first target check code and/or the second current check code is different from the second target check code.
In this embodiment, when the integrity check fails, the failure repair module is used to repair the firmware volume with the failed integrity check by the backup firmware volume in the target flash memory chip, and repair the firmware volume header with the failed integrity check by the backup firmware volume header in the target flash memory chip. Through fault repair, the stable operation of the computer system is ensured, the manpower input is reduced, and the maintenance cost of equipment is reduced.
In a third aspect, the present invention provides a firmware loading apparatus for a basic input output system, the apparatus comprising:
The first acquisition module is used for acquiring a firmware volume header from the target flash memory chip under the condition of receiving a firmware loading instruction, wherein the firmware loading instruction is used for indicating to load the firmware of the basic input/output system;
The backup module is used for creating a new firmware volume header under the condition that the firmware volume header is empty, and backing up the firmware volume of the basic input/output system according to the new firmware volume header, wherein the firmware volume contains codes of firmware;
The first judging module is used for judging whether the mark of the firmware volume header is a preset mark or not under the condition that the firmware volume header is not empty;
The second acquisition module is used for acquiring a first current check code according to the firmware volume if the first current check code is a preset mark, acquiring a second current check code according to the firmware volume header, and acquiring a first target check code of the firmware volume and a second target check code of the firmware volume header from the firmware volume header;
The loading module is used for loading the firmware under the condition that the first current check code is the same as the first target check code and the second current check code is the same as the second target check code.
In a fourth aspect, the present invention provides a computer device comprising: the memory and the processor are in communication connection, computer instructions are stored in the memory, and the processor executes the computer instructions, so that the firmware loading method of the basic input/output system of the first aspect or any implementation manner corresponding to the first aspect is executed.
In a fifth aspect, the present invention provides a computer readable storage medium having stored thereon computer instructions for causing a computer to execute the firmware loading method of the basic input output system of the first aspect or any of the embodiments corresponding thereto.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the related art, the drawings that are required to be used in the description of the embodiments or the related art will be briefly described, and it is apparent that the drawings in the description below are some embodiments of the present invention, and other drawings may be obtained according to the drawings without inventive effort for those skilled in the art.
FIG. 1 is a flow chart of a method for loading firmware of a basic input/output system according to an embodiment of the invention;
FIG. 2 is a schematic diagram of a firmware volume header structure according to an embodiment of the invention;
FIG. 3 is a block diagram of a firmware loading system of a basic input output system according to an embodiment of the present invention;
FIG. 4 is a flowchart of loading firmware of a BIOS when a firmware volume header is empty according to an embodiment of the present invention;
FIG. 5 is a flow chart of the integrity check of firmware when loading the firmware of a basic input output system according to an embodiment of the present invention;
FIG. 6 is a block diagram of a firmware loading apparatus of a basic input output system according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a hardware structure of a computer device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The BIOS loading process can be generally summarized into several stages of SEC (security verification), PEI (pre-initialization), DXE (driver execution environment), BDS (boot device selection), and the like, and the code of each stage is stored in a different area in a Flash chip in the form of a Firmware Volume (FV), where the Flash chip is a nonvolatile memory, and data can be read and written by a specific program, and the Firmware Volume is a logic block in the Flash chip for storing the code and the data. The Flash chip comprises a FV_BB area, a FV_MAIN area, an NVRAM area and other areas, codes and data of SEC and PEI phases of a BIOS loading process are stored in the FV_BB area, codes and data of DXE and BDS phases are stored in the FV_MAIN area, and variable information such as configuration items of the BIOS is stored in the NVRAM area. The data in any area of the Flash chip is destroyed, which results in failure of starting up the final BIOS, and failure of starting up the system. Currently, 2 Flash chips are typically used to store BIOS firmware, one storing the master BIOS firmware and the other storing the slave BIOS firmware. On one hand, 1 Flash chip is required to be additionally purchased during the production of the equipment, so that the cost is increased; on the other hand, when the 2 nd Flash chip is damaged as well, the normal starting of the system cannot be ensured again. And when the data are destroyed, the storage equipment storing the target file is manually inserted, if the insertion is not timely, the normal starting of the system cannot be ensured, and the labor cost and the later equipment maintenance cost are increased intangibly.
Based on the above, the embodiment of the present invention provides a firmware loading method for a basic input/output system, which mainly includes 3 modules: the active backup module, the integrity measurement module and the fault restoration module realize the integrity measurement, active backup and fault restoration mechanisms through 3 modules, and load the firmware of the BIOS based on the mechanisms. The active backup module is used for backing up codes and data of the BIOS when the computer system is powered on and started for the first time, and the backed-up FV is stored in a specific target FV area of the Flash chip; the integrity measurement module performs data integrity verification on the BIOS firmware in Flash, and if the verification passes, the BIOS firmware is continuously loaded; and when the integrity check fails, the fault restoration module restores the FV area with failed integrity check through the backed-up FV part. The system and the method have the advantages that the integrity check of the BIOS firmware is carried out when the computer system is started each time, meanwhile, the self-repairing can be carried out through a fault repairing mechanism in time after the code or data of the BIOS firmware is damaged, the stable operation of the system is ensured, the production cost can be reduced to a certain extent, and the labor input and the later equipment maintenance cost are reduced.
According to an embodiment of the present invention, there is provided a firmware loading method embodiment of a basic input output system, it should be noted that the steps shown in the flowchart of the drawings may be performed in a computer device having data processing capability, and that although a logic sequence is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown or described herein.
In this embodiment, a firmware loading method of a basic input/output system is provided, which may be used in the above-mentioned computer device, and fig. 1 is a flowchart of a firmware loading method of a basic input/output system according to an embodiment of the present invention, as shown in fig. 1, where the flowchart includes the following steps:
step S101, under the condition that a firmware loading instruction is received, a firmware volume header is obtained in a target flash memory chip, wherein the firmware loading instruction is used for indicating to load the firmware of the basic input/output system.
Specifically, the CPU of a computer device such as a server has a RLTRST _n signal, through which the computer system issues a load firmware instruction. After power-on, RLTRST _N signal of CPU is pulled down, namely, a loading firmware instruction is issued to BIOS firmware loading system for loading BIOS firmware, the BIOS firmware loading system obtains Firmware Volume (FV) header in target Flash chip, only one Flash chip is needed to store BIOS firmware, backup BIOS firmware and FV header, the Flash chip is the target Flash chip. In order to realize active backup, integrity measurement and fault restoration functions, the invention designs a FV header structure based on a single Flash backup restoration mechanism, and information such as a FV header identifier, an offset address and length of the FV header, a check code of the FV header, an offset address of a backup FV header, offset addresses and lengths of different FVs, check codes of different FVs, offset addresses of different backup FVs and the like is stored in the FV header. Check codes such as: CRC check code, CRC is cyclic redundancy check, used for detecting or checking possible errors of data during transmission or after storage. The FV header is used to perform integrity checking on BIOS firmware.
Step S102, under the condition that the firmware volume header is empty, a new firmware volume header is created, and the firmware volume of the basic input output system is backed up according to the new firmware volume header, wherein the firmware volume contains codes of firmware.
Specifically, if the current computer is powered on for the first time, the FV header is empty, i.e. no FV header exists in the target Flash chip, and a new FV header is created. The firmware volume and the backup firmware volume are saved in different areas in the Flash chip according to the Firmware Volume (FV) of the new FV header backup BIOS. Obtaining information such as offset address and length of FV header, check code of FV header, offset address of backup FV header, offset address and length of different FV, check code of different FV, offset address of different backup FV, etc. according to firmware volume and backup firmware volume in Flash chip
Step S103, judging whether the mark of the firmware volume header is a preset mark or not under the condition that the firmware volume header is not empty.
Specifically, the flag of the firmware volume header is the FV header identifier, and the FV header identifier is recorded in the FV header. In the case that the FV header is not empty, determining whether the FV header identifier of the FV header is a preset flag, where the preset flag is, for example: the string "FVHEADER" FV header identifier is used for retrieval and locating. If the FV header identifier is a preset flag, the FV header is normal, otherwise, the FV header fails, and the BIOS firmware loading system gives a warning.
Step S104, if the preset mark is the preset mark, obtaining a first current check code according to the firmware volume, obtaining a second current check code according to the firmware volume header, and obtaining a first target check code of the firmware volume and a second target check code of the firmware volume header from the firmware volume header.
Specifically, if the FV header identifier is a preset flag, the FV header is normal. Calculating a first current check code from the code and data in the FV and calculating a second current check code from the data in the FV header, the first current check code and the second current check code being, for example: the CRC check code, CRC, i.e., cyclic redundancy check code (Cyclic Redundancy Check), is the most commonly used error check code in the field of data communication, and is mainly used for detecting or checking errors possibly occurring after data transmission or storage, and the CRC check code is calculated by using the principles of division and remainder (modulo two operation), and the manner of calculating the CRC check code is a conventional technical means, which is not described herein. The invention stores the check codes of the FV header and the check codes of different FVs in the FV header, can directly read the check codes of different FVs from the FV header as the first target check code of the firmware coil, and reads the check code of the FV header as the second target check code of the firmware coil header.
Step S105, loading the firmware when the first current check code is the same as the first target check code and the second current check code is the same as the second target check code.
Specifically, the BIOS firmware loading system compares the first current check code with the first target check code, compares the second current check code with the second target check code under the condition that the first current check code is the same as the first target check code, and if the second current check code is the same as the second target check code, the verification of the integrity of the BIOS firmware is passed, so that the BIOS firmware loading system can normally load the BIOS firmware.
It should be noted that the scheme of the present invention not only can be used for detecting, backing up and recovering the integrity of the firmware of the BIOS, but also is applicable to other firmware such as baseboard management controller (Baseboard Management Controller, BMC).
According to the firmware loading method of the basic input and output system, the firmware volume is actively backed up by creating the new firmware volume header, so that the firmware volume is convenient to repair subsequently, the labor input is reduced, and the maintenance cost of equipment is reduced. The backup of BIOS firmware is realized by using a single flash memory chip, and the production cost is saved. The current check code of the firmware is calculated before loading the firmware and is compared with the target check code recorded in the firmware volume header, the data integrity of the firmware is checked, and after the data integrity check is passed, the firmware is loaded again, so that the reliability of the machine is improved, the customer experience is optimized, and the smooth operation of each system startup is ensured. The method solves the problem that the firmware of the basic input/output system cannot be subjected to integrity check and smoothly loaded under the condition that only one flash memory chip is used for backing up the firmware of the basic input/output system.
In some alternative embodiments, in a case that the firmware volume header is empty, creating a new firmware volume header, and backing up the firmware volume of the basic input output system according to the new firmware volume header, including:
under the condition that the firmware volume header is empty, a new firmware volume header is created, and a preset mark is obtained;
Filling a preset mark into a first interval of the new firmware volume header to obtain a first intermediate firmware volume header;
Acquiring all firmware volumes, first offset addresses and first lengths of the firmware volumes, and obtaining a first target check code of the firmware volumes according to the firmware volumes, wherein the first offset addresses and the first lengths are used for positioning the firmware volumes, and the first target check code is used for determining whether the firmware volumes are complete or not;
filling the first offset address, the first length and the first target check code into a second section of the first intermediate firmware volume header to obtain a second intermediate firmware volume header;
acquiring a second offset address and a second length of the second intermediate firmware volume header, wherein the second offset address and the second length are used for positioning the second intermediate firmware volume header;
Determining a third offset address and a fourth offset address in the target flash memory chip, wherein the third offset address is used for backing up the second intermediate firmware volume table head, and the fourth offset address is used for backing up the firmware volume;
Filling the second offset address, the second length, the third offset address and the fourth offset address into a third section of the second intermediate firmware volume header to obtain a third intermediate firmware volume header;
Obtaining a second target check code of the third intermediate firmware volume header according to the third intermediate firmware volume header, and filling the second target check code into a fourth interval of the third intermediate firmware volume header to obtain the firmware volume header, wherein the second target check code is used for determining whether the firmware volume header is complete;
and in the target flash memory chip, backing up the firmware volume table head and all the firmware volumes.
Specifically, only one Flash chip is needed to store the BIOS firmware, the backup BIOS firmware and the FV header, and the Flash chip is the target Flash chip. The firmware volume header (FV header) is empty to indicate that no FV header exists in the target Flash chip; the absence of the FV header indicates that no backup of the BIOS firmware is performed in the target Flash chip, and therefore, the FV header needs to be created in the target Flash chip and the BIOS firmware needs to be backed up, which specifically includes the steps of:
Creating a new FV header, wherein the content in the new FV header is empty, and acquiring a preset flag, where the preset flag is as follows: the string "FVHEADER". If the FV header identifier is a preset flag, the FV header is normal, otherwise, the FV header fails, and the BIOS firmware loading system gives a warning.
And filling the preset mark into a first section of the new FV header to obtain a first intermediate firmware volume header. The FV header structure as shown in fig. 2, the first row and the first left column of the FV header do not include cells for filling in information, only the offset is recorded, and the cells referred to below are not included in the first row and the first left column. The first row of the FV header represents the offset corresponding to each cell in the second row and the first column to the left of the FV header represents the offset of the cells in the same row adjacent thereto, such as: in fig. 2, the cell filled with "F" is offset by 0, the cell filled with "R" is offset by 7, and the offset of the first cell in the second row is 8. The first interval is 0x00-0x07, "0x" representing hexadecimal, 0x00 representing a cell offset by 0 in the FV header, and 0x07 representing a cell offset by 7 in the FV header. After the new FV header is filled with the preset flag, it is referred to as a first intermediate firmware volume header in order to distinguish it from the original new FV header.
Acquiring all Firmware Volumes (FVs) of BIOS firmware stored in a target Flash chip, a first Offset address (Offset) and a first Length (Length) of each FV, wherein each FV can be positioned in the target Flash chip through the first Offset address and the first Length, the Offset is used for searching and backing up, the Length is used for calculating an end address of the FV, and the target Flash chip comprises a plurality of areas such as a FV_BB area, a FV_MAIN area, an NVRAM area and the like. Fv_bb, fv_main, NVRAM, etc. Calculating a first target check code corresponding to the FV according to codes and data in different FVs, wherein the check code is as follows: the CRC check code, the first target check code is used for integrity measurement of FV, and the mode of calculating the CRC check code is conventional technical means, and will not be repeated here. In the subsequent verification, whether the current FV is complete can be determined by calculating the verification code of the current FV and comparing the verification code with the first target verification code.
Filling the first offset address, the first length and the first target check code into a second section of the first intermediate firmware volume header to obtain a second intermediate firmware volume header, wherein the first offset address comprises: the Offset address of the NVRAM is NVRAM_Offset, the first Length is NVRAM_Length, and the first target check code is NVRAM_CRC; the Offset address of FV_BB is FV_BB_Offset, the first Length is FV_BB_Length, and the first target check code is FV_BB_CRC; the Offset address of FV_MAIN is FV_MAIN_Offset, the first Length is FV_MAIN_Length, and the first target check code is FV_MAIN_CRC. As shown in fig. 2, the second section includes: 0x20-0x27 (representing cells with 32-39 Offset), 0x28-0x2b (representing cells with 40-43 Offset), 0x2c-0x2F (representing cells with 44-47 Offset), etc., with "0x" representing hexadecimal, as shown in fig. 2, nvram_offset is filled into cells with 32-39 Offset, nvram_crc is filled into cells with 40-43 Offset, nvram_length is filled into cells with 44-47 Offset; filling FV_BB_Offset into cells with Offset of 56-63, filling FV_BB_CRC into cells with Offset of 64-67, and filling FV_BB_Length into cells with Offset of 68-71; fv_main_offset is filled into cells with an Offset of 80-87, fv_main_crc is filled into cells with an Offset of 88-91, and fv_main_length is filled into cells with an Offset of 92-95. After the first offset address, the first length and the first target check code are filled into the first intermediate firmware volume header, the first offset address, the first length and the first target check code are called a second intermediate firmware volume header for distinguishing the first intermediate firmware volume header from the original first intermediate firmware volume header.
And acquiring a second Offset address FV_HD_Offset and a second Length FV_HD_Length of the second intermediate firmware volume header from the target Flash chip, searching and backing up the FV header through the FV_HD_Offset, calculating an end address of the FV header by the FV_HD_Length, and positioning the second intermediate firmware volume header through the FV_HD_Offset and the FV_HD_Length.
And determining a third Offset address and a fourth Offset address in the target Flash chip, wherein the third Offset address is FV_HD_BAK_Offset, the FV_HD_BAK_Offset is the Offset address of the backup FV header, and after the backup of the second intermediate firmware volume header, the backup FV header can be positioned through the FV_HD_BAK_Offset. After all FV of the BIOS firmware are backed up, a corresponding backup FV is generated, and the fourth offset address is an offset address of the backup FV. Backup FV e.g.: backup fv_bb, backup fv_main, backup NVRAM, etc., the fourth offset address includes: the Offset address of the backup NVRAM is NVRAM_BAK_Offset, the Offset address of the backup FV_BB is FV_BB_BAK_Offset, and the Offset address of the backup FV_MAIN is FV_MAIN_BAK_Offset. Each backup FV can be located by a fourth offset address.
The second Offset address fv_hd_offset, the second Length fv_hd_length, the third Offset address fv_hd_bak_offset, and the fourth Offset address are filled in a third section of the second intermediate firmware volume header to obtain a third intermediate firmware volume header, as shown in fig. 2, where the third section includes: 0x08-0x0F (indicating a cell with an Offset of 8-15), 0x14-0x17 (indicating a cell with an Offset of 20-23), etc., and "0x" indicates hexadecimal, as shown in fig. 2, fv_hd_offset is filled into a cell with an Offset of 8-15, fv_hd_length is filled into a cell with an Offset of 20-23, fv_hd_bak_offset is filled into a cell with an Offset of 24-31, nvram_bak_offset is filled into a cell with an Offset of 48-55, fv_bb_bak_offset is filled into a cell with an Offset of 72-79, fv_main_bak_offset is filled into a cell with an Offset of 96-103. After the second offset address, the second length, the third offset address and the fourth offset address are filled into the second intermediate firmware volume header, the second offset address, the third offset address and the fourth offset address are called a third intermediate firmware volume header for distinguishing the second intermediate firmware volume header from the original second intermediate firmware volume header.
Calculating a second target check code fv_hd_crc according to the data of the third intermediate firmware volume header, wherein the check code is as follows: and CRC check codes, wherein a second target check code is used for measuring the integrity of the FV header. The second target check code fv_hd_crc is filled into the fourth section of the third intermediate firmware header to obtain the firmware header, as shown in fig. 2, where the fourth section is 0x10-0x13 (indicating cells with offset 16-offset 19), and fv_hd_crc is filled into cells with offset 16-19.
And calling an active backup module, backing up the firmware volume header and all the firmware volumes in the target Flash chip, and storing the backup FV header and the backup FV in a target FV area in the target Flash chip, wherein the target FV area is determined according to each offset address and each length.
In this embodiment, a new firmware volume header is created, and firmware volumes of the bios are backed up according to the new firmware volume header, and an offset address and a length of each firmware volume, an offset address of a backup firmware volume, an offset address and a length of the firmware volume header, and an offset address of the backup firmware volume header are recorded in the firmware volume header, so that positioning is facilitated. And the firmware volume header and the target verification of the firmware volume are recorded in the firmware volume header, so that the data integrity verification can be conveniently carried out subsequently.
In some alternative embodiments, after obtaining the first current check code according to the firmware volume, obtaining the second current check code according to the firmware volume header, and obtaining the first target check code of the firmware volume and the second target check code of the firmware volume header from the firmware volume header, the method further includes:
Judging whether the second current check code is the same as the second target check code or not;
Judging whether the first current check code is the same as the first target check code or not under the condition that the second current check code is the same as the second target check code;
If the first current check code is different from the first target check code, determining a first firmware volume to be repaired according to the first current check code and the first target check code, acquiring a backup firmware volume from a target flash memory chip, repairing the first firmware volume to be repaired by using the backup firmware volume, and loading firmware;
Under the condition that the second current check code is different from the second target check code, acquiring a backup firmware volume header from the target flash memory chip, and repairing the firmware volume header by using the backup firmware volume header;
Judging whether the first current check code is the same as the first target check code or not, if the first current check code is different from the first target check code, determining a first firmware volume to be repaired according to the first current check code and the first target check code, repairing the first firmware volume to be repaired by using the backup firmware volume, and loading the firmware;
if the first current check code is the same as the first target check code, the firmware is directly loaded.
Specifically, FV is, for example: fv_bb, fv_main, NVRAM, etc. And calculating a first current check code of each FV according to the codes and the data in each FV, and calculating a second current check code of the FV header according to the data of the FV header. And reading the first target check codes of different FVs from the FV header, and reading the second target check codes of the FV header. Check codes such as: the method for calculating the CRC code is a conventional technical means, and is not repeated here.
Judging whether the second current check code is the same as the second target check code, if so, indicating that the integrity check of the FV header passes, and the data of the FV header is complete.
And under the condition that the second current check code is the same as the second target check code, judging whether the first current check code is the same as the first target check code, and if so, indicating that the FV integrity check passes, wherein the codes and the data in the FV are complete. If the first current check code is different from the first target check code, the first current check code which is different from the corresponding first target check code is used as the first firmware volume to be repaired, for example: if the first current check code of fv_bb is different from the corresponding first target check code, fv_bb is the first firmware volume to be repaired. The backup FV is obtained from the target Flash chip, and the backup FV is used to repair the first firmware volume to be repaired, for example: and acquiring the backup FV_BB in the target Flash chip, and copying codes and data of the backup FV_BB into the FV_BB to finish the repair of the FV_BB. After the repair of the first firmware volume to be repaired is completed, loading BIOS firmware.
And under the condition that the second current check code is different from the second target check code, the data of the FV header is incomplete. The back-up FV header is obtained from the target Flash chip, and the back-up FV header is used to repair the FV header, for example: the data in the back-up FV header is copied to the FV header.
After the repair of the FV header is completed, judging whether the first current check code is identical to the first target check code, if the first current check code is not identical to the first target check code, taking the first current check code which is not identical to the corresponding first target check code as a first firmware volume to be repaired, acquiring a backup FV from a target Flash chip, and repairing the first firmware volume to be repaired by using the backup FV. After the repair of the first firmware volume to be repaired is completed, loading BIOS firmware. If the first current check code is the same as the first target check code, the BIOS firmware is directly loaded.
In the embodiment, in the data integrity verification process, if the data of the firmware volume header is incomplete, the backup firmware volume header is utilized to repair, and if the data of the firmware volume is incomplete, the corresponding backup firmware volume is utilized to repair, so that the timely detection and repair of faults are realized, and the reliability of the computer is improved.
In some alternative embodiments, the method further comprises:
obtaining a third offset address and a fourth offset address according to the firmware volume header;
in the target flash memory chip, a backup firmware volume table head is obtained according to the third offset address, and a backup firmware volume is obtained according to the fourth offset address;
Obtaining a third current check code according to the backup firmware volume and obtaining a fourth current check code according to the backup firmware volume header, wherein the third current check code is used for determining whether the backup firmware volume is complete, and the fourth current check code is used for determining whether the backup firmware volume header is complete;
and judging whether the firmware can be loaded according to the first current check code, the second current check code, the third current check code, the fourth current check code, the first target check code and the second target check code.
Specifically, in the target Flash chip, the FV header and the backup FV header are backed up, the CRC values of the FV header and the backup FV header are calculated before loading the BIOS firmware each time, and compared with the CRC values stored in the FV header, respectively, and when the CRC values are inconsistent, the data of the current FV header is restored by using the data of the other FV header. FV and back-up FV are the same.
Obtaining a third Offset address and a fourth Offset address from the FV header, wherein the third Offset address is fv_hd_bak_offset, fv_hd_bak_offset is the Offset address of the back-up FV header, and the back-up FV header can be positioned by using the third Offset address; the fourth offset address includes: the Offset address of the backup NVRAM is NVRAM_BAK_Offset, the Offset address of the backup FV_BB is FV_BB_BAK_Offset, and the Offset address of the backup FV_MAIN is FV_MAIN_BAK_Offset. Each backup FV can be located by a fourth offset address.
In the target flash memory chip, positioning the back-up FV header according to a third Offset address FV_HD_BAK_Offset, and acquiring data of the back-up FV header; and positioning each backup FV according to the fourth offset address, and acquiring codes and data of each backup FV.
And calculating third current check codes of different backup FVs according to codes and data of the backup FVs, and calculating fourth current check codes according to data of the backup FV header. Check codes such as: the method for calculating the CRC code is a conventional technical means, and is not repeated here.
Judging whether firmware can be loaded according to the first current check code, the second current check code, the third current check code, the fourth current check code, the first target check code and the second target check code, for example: if the second current check code is the same as the second target check code, the fourth current check code is the same as the second target check code, the first current check code is the same as the first target check code, and the third current check code is the same as the first target check code, the FV header, the backup FV header, each FV and each backup FV pass the integrity check, the data are complete, the BIOS firmware is complete, the loading is not wrong, and the BIOS firmware can be directly loaded; if the fourth current check code is different from the second target check code, the FV header is restored and backed up by utilizing the FV header; if the first current check code is not the same as the first target check code, restoring the FV by using the backup FV; in summary, the FV header and the back-up FV header are back-up to each other, and FV and back-up FV are back-up to each other, so that they can be restored to each other.
In this embodiment, the third current check code of the backup firmware volume and the fourth current check code of the backup firmware volume header are calculated, so that when the data integrity of the BIOS firmware is checked later, the data integrity of the backup firmware volume and the backup firmware volume header are checked at the same time.
In some alternative embodiments, determining whether firmware can be loaded according to the first current check code, the second current check code, the third current check code, the fourth current check code, the first target check code, and the second target check code includes:
judging whether the second current check code is identical to the second target check code or not, and judging whether the fourth current check code is identical to the second target check code or not;
If the second current check code is different from the second target check code and the fourth current check code is the same as the second target check code, repairing the firmware volume header by using the backup firmware volume header;
If the second current check code is the same as the second target check code and the fourth current check code is different from the second target check code, repairing the backup firmware volume header by using the firmware volume header;
if the second current check code is the same as the second target check code and the fourth current check code is the same as the second target check code, judging whether the first current check code is the same as the first target check code or not, and judging whether the third current check code is the same as the first target check code or not;
if the first current check code is different from the first target check code and the third current check code is the same as the first target check code, determining a second firmware volume to be repaired according to the first current check code and the first target check code, repairing the second firmware volume to be repaired by using the backup firmware volume, and loading the firmware;
If the first current check code is the same as the first target check code and the third current check code is different from the first target check code, determining a backup firmware volume to be repaired according to the third current check code and the first target check code, repairing the backup firmware volume to be repaired by using the firmware volume, and loading the firmware;
if the first current check code is the same as the first target check code and the third current check code is the same as the first target check code, the firmware is directly loaded.
Specifically, FV is, for example: fv_bb, fv_main, NVRAM, etc. And calculating a first current check code of each FV according to the codes and the data in each FV, and calculating a second current check code of the FV header according to the data of the FV header. And reading the first target check codes of different FVs from the FV header, and reading the second target check codes of the FV header. And calculating third current check codes of different backup FVs according to codes and data of the backup FVs, and calculating fourth current check codes according to data of the backup FV header. Check codes such as: the method for calculating the CRC code is a conventional technical means, and is not repeated here.
If the second current check code is different from the second target check code and the fourth current check code is the same as the second target check code, the data of the FV header is incomplete, and the data of the backup FV header is complete, the FV header is restored by using the backup FV header.
If the second current check code is the same as the second target check code and the fourth current check code is different from the second target check code, the data of the FV header is complete, and the data of the backup FV header is incomplete, the backup FV header is restored by utilizing the FV header.
If the second current check code is the same as the second target check code and the fourth current check code is the same as the second target check code, indicating that the FV header and the backup FV header are complete in data, further judging whether the first current check code is the same as the first target check code or not, and whether the third current check code is the same as the first target check code or not.
If the first current check code is different from the first target check code and the third current check code is the same as the first target check code, the data of all the backup FVs are complete, but the FVs with incomplete data exist, the corresponding FVs with the first current check code being different from the first target check code are used as the second firmware volume to be repaired, and the backup FVs corresponding to the second firmware volume to be repaired are utilized to repair the second firmware volume to be repaired. And loading BIOS firmware after the second firmware volume to be repaired is repaired.
If the first current check code is the same as the first target check code and the third current check code is different from the first target check code, the data of all FVs are complete, but backup FVs with incomplete data exist, the corresponding backup FVs with the third current check code different from the first target check code are used as the second firmware volume to be repaired, and the FVs corresponding to the second firmware volume to be repaired are utilized to repair the second firmware volume to be repaired. And loading BIOS firmware after the second firmware volume to be repaired is repaired.
If the first current check code is the same as the first target check code and the third current check code is the same as the first target check code, the data of all FVs are complete, and the data of all backup FVs are complete, the data of the FV header and the backup FV header are also complete, so that the BIOS firmware is complete, loading is not wrong, and the BIOS firmware can be directly loaded.
In this embodiment, the firmware volume header and the backup firmware volume header are backed up each other, and the firmware volume and the backup firmware volume are backed up each other, so that the firmware volume and the backup firmware volume can be repaired each other when a failure such as incomplete data occurs. The reliability of the computer is improved, the customer experience is optimized, and the smooth performance of each system startup is ensured.
In this embodiment, a firmware loading system of a basic input/output system is provided, which may be deployed in the above-mentioned computer device, and the system includes: an integrity measurement module and an active backup module;
under the condition that a firmware loading instruction is received, the integrity measurement module is used for acquiring a firmware volume header from the target flash memory chip, wherein the firmware loading instruction is used for indicating to load the firmware of the basic input and output system, and the firmware volume header is used for determining whether the firmware is complete or not;
The integrity measurement module is used for judging whether the firmware volume header is empty, creating a new firmware volume header and calling the active backup module under the condition that the firmware volume header is empty, and backing up the firmware volume of the basic input and output system according to the new firmware volume header by using the active backup module, wherein the firmware volume contains codes of firmware;
And under the condition that the firmware volume header is not empty, the integrity measurement module judges whether the mark of the firmware volume header is a preset mark, if so, a first current check code is obtained according to the firmware volume, a second current check code is obtained according to the firmware volume header, a first target check code of the firmware volume and a second target check code of the firmware volume header are obtained from the firmware volume header, and the firmware is loaded under the condition that the first current check code is identical to the first target check code and the second current check code is identical to the second target check code.
Specifically, after a computer device such as a server is powered on and started, a RLTRST _n signal of a CPU is pulled down, that is, a firmware loading instruction is issued to a firmware loading system of a Basic Input Output System (BIOS), the firmware loading system of the BIOS invokes an integrity measurement module to perform data integrity verification on FV and FV headers, and invokes an active backup module or a fault repair module according to the verification condition, and after the FV and FV headers pass the data integrity verification, a process of loading BIOS firmware is executed. As shown in fig. 3, a load firmware instruction is input into an integrity metrics module, which may invoke an active backup module or a fail-over module.
Under the condition that a firmware loading instruction is received, the integrity measurement module acquires the FV header in the target Flash chip, judges whether the FV header is empty, creates a new FV header and calls the active backup module if the FV header is empty, and the active backup module is utilized to backup the FV of the BIOS according to the new FV header, wherein the specific process is as shown in FIG. 4: starting; RLTRST _N is pulled low; initializing an integrity measurement module; searching the FV table head through the address, and judging whether the FV table head is empty or not; if empty, creating a new FV header, and filling a header mark 'FVHEADER'; reading the Offset and Length of each FV part in the firmware, and calculating a checksum; filling Offset, length and CRC checksum of each FV into the FV header; filling FV header, FV header Length, offset of each back-up FV header, and Offset of each back-up FV header into the FV header; calculating CRC checksum of the whole FV header, and filling the CRC checksum into the FV header; initializing an active backup module; backing up FV heads and FV parts; loading BIOS firmware; and (5) ending.
If the FV header is not empty, the integrity measurement module determines whether the FV header flag is a preset flag, e.g., "FVHEADER", and if not, the integrity measurement module issues an alarm message; if so, a first current check code is obtained through calculation according to the code and the data of the FV, a second current check code is obtained through calculation according to the data of the FV header, the first target check code of the FV and the second target check code of the FV header are obtained from the FV header, and the firmware is loaded under the condition that the first current check code is identical to the first target check code and the second current check code is identical to the second target check code. The above process is shown in fig. 5: starting; RLTRST _N is pulled low; initializing an integrity measurement module; searching the FV table head through the address, and judging whether the FV table head is empty or not; if not, reading FV header mark, judging whether it is 'FVHEADER'; if not, sending out alarm information and ending; if so, calculating CRC of the FV header and comparing with FV_HD_CRC stored in the FV header; judging whether the two are consistent, if so, calculating CRC of each FV part, comparing with CRC of each FV part stored in the FV head, and judging whether the two are consistent; if the CRC of each FV part is consistent with the CRC of each FV part stored in the FV header, loading BIOS firmware and ending.
The firmware loading system of the basic input/output system provided by the embodiment performs data integrity verification on BIOS firmware according to the firmware volume header by utilizing the integrity measurement module; and if the firmware volume header is empty, calling an active backup module to backup the firmware volume of the BIOS firmware. When the firmware volume header is empty, the firmware volume is actively backed up, and when the computer system is started each time, the integrity check of BIOS firmware is automatically carried out, so that the stable operation of the system is ensured, the production cost can be reduced to a certain extent, and the labor input and the later equipment maintenance cost are reduced. The method solves the problem that the firmware of the basic input/output system cannot be subjected to integrity check and smoothly loaded under the condition that only one flash memory chip is used for backing up the firmware of the basic input/output system.
In some alternative embodiments, the system further comprises: a fault repair module;
And the integrity measurement module invokes the fault restoration module to restore the firmware volume header and/or the firmware volume by using the fault restoration module under the condition that the first current check code is different from the first target check code and/or the second current check code is different from the second target check code.
Specifically, the first current check code is different from the first target check code and/or the second current check code is different from the second target check code includes the following three cases: the first current check code is different from the first target check code, the second current check code is different from the second target check code, each FV and FV header of the BIOS firmware is represented by passing the data integrity check, the data is incomplete, the integrity measurement module invokes the fault repair module, the fault repair module obtains the backup FV and the backup FV header from the target Flash chip, the FV is repaired by using the backup FV, and the FV header is repaired by using the backup FV header, for example: copying codes and data in the backup FV into the FV, and copying data of the front of the backup FV into the front of the FV; the first current check code is the same as the first target check code, the second current check code is different from the second target check code, the data of each FV of the BIOS firmware are complete, but the data of the FV header is incomplete, the integrity measurement module can call the fault repair module, the fault repair module can obtain a backup FV header from the target Flash chip, and the FV header is repaired by the backup FV header; the first current check code is different from the first target check code, the second current check code is the same as the second target check code, the FV header data of the BIOS firmware is complete, but the data incompletion FV exists in the BIOS firmware, the integrity measurement module can call the fault restoration module, the fault restoration module can acquire the backup FV from the target Flash chip, and the data incompletion FV is restored by the backup FV.
The above process is shown in fig. 5: calculating CRC of the FV header and comparing with FV_HD_CRC stored in the FV header; judging whether CRC of the FV header is consistent with FV_HD_CRC, if the CRC of the FV header is inconsistent with FV_HD_CRC, initializing a fault repair module; restoring the FV header by backing up the FV header; calculating CRC of each FV part and comparing with CRC of each FV part stored in the FV header; judging whether CRC of each FV part is consistent with CRC of each FV part stored in the FV header, if so, loading BIOS firmware, and ending; if not, repairing the damaged FV part, loading BIOS firmware, and ending. If the CRC of the FV header is inconsistent with the FV_HD_CRC, calculating the CRC of each FV part, comparing the CRC with the CRC of each FV part stored in the FV header, judging whether the CRC of each FV part is consistent with the CRC of each FV part stored in the FV header, if not, initializing a fault repair module, repairing the damaged FV part, loading BIOS firmware and ending.
In this embodiment, when the integrity check fails, the failure repair module is used to repair the firmware volume with the failed integrity check by the backup firmware volume in the target flash memory chip, and repair the firmware volume header with the failed integrity check by the backup firmware volume header in the target flash memory chip. Through fault repair, the stable operation of the computer system is ensured, the manpower input is reduced, and the maintenance cost of equipment is reduced.
The embodiment also provides a firmware loading device of the basic input/output system, which is used for implementing the above embodiment and the preferred implementation manner, and the description is omitted. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
The present embodiment provides a firmware loading device of a basic input/output system, as shown in fig. 6, including:
The first obtaining module 601 is configured to obtain a firmware volume header from the target flash memory chip when receiving a firmware loading instruction, where the firmware loading instruction is used to instruct loading of firmware of the bios;
The backup module 602 is configured to create a new firmware volume header when the firmware volume header is empty, and backup a firmware volume of the bios according to the new firmware volume header, where the firmware volume includes codes of firmware;
a first judging module 603, configured to judge whether a flag of the firmware volume header is a preset flag if the firmware volume header is not empty;
The second obtaining module 604 is configured to obtain a first current check code according to the firmware volume if the first current check code is a preset flag, obtain a second current check code according to the firmware volume header, and obtain a first target check code of the firmware volume and a second target check code of the firmware volume header from the firmware volume header;
the loading module 605 is configured to load firmware when the first current check code is the same as the first target check code and the second current check code is the same as the second target check code.
In some alternative embodiments, backup module 602 includes:
The first acquisition unit is used for creating a new firmware volume header and acquiring a preset mark under the condition that the firmware volume header is empty;
the first filling unit is used for filling the preset mark into a first interval of the new firmware volume header to obtain a first intermediate firmware volume header;
The first obtaining unit is used for obtaining all the firmware volumes, a first offset address and a first length of the firmware volumes, and obtaining a first target check code of the firmware volumes according to the firmware volumes, wherein the first offset address and the first length are used for positioning the firmware volumes, and the first target check code is used for determining whether the firmware volumes are complete or not;
The second obtaining unit is used for filling the first offset address, the first length and the first target check code into a second section of the first intermediate firmware volume header to obtain a second intermediate firmware volume header;
The second obtaining unit is used for obtaining a second offset address and a second length of the second intermediate firmware volume header, wherein the second offset address and the second length are used for positioning the second intermediate firmware volume header;
The determining unit is used for determining a third offset address and a fourth offset address in the target flash memory chip, wherein the third offset address is used for backing up the second intermediate firmware volume header, and the fourth offset address is used for backing up the firmware volume;
The second filling unit is used for filling the second offset address, the second length, the third offset address and the fourth offset address into a third section of the second intermediate firmware volume header to obtain a third intermediate firmware volume header;
The third filling unit is used for obtaining a second target check code of the third intermediate firmware volume header according to the third intermediate firmware volume header, and filling the second target check code into a fourth interval of the third intermediate firmware volume header to obtain the firmware volume header, wherein the second target check code is used for determining whether the firmware volume header is complete;
And the backup unit is used for backing up the firmware volume table head and all the firmware volumes in the target flash memory chip.
In some alternative embodiments, the second acquisition module 604 includes:
The first judging unit is used for judging whether the second current check code is the same as the second target check code or not;
The second judging unit is used for judging whether the first current check code is the same as the first target check code or not under the condition that the second current check code is the same as the second target check code;
the first repair unit is used for determining a first firmware volume to be repaired according to the first current check code and the first target check code if the first current check code is different from the first target check code, acquiring a backup firmware volume in the target flash memory chip, repairing the first firmware volume to be repaired by using the backup firmware volume, and loading firmware;
the second repairing unit is used for acquiring the backup firmware volume header from the target flash memory chip under the condition that the second current check code is different from the second target check code, and repairing the firmware volume header by using the backup firmware volume header;
The third judging unit is used for judging whether the first current check code is the same as the first target check code, if the first current check code is different from the first target check code, determining a first firmware volume to be repaired according to the first current check code and the first target check code, repairing the first firmware volume to be repaired by utilizing the backup firmware volume, and loading the firmware;
And the loading unit is used for directly loading the firmware if the first current check code is the same as the first target check code.
In some alternative embodiments, the apparatus further comprises:
The obtaining module is used for obtaining a third offset address and a fourth offset address according to the firmware volume header;
the obtaining module is used for obtaining a backup firmware volume table head according to the third offset address and obtaining a backup firmware volume according to the fourth offset address in the target flash memory chip;
the obtaining module is used for obtaining a third current check code according to the backup firmware volume and obtaining a fourth current check code according to the backup firmware volume header, wherein the third current check code is used for determining whether the backup firmware volume is complete, and the fourth current check code is used for determining whether the backup firmware volume header is complete;
The second judging module is used for judging whether the firmware can be loaded according to the first current check code, the second current check code, the third current check code, the fourth current check code, the first target check code and the second target check code.
In some alternative embodiments, the second determining module includes:
The fourth judging unit is used for judging whether the second current check code is the same as the second target check code or not and judging whether the fourth current check code is the same as the second target check code or not;
The third repair unit is used for repairing the firmware volume header by using the backup firmware volume header if the second current check code is different from the second target check code and the fourth current check code is the same as the second target check code;
the fourth repairing unit is used for repairing the backup firmware volume header by using the firmware volume header if the second current check code is the same as the second target check code and the fourth current check code is different from the second target check code;
A fifth judging unit, configured to judge whether the first current check code is identical to the first target check code and whether the third current check code is identical to the first target check code if the second current check code is identical to the second target check code and the fourth current check code is identical to the second target check code;
A fifth repair unit, configured to determine, if the first current check code is different from the first target check code and the third current check code is the same as the first target check code, a second firmware volume to be repaired according to the first current check code and the first target check code, repair the second firmware volume to be repaired by using the backup firmware volume, and load firmware;
The sixth restoring unit is configured to determine a backup firmware volume to be restored according to the third current check code and the first target check code if the first current check code is the same as the first target check code and the third current check code is different from the first target check code, restore the backup firmware volume to be restored by using the firmware volume, and load firmware;
and the loading unit is used for directly loading the firmware if the first current check code is the same as the first target check code and the third current check code is the same as the first target check code.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
The firmware loading device of the bios in this embodiment is presented as a functional unit, where the unit refers to an ASIC (Application SPECIFIC INTEGRATED Circuit) Circuit, a processor and a memory that execute one or more software or firmware programs, and/or other devices that can provide the above functions.
The embodiment of the invention also provides a computer device, which is provided with the firmware loading device of the basic input/output system shown in the figure 6.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a computer device according to an alternative embodiment of the present invention, as shown in fig. 7, the computer device includes: one or more processors 10, memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the computer device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple computer devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 10 is illustrated in fig. 7.
The processor 10 may be a central processor, a network processor, or a combination thereof. The processor 10 may further include a hardware chip, among others. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform a method for implementing the embodiments described above.
The memory 20 may include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 20 may optionally include memory located remotely from processor 10, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
Memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk, or solid state disk; the memory 20 may also comprise a combination of the above types of memories.
The computer device also includes a communication interface 30 for the computer device to communicate with other devices or communication networks.
The embodiments of the present invention also provide a computer readable storage medium, and the method according to the embodiments of the present invention described above may be implemented in hardware, firmware, or as a computer code which may be recorded on a storage medium, or as original stored in a remote storage medium or a non-transitory machine readable storage medium downloaded through a network and to be stored in a local storage medium, so that the method described herein may be stored on such software process on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, a solid state disk or the like; further, the storage medium may also comprise a combination of memories of the kind described above. It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Although embodiments of the present invention have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope of the invention as defined by the appended claims.

Claims (10)

1. A method for loading firmware of a basic input/output system, the method comprising:
under the condition of receiving a firmware loading instruction, acquiring a firmware volume header from a target flash memory chip, wherein the firmware loading instruction is used for indicating loading of firmware of a basic input/output system;
creating a new firmware volume header under the condition that the firmware volume header is empty, and backing up the firmware volume of the basic input/output system according to the new firmware volume header, wherein the firmware volume contains codes of the firmware;
judging whether a mark of the firmware volume header is a preset mark or not under the condition that the firmware volume header is not empty;
If the preset mark is the preset mark, a first current check code is obtained according to the firmware volume, a second current check code is obtained according to the firmware volume header, and a first target check code of the firmware volume and a second target check code of the firmware volume header are obtained from the firmware volume header;
and loading the firmware under the condition that the first current check code is the same as the first target check code and the second current check code is the same as the second target check code.
2. The method of claim 1, wherein creating a new firmware volume header and backing up the firmware volume of the bios based on the new firmware volume header if the firmware volume header is empty comprises:
Under the condition that the firmware volume header is empty, creating the new firmware volume header and acquiring the preset mark;
filling the preset mark into a first interval of the new firmware volume header to obtain a first intermediate firmware volume header;
Acquiring all the firmware volumes, a first offset address and a first length of the firmware volumes, and obtaining the first target check code of the firmware volumes according to the firmware volumes, wherein the first offset address and the first length are used for positioning the firmware volumes, and the first target check code is used for determining whether the firmware volumes are complete;
Filling the first offset address, the first length and the first target check code into a second section of the first intermediate firmware volume header to obtain a second intermediate firmware volume header;
Acquiring a second offset address and a second length of the second intermediate firmware volume header, wherein the second offset address and the second length are used for positioning the second intermediate firmware volume header;
Determining a third offset address and a fourth offset address in the target flash memory chip, wherein the third offset address is used for backing up the second intermediate firmware volume header, and the fourth offset address is used for backing up the firmware volume;
Filling the second offset address, the second length, the third offset address and the fourth offset address into a third section of the second intermediate firmware volume header to obtain a third intermediate firmware volume header;
Obtaining the second target check code of the third intermediate firmware volume header according to the third intermediate firmware volume header, and filling the second target check code into a fourth interval of the third intermediate firmware volume header to obtain the firmware volume header, wherein the second target check code is used for determining whether the firmware volume header is complete;
And in the target flash memory chip, backing up the firmware volume header and all the firmware volumes.
3. The method of claim 1, wherein after the obtaining a first current check code from the firmware volume, obtaining a second current check code from the firmware volume header, and obtaining a first target check code for the firmware volume and a second target check code for the firmware volume header from the firmware volume header, the method further comprises:
judging whether the second current check code is the same as the second target check code or not;
Judging whether the first current check code is identical to the first target check code or not under the condition that the second current check code is identical to the second target check code;
if the first current check code is different from the first target check code, determining a first firmware volume to be repaired according to the first current check code and the first target check code, acquiring a backup firmware volume from the target flash memory chip, repairing the first firmware volume to be repaired by using the backup firmware volume, and loading the firmware;
Under the condition that the second current check code is different from the second target check code, acquiring a backup firmware volume header from the target flash memory chip, and repairing the firmware volume header by using the backup firmware volume header;
Judging whether the first current check code is the same as the first target check code, if the first current check code is different from the first target check code, determining the first firmware volume to be repaired according to the first current check code and the first target check code, repairing the first firmware volume to be repaired by utilizing the backup firmware volume, and loading the firmware;
and if the first current check code is the same as the first target check code, directly loading the firmware.
4. The method according to claim 2, wherein the method further comprises:
obtaining the third offset address and the fourth offset address according to the firmware volume header;
In the target flash memory chip, a backup firmware volume table head is obtained according to the third offset address, and a backup firmware volume is obtained according to the fourth offset address;
obtaining a third current check code according to the backup firmware volume, and obtaining a fourth current check code according to the backup firmware volume header, wherein the third current check code is used for determining whether the backup firmware volume is complete, and the fourth current check code is used for determining whether the backup firmware volume header is complete;
And judging whether the firmware can be loaded according to the first current check code, the second current check code, the third current check code, the fourth current check code, the first target check code and the second target check code.
5. The method of claim 4, wherein the determining whether the firmware can be loaded based on the first current check code, the second current check code, the third current check code, the fourth current check code, the first target check code, and the second target check code comprises:
judging whether the second current check code is the same as the second target check code or not, and judging whether the fourth current check code is the same as the second target check code or not;
If the second current check code is different from the second target check code and the fourth current check code is the same as the second target check code, repairing the firmware volume header by using the backup firmware volume header;
If the second current check code is the same as the second target check code and the fourth current check code is different from the second target check code, repairing the backup firmware volume header by using the firmware volume header;
If the second current check code is the same as the second target check code and the fourth current check code is the same as the second target check code, judging whether the first current check code is the same as the first target check code or not, and judging whether the third current check code is the same as the first target check code or not;
if the first current check code is different from the first target check code and the third current check code is the same as the first target check code, determining a second firmware volume to be repaired according to the first current check code and the first target check code, repairing the second firmware volume to be repaired by utilizing the backup firmware volume, and loading the firmware;
If the first current check code is the same as the first target check code and the third current check code is different from the first target check code, determining a backup firmware volume to be repaired according to the third current check code and the first target check code, repairing the backup firmware volume to be repaired by utilizing the firmware volume, and loading the firmware;
and if the first current check code is the same as the first target check code and the third current check code is the same as the first target check code, directly loading the firmware.
6. A firmware loading system for a basic input output system, the system comprising: an integrity measurement module and an active backup module;
Under the condition that a firmware loading instruction is received, the integrity measurement module is used for acquiring a firmware volume header from a target flash memory chip, wherein the firmware loading instruction is used for indicating to load the firmware of a basic input/output system, and the firmware volume header is used for determining whether the firmware is complete or not;
The integrity measurement module is used for judging whether the firmware volume header is empty, creating a new firmware volume header and calling the active backup module under the condition that the firmware volume header is empty, and backing up the firmware volume of the basic input/output system by utilizing the active backup module according to the new firmware volume header, wherein the firmware volume contains codes of the firmware;
And under the condition that the firmware volume header is not empty, the integrity measurement module judges whether a mark of the firmware volume header is a preset mark, if so, a first current check code is obtained according to the firmware volume, a second current check code is obtained according to the firmware volume header, a first target check code of the firmware volume and a second target check code of the firmware volume header are obtained from the firmware volume header, and the firmware is loaded under the condition that the first current check code is identical to the first target check code and the second current check code is identical to the second target check code.
7. The system of claim 6, wherein the system further comprises: a fault repair module;
And the integrity measurement module calls the fault restoration module to restore the firmware volume header and/or the firmware volume by using the fault restoration module under the condition that the first current check code is different from the first target check code and/or the second current check code is different from the second target check code.
8. A firmware loading apparatus for a basic input output system, the apparatus comprising:
The first acquisition module is used for acquiring a firmware volume header from the target flash memory chip under the condition of receiving a firmware loading instruction, wherein the firmware loading instruction is used for indicating the loading of the firmware of the basic input/output system;
The backup module is used for creating a new firmware volume header under the condition that the firmware volume header is empty, and backing up the firmware volume of the basic input/output system according to the new firmware volume header, wherein the firmware volume contains codes of the firmware;
The first judging module is used for judging whether the mark of the firmware volume header is a preset mark or not under the condition that the firmware volume header is not empty;
The second acquisition module is used for acquiring a first current check code according to the firmware volume if the preset mark is the preset mark, acquiring a second current check code according to the firmware volume header, and acquiring a first target check code of the firmware volume and a second target check code of the firmware volume header from the firmware volume header;
The loading module is used for loading the firmware under the condition that the first current check code is the same as the first target check code and the second current check code is the same as the second target check code.
9. A computer device, comprising:
A memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the method of loading firmware of the basic input output system of any one of claims 1 to 7.
10. A computer-readable storage medium having stored thereon computer instructions for causing a computer to perform the firmware loading method of the basic input output system of any one of claims 1 to 7.
CN202311839874.1A 2023-12-28 2023-12-28 Firmware loading method, system and device of basic input/output system Pending CN118093028A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311839874.1A CN118093028A (en) 2023-12-28 2023-12-28 Firmware loading method, system and device of basic input/output system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311839874.1A CN118093028A (en) 2023-12-28 2023-12-28 Firmware loading method, system and device of basic input/output system

Publications (1)

Publication Number Publication Date
CN118093028A true CN118093028A (en) 2024-05-28

Family

ID=91149655

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311839874.1A Pending CN118093028A (en) 2023-12-28 2023-12-28 Firmware loading method, system and device of basic input/output system

Country Status (1)

Country Link
CN (1) CN118093028A (en)

Similar Documents

Publication Publication Date Title
CN113064747B (en) Fault positioning method, system and device in server starting process
CN108646982B (en) Automatic data restoration method and device based on UBIFS
CN113282434B (en) Memory repair method based on post-package repair technology and related components
CN109032632B (en) FOTA upgrading method, wireless communication terminal and storage medium
US20070055969A1 (en) System and method for updating firmware
CN104834575A (en) Firmware recovery method and device
CN106775610B (en) Electronic equipment starting method and electronic equipment
CN113064757B (en) Server firmware self-recovery system and server
CN108932249B (en) Method and device for managing file system
CN114116280B (en) Interactive BMC self-recovery method, system, terminal and storage medium
CN111552592A (en) Double-backup starting method and system
CN111813753A (en) File saving method, file restoring method, device and terminal equipment
CN115421984A (en) Memory fault processing method and device, electronic equipment and medium
CN105426268A (en) Method for preventing damage of file system during outage of relay protection device
CN118093028A (en) Firmware loading method, system and device of basic input/output system
CN113448760B (en) Method, system, equipment and medium for recovering abnormal state of hard disk
CN114116330B (en) Server performance testing method, system, terminal and storage medium
CN114385418A (en) Protection method, device, equipment and storage medium for communication equipment
CN111783162B (en) Data protection implementation method and device and computer equipment
CN114594995A (en) Electronic device and starting method thereof
CN113094107A (en) Data protection method, device, equipment and computer storage medium
KR20030062793A (en) Apparatus and Method for operating recovery and backup of linux operting system
CN117472291B (en) Data block verification method and device, storage medium and electronic equipment
TWI777259B (en) Boot method
CN113608922A (en) Backup system switching method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination