CN114741091A - Firmware loading method and device, electronic equipment and computer readable storage medium - Google Patents

Firmware loading method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN114741091A
CN114741091A CN202210272778.2A CN202210272778A CN114741091A CN 114741091 A CN114741091 A CN 114741091A CN 202210272778 A CN202210272778 A CN 202210272778A CN 114741091 A CN114741091 A CN 114741091A
Authority
CN
China
Prior art keywords
check value
firmware
programmable device
firmware data
data
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
CN202210272778.2A
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.)
Accelink Technologies Co Ltd
Original Assignee
Accelink Technologies 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 Accelink Technologies Co Ltd filed Critical Accelink Technologies Co Ltd
Priority to CN202210272778.2A priority Critical patent/CN114741091A/en
Publication of CN114741091A publication Critical patent/CN114741091A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/63Image based installation; Cloning; Build to order
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/51Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems at application loading time, e.g. accepting, rejecting, starting or inhibiting executable software based on integrity or source reliability
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a firmware loading method, a firmware loading device, electronic equipment and a computer readable storage medium; the method is applied to a Central Processing Unit (CPU) which is in communication connection with a programmable device, and comprises the following steps: reading firmware data and a corresponding first check value from the programmable device; calculating a check value of the firmware data through a check value algorithm to obtain a corresponding second check value; comparing the first check value with the second check value to obtain a corresponding comparison result; and when the comparison result indicates that the first check value is consistent with the second check value, sending a firmware loading instruction to the programmable device so that the programmable device loads a firmware program corresponding to the firmware data. By the method and the device, the stability and the reliability of a communication system where the programmable device is located can be improved.

Description

Firmware loading method and device, electronic equipment and computer readable storage medium
Technical Field
The present application relates to programmable device technologies, and in particular, to a firmware loading method, apparatus, device, and computer readable storage medium.
Background
Some programmable devices in the market can store firmware programs inside, so that peripheral circuits of the programmable devices are reduced, and the area of a circuit board is reduced. However, for upgrading a firmware program in the programmable device, a Central Processing Unit (CPU) needs to communicate with the programmable device first, and then the programmable chip writes the upgraded firmware program into an internal storage space, and once the firmware upgrading fails, the programmable device may not be started, so that the CPU cannot upgrade the programmable device again, and can only burn the firmware program through a Joint Test Action Group (JTAG) interface of the programmable device, which seriously affects the reliability of the system.
Disclosure of Invention
The embodiment of the application provides a firmware loading method, a firmware loading device, electronic equipment and a computer readable storage medium, which can improve the stability and reliability of a programmable device system.
The technical scheme of the embodiment of the application is realized as follows:
the embodiment of the application provides a firmware loading method, which is applied to a Central Processing Unit (CPU) in communication connection with a programmable device, and comprises the following steps:
reading firmware data and a corresponding first check value from the programmable device;
calculating a check value of the firmware data through a check value algorithm to obtain a corresponding second check value;
comparing the first check value with the second check value to obtain a corresponding comparison result;
and when the comparison result represents that the first check value is consistent with the second check value, sending a firmware loading instruction to the programmable device so that the programmable device loads a firmware program corresponding to the firmware data.
In the foregoing solution, the method further includes: when the comparison result represents that the first check value is inconsistent with the second check value, new firmware data is obtained; and upgrading the firmware data in the programmable device by using the new firmware data.
In the foregoing solution, the upgrading the firmware data in the programmable device by using the new firmware data includes: and sending the new firmware data to the programmable device so that the programmable device replaces the firmware data with the new firmware data to upgrade the firmware data.
In the above scheme, the method further comprises: obtaining a check value of the new firmware data; sending the obtained verification value to the programmable device, so that the programmable device stores the verification value as a first verification value corresponding to the new firmware data; and returning to execute the step of reading the firmware data and the corresponding first check value from the programmable device.
The embodiment of the present application further provides a firmware loading method, where the method is applied to a programmable device in communication connection with a CPU, and includes: acquiring firmware data and a corresponding first check value; responding to a data reading instruction sent by the CPU, transmitting the firmware data and a corresponding first check value to the CPU, so that the CPU calculates the check value of the firmware data through a check value algorithm to obtain a corresponding second check value, comparing the first check value with the second check value to obtain a corresponding comparison result, and sending a firmware loading instruction to the programmable device when the comparison result represents that the first check value is consistent with the second check value; and responding to the firmware loading instruction, and loading a firmware program corresponding to the firmware data.
In the above solution, the programmable device includes a main area and a data verification area, and the obtaining of the firmware data and the corresponding first verification value includes: and acquiring firmware data from the main area, and acquiring a first verification value corresponding to the firmware data from the data verification area.
In the foregoing solution, the programmable device further includes a spare area, and before the obtaining the firmware data and the corresponding first check value, the method further includes: when the programmable device is changed from a non-power-on state to a power-on state, obtaining original firmware data from the standby area; and loading a firmware program corresponding to the original firmware data.
An embodiment of the present application provides a firmware loading apparatus, including:
the reading module is used for reading the firmware data and the corresponding first check value from the programmable device;
the calculation module is used for calculating the check value of the firmware data through a check value algorithm to obtain a corresponding second check value;
the comparison module is used for comparing the first check value with the second check value to obtain a corresponding comparison result;
and the sending module is used for sending a firmware loading instruction to the programmable device when the comparison result represents that the first check value is consistent with the second check value, so that the programmable device loads a firmware program corresponding to the firmware data.
An embodiment of the present application further provides a firmware loading apparatus, including:
the acquisition module is used for acquiring firmware data and a corresponding first check value;
the transmission module is used for responding to a data reading instruction sent by a CPU (central processing unit), transmitting the firmware data and a corresponding first check value to the CPU so that the CPU calculates the check value of the firmware data through a check value algorithm to obtain a corresponding second check value, comparing the first check value with the second check value to obtain a corresponding comparison result, and sending a firmware loading instruction to the programmable device when the comparison result represents that the first check value is consistent with the second check value;
and the loading module is used for responding to the firmware loading instruction and loading the firmware program corresponding to the firmware data.
An embodiment of the present application provides an electronic device, including:
a memory for storing executable instructions;
and the processor is used for realizing the firmware loading method provided by the embodiment of the application when the executable instructions stored in the memory are executed.
The embodiment of the present application provides a computer-readable storage medium, which stores executable instructions for causing a processor to execute the method for loading firmware provided by the embodiment of the present application.
The embodiment of the application reads the firmware data and the corresponding first check value from the programmable device; calculating a check value of the firmware data through a check value algorithm to obtain a corresponding second check value; comparing the first check value with the second check value to obtain a corresponding comparison result; when the comparison result represents that the first check value is consistent with the second check value, a firmware loading instruction is sent to the programmable device, so that the programmable device loads a firmware program corresponding to the firmware data, that is, before the firmware data in the programmable device is loaded, the firmware data is verified, and only after the firmware data is verified, the programmable device loads the firmware data, so that the phenomenon that the system is hung up due to the fact that the programmable device loads the modified incomplete or damaged firmware data is avoided, and the stability and reliability of a communication system where the programmable device is located are improved.
Drawings
Fig. 1 is an alternative structural diagram of a firmware loading system according to an embodiment of the present application;
fig. 2 is an alternative structural schematic diagram of an electronic device 200 provided in the embodiment of the present application;
FIG. 3 is a schematic flowchart of an alternative firmware loading method according to an embodiment of the present disclosure;
FIG. 4 is a schematic flowchart of an alternative firmware loading method according to an embodiment of the present application;
FIG. 5 is a schematic flowchart of an alternative firmware loading method according to an embodiment of the present application;
FIG. 6 is a schematic flowchart of an alternative firmware loading method according to an embodiment of the present application;
FIG. 7 is an alternative flow chart illustrating steps prior to step 601 provided by embodiments of the present application;
fig. 8 is an alternative flowchart of a firmware loading method according to an embodiment of the present application.
Detailed Description
In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be described in further detail with reference to the attached drawings, the described embodiments should not be considered as limiting the present application, and all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.
In the following description, references to the terms "first \ second \ third" are only to distinguish similar objects and do not denote a particular order, but rather the terms "first \ second \ third" are used to interchange specific orders or sequences, where appropriate, so as to enable the embodiments of the application described herein to be practiced in other than the order shown or described herein.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the present application only and is not intended to be limiting of the application.
Before further detailed description of the embodiments of the present application, terms and expressions referred to in the embodiments of the present application will be described, and the terms and expressions referred to in the embodiments of the present application will be used for the following explanation.
In embedded development, a firmware program of a system is usually stored in a nonvolatile memory, and Flash has the basic characteristic of being used as a block storage device and capable of quickly reading and writing a large block of data, so that the Flash is suitable for being used as a firmware storage device of the system. The system can be updated quickly, and the online upgrading time of the system is reduced; meanwhile, the quick power-on starting can be realized, the power-on starting speed is improved, and the cold starting or reset starting time of the system is reduced, so that the service interruption time of the system is reduced.
The periphery of a part of programmable chips in the market is required to be connected to a Flash circuit on a nonvolatile memory, and the loading or upgrading of the firmware of the programmable device is realized by the CPU through the read-write control of the CPU on the external Flash of the programmable device;
the non-volatile memory Flash is integrated in some programmable devices, so that the peripheral circuit of the programmable devices is reduced, and the area of a circuit board is reduced; upgrading Flash inside the programmable device requires that a CPU firstly communicates with the programmable device, the programmable chip writes an upgrading file into the internal Flash, and once the Flash upgrading fails, the programmable device can not be started, the CPU can not carry out upgrading operation on the programmable device again; the burn can be performed only through the JTAG interface of the programmable device, and the reliability of the system is seriously influenced.
Based on this, embodiments of the present application provide a firmware loading method, apparatus, electronic device, and computer-readable storage medium, which can improve stability and reliability of a communication system in which a programmable device is located.
First, a firmware loading system provided in an embodiment of the present application is described, referring to fig. 1, where fig. 1 is an optional structural schematic diagram of the firmware loading system provided in the embodiment of the present application, and a CPU101 is connected to a programmable device 103 through a Low pin count Bus (LPC) 102. The CPU101 includes a check value algorithm module 1011 and a cache module 1012. The programmable device 103 includes a Flash read-write control module 1031, a firmware selection module 1032, and a Flash memory 1033. The verification value algorithm module 1011 is configured to calculate a verification value for the firmware data; the cache module is used for storing firmware data for upgrading of the programmable device; the Flash read-write control module is used for interface conversion and writing the firmware data issued by the CPU into Flash according to the read-write time sequence of the Flash; and the firmware selection module is used for selecting to load the firmware data in the main area or the spare area into the programmable device. Flash memory 1033 is embedded within programmable device 103 and includes: main area 10331, data check area 10332, spare area 10333, and reserved area 10334. The main area 10331 is used for storing firmware data of the programmable device, which can be upgraded, the spare area 10333 is used for storing original firmware data of the programmable device, the data verification area 10332 is used for storing a verification value corresponding to the firmware data in the main area 10331, and the reserved area 10334 is a reserved area and used for storing data of a new developed function.
Next, an electronic device for implementing the firmware loading method provided in the embodiment of the present application is described, referring to fig. 2, fig. 2 is an optional structural schematic diagram of the electronic device 200 provided in the embodiment of the present application, and in practical applications, the electronic device 200 may be implemented as the CPU101 or the programmable device 103 in fig. 1, and the electronic device implementing the firmware loading method according to the embodiment of the present application is described by taking the electronic device as the CPU101 shown in fig. 1 as an example. The electronic device 200 shown in fig. 2 includes: at least one processor 201 and memory 202. The various components in the electronic device 200 are coupled together by a bus system 203. It will be appreciated that the bus system 203 is used to enable communications among the components. The bus system 203 includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, however, the various buses are labeled as bus system 203 in fig. 2.
The Processor 201 may be an integrated circuit chip having Signal processing capabilities, such as a general purpose Processor, a Digital Signal Processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like, wherein the general purpose Processor may be a microprocessor or any conventional Processor, or the like.
The memory 202 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, and the like. Memory 202 optionally includes one or more storage devices physically located remotely from processor 201.
The memory 202 includes volatile memory or nonvolatile memory, and may include both volatile and nonvolatile memory. The nonvolatile Memory may be a Read Only Memory (ROM), and the volatile Memory may be a Random Access Memory (RAM). The memory 202 described in embodiments herein is intended to comprise any suitable type of memory.
In some embodiments, memory 202 is capable of storing data, examples of which include programs, modules, and data structures, or a subset or superset thereof, in order to support various operations, in embodiments of the present application, operating system 2021 and firmware loader 2022 are stored in memory 202; in particular, the amount of the solvent to be used,
an operating system 2021 including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
in some embodiments, the firmware loading apparatus provided in this embodiment of the present application may be implemented in software, and fig. 2 illustrates a firmware loading apparatus 2022 stored in the memory 202, which may be software in the form of programs and plug-ins, and includes the following software modules: a reading module 20221, a calculating module 20222, a comparing module 20223 and a sending module 20224, which are logical and thus may be arbitrarily combined or further divided according to the functions implemented. The functions of the respective modules will be explained below.
In other embodiments, the firmware loading apparatus provided in the embodiments of the present Application may be implemented in hardware, and as an example, the firmware loading apparatus provided in the embodiments of the present Application may be a processor in the form of a hardware decoding processor, which is programmed to execute the firmware loading method provided in the embodiments of the present Application, for example, the processor in the form of the hardware decoding processor may be one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field Programmable Gate Arrays (FPGAs), or other electronic components.
The firmware loading method provided by the embodiment of the present application will be described in conjunction with exemplary applications and implementations of a CPU provided by the embodiment of the present application.
Referring to fig. 3, fig. 3 is an alternative flowchart of a firmware loading method provided in an embodiment of the present application, which will be described with reference to the steps shown in fig. 3.
Step 301, reading firmware data and a corresponding first check value from a programmable device;
step 302, calculating a check value of the firmware data through a check value algorithm to obtain a corresponding second check value;
step 303, comparing the first check value with the second check value to obtain a corresponding comparison result;
step 304, when the comparison result indicates that the first check value is consistent with the second check value, a firmware loading instruction is sent to the programmable device, so that the programmable device loads a firmware program corresponding to the firmware data.
It should be noted that the embodiment of the present application is specifically directed to loading of firmware data of a Flash memory in a programmable device. The programmable device according to the embodiment of the present application may be a Field Programmable Gate Array (FPGA) device. In the embodiment of the application, before the firmware data is loaded in the Flash memory, the firmware data is verified, and only after the verification is passed, the firmware data is loaded in the programmable device. In actual implementation, the CPU reads the firmware data and the corresponding first check value from the programmable device. Here, the first verification value is stored in the programmable device in advance simultaneously with the firmware data. In an actual application scenario, the first check value may be calculated before being stored in the programmable device, and the programmable device stores the firmware data obtained at the same time and the first check value corresponding to the firmware data. Here, the first check value may be calculated by a check value algorithm. The Check value algorithm may be, for example, a Cyclic Redundancy Check (CRC) algorithm, a data accumulation and Check algorithm, or a hash algorithm. In the embodiment of the application, the first check value is obtained by calculating firmware data in advance through a check value algorithm. The programmable device stores the firmware data and the pre-calculated first check value.
It should be understood that when the firmware data is damaged in the storage process of the programmable device, the firmware data will be abnormal, and the check value obtained by calculating the check value of the changed firmware data through the check value algorithm will be different from the first check value. In the embodiment of the application, after the CPU reads the firmware data and the corresponding first check value from the programmable device, the check value algorithm module in the CPU calculates the check value of the read firmware data by using the check value algorithm, and the calculated check value is used as the second check value. And then, the CPU compares the first check value with the second check value, and when the first check value is consistent with the second check value, the firmware data in the programmable device is represented to be not damaged, and the CPU sends a firmware loading instruction to the programmable device. And after receiving the firmware loading instruction, the programmable device loads the firmware program corresponding to the stored firmware data through the firmware selection module.
In some embodiments, the programmable device includes a main area and a data verification area, the firmware data is stored in the main area, and a first verification value corresponding to the firmware data is stored in the data verification area. When the CPU sends a data reading instruction for acquiring the firmware data and the corresponding first check value to the programmable device, the Flash read-write control module of the programmable device responds to the data reading instruction, reads the firmware data from the main area of the programmable device, reads the first check value from the data check area, and then transmits the read firmware data and the corresponding first check value to the CPU.
In some embodiments, the programmable device further includes a spare area in which the original firmware data is stored. In practical implementation, when the programmable device is changed from a non-powered-on state to a powered-on state, that is, when the programmable device is just powered on, the Flash read-write control module of the programmable device reads original firmware data from the spare area, and directly loads a firmware program corresponding to the original firmware data through the firmware selection module. Meanwhile, the programmable device reads the firmware data from the main area and reads the first check value from the data check area to be transmitted to the CPU, the firmware data is checked by the CPU through the firmware data and the first check value, and after the check is passed, the programmable device loads the firmware data in the main area. The original firmware data is directly read from the standby area and loaded when the programmable device is just powered on, so that the firmware loading efficiency can be improved, meanwhile, the firmware data in the main area is verified, and the firmware data in the main area is loaded after the verification is passed, so that the accuracy of the loaded firmware can be ensured, and the stability and the reliability of the loaded firmware are guaranteed.
In some embodiments, referring to fig. 4, fig. 4 is an optional flowchart of the firmware loading method provided in the embodiment of the present application, and may further perform:
step 401, when the comparison result indicates that the first check value is inconsistent with the second check value, obtaining new firmware data;
and 402, upgrading the firmware data in the programmable device by using the new firmware data.
In actual implementation, when the first check value is inconsistent with the second check value, the firmware data in the programmable device is represented to be damaged, the CPU obtains new firmware data, and the firmware data in the programmable device is upgraded through the new firmware data. Here, the new firmware data is stored in advance in a cache module of the CPU, and the CPU obtains the new firmware data from the cache module.
In some embodiments, step 402 may also be implemented by: and sending the new firmware data to the programmable device so that the programmable device replaces the firmware data with the new firmware data to upgrade the firmware data.
In actual implementation, the CPU sends new firmware data to the programmable device, and the programmable device replaces the local firmware data with the new firmware data after receiving the new firmware data, so as to implement the upgrade processing of the firmware data.
In some embodiments, referring to fig. 5, fig. 5 is an optional flowchart of the firmware loading method provided in the embodiment of the present application, and after step 402, the following may be further performed:
step 501, obtaining a check value of the new firmware data;
step 502, sending the obtained verification value to the programmable device, so that the programmable device stores the verification value as a first verification value corresponding to the new firmware data;
step 503, return to execute step 301.
In actual implementation, after the CPU device upgrades the firmware data in the programmable device, the CPU continues to obtain the verification value of the new firmware data. Here, the check value of the new firmware data may be calculated by the check value algorithm module of the CPU using a check value algorithm to perform the check value calculation on the new firmware data. Specifically, the CPU calculates a check value of the new firmware data by using a check value algorithm through the check value algorithm module to obtain a check value corresponding to the new firmware data, and sends the calculated check value to the programmable device. And after receiving the check value corresponding to the new firmware data, the programmable device stores the received check value as a first check value corresponding to the new firmware data. Here, the programmable device stores new firmware data in the main area, and stores a first verification value corresponding to the new firmware data in the data verification area.
And then, the CPU continuously checks the new firmware data stored in the programmable device to ensure that the new firmware data is not damaged in the transmission and storage processes. Here, the CPU refers to steps 301 to 303 for verifying the new firmware data in the programmable device. In actual implementation, the CPU returns to execute step 301, and when the CPU calculates the check value of the read-back new firmware data to obtain a corresponding new second check value, the first check value corresponding to the new firmware data and the second check value corresponding to the new firmware data are continuously compared; when the firmware loading instruction and the firmware loading instruction are consistent, sending a firmware loading instruction to the programmable device so that the programmable device loads new firmware data stored in the main area; and when the firmware data and the firmware data are not consistent, the CPU continuously updates the new firmware data in the programmable device until the firmware data which is stored in the programmable device and is updated for the last time is verified by the CPU, and then the CPU controls the programmable device to load the firmware data which is updated for the last time.
The embodiment of the application reads the firmware data and the corresponding first check value from the programmable device; calculating a check value of the firmware data through a check value algorithm to obtain a corresponding second check value; comparing the first check value with the second check value to obtain a corresponding comparison result; when the comparison result represents that the first check value is consistent with the second check value, a firmware loading instruction is sent to the programmable device, so that the programmable device loads a firmware program corresponding to the firmware data, that is, before the firmware data in the programmable device is loaded, the firmware data is verified, and only after the firmware data is verified, the programmable device loads the firmware data, so that the phenomenon that the system is hung up due to the fact that the programmable device loads the modified incomplete or damaged firmware data is avoided, and the stability and reliability of a communication system where the programmable device is located are improved.
The firmware loading method provided by the embodiment of the present application is described below with reference to exemplary applications and implementations of the programmable device provided by the embodiment of the present application.
Referring to fig. 6, fig. 6 is an alternative flowchart of a firmware loading method provided in an embodiment of the present application, which will be described with reference to the steps shown in fig. 6.
Step 601, acquiring firmware data and a corresponding first check value;
step 602, in response to a data reading instruction sent by a CPU, transmitting the firmware data and a corresponding first check value to the CPU, so that the CPU calculates the check value of the firmware data through a check value algorithm to obtain a corresponding second check value, comparing the first check value with the second check value to obtain a corresponding comparison result, and sending a firmware loading instruction to the programmable device when the comparison result indicates that the first check value is consistent with the second check value;
step 603, in response to the firmware loading instruction, loading a firmware program corresponding to the firmware data.
In actual implementation, the programmable device locally obtains the firmware data and the first check value corresponding to the firmware data. Here, the programmable device specifically obtains corresponding firmware data from the main area, and obtains a first verification value corresponding to the firmware data from the data verification area. And then, when receiving a data reading instruction sent by the CPU, the programmable device responds to the data reading instruction and transmits the firmware data and the corresponding first check value to the CPU. After reading the firmware data and the corresponding first verification value, the CPU verifies the firmware data. The verification process of the firmware data by the CPU refers to the above embodiments, and is not described herein again.
And when the CPU passes the verification of the firmware data, namely the first verification value is consistent with the second verification value, the CPU sends a firmware loading instruction to the programmable device. And the programmable device receives a firmware loading instruction sent by the CPU and loads a firmware program corresponding to the firmware data.
In some embodiments, the programmable device includes a main region and a data verification region, and step 601 may be implemented as follows: and acquiring firmware data from the main area, and acquiring a first verification value corresponding to the firmware data from the data verification area.
Here, the manner of acquiring the firmware data and the first check value by the programmable device is referred to the above embodiments of the present application, and is not described herein again.
In some embodiments, referring to fig. 7, fig. 7 is an optional flowchart of steps before step 601 provided in an embodiment of the present application, and before step 601, the following may also be performed:
step 701, when the programmable device is changed from a non-powered state to a powered state, obtaining original firmware data from the spare area;
step 702, loading a firmware program corresponding to the original firmware data.
In this embodiment of the present application, before the programmable device loads the firmware data in the main area, steps 701 to 702 are further executed, that is, when the programmable device is just powered on, the firmware program corresponding to the original firmware data in the spare area is loaded. Here, the process of loading the original firmware data in the spare area by the programmable device is referred to the above embodiments of the present application, and is not described herein again. According to the embodiment of the application, the original firmware data is directly read from the standby area and loaded when the programmable device is just powered on, so that the firmware loading efficiency can be improved, meanwhile, the firmware data in the main area is verified, and the firmware data in the main area is loaded after the verification is passed, so that the accuracy of the loaded firmware can be ensured, and the stability and the reliability of the loaded firmware are guaranteed.
The embodiment of the application reads the firmware data and the corresponding first check value from the programmable device; calculating a check value of the firmware data through a check value algorithm to obtain a corresponding second check value; comparing the first check value with the second check value to obtain a corresponding comparison result; when the comparison result represents that the first check value is consistent with the second check value, a firmware loading instruction is sent to the programmable device, so that the programmable device loads a firmware program corresponding to the firmware data, that is, before the firmware data in the programmable device is loaded, the firmware data is verified, and only after the firmware data is verified, the programmable device loads the firmware data, so that the phenomenon that the system is hung up due to the fact that the programmable device loads the modified incomplete or damaged firmware data is avoided, and the stability and reliability of a communication system where the programmable device is located are improved.
In the following, an exemplary application of the embodiments of the present application in a practical application scenario will be described. Referring to fig. 8, fig. 8 is an alternative flowchart of a firmware loading method according to an embodiment of the present application, which will be described with reference to the steps shown in fig. 3.
Step 801, when the programmable device is powered on, loading original firmware data in the spare area.
In actual implementation, the programmable device loads the spare firmware program by default when powered on.
Step 802, the CPU obtains firmware data in a main area of a Flash memory in the programmable device and a check value A0 of a data check area.
In step 803, the CPU calculates a check value a1 corresponding to the firmware data through a check value algorithm module.
In practical implementation, the CPU communicates with the programmable device through the LPC bus to obtain firmware data in the main area and calculate a check value A1 through a check value algorithm module, and the original check value obtained from the data check area is A0
In step 804, the CPU determines whether the check value a1 matches the check value a0 in the data check area, and if so, executes step 805, and if not, executes step 806.
At step 805, the programmable device loads firmware data in the main region.
In step 806, the CPU determines that the firmware data in the main area is abnormal.
In step 807, the CPU upgrades the data in the main area and the corresponding check value.
In actual implementation, if a0 is consistent with a1, it is indicated that the firmware data in the main area is correct, and the programmable device loads the firmware data in the main area through the firmware selection module; and if the firmware data in the main area is abnormal if the A0 and the A1 are inconsistent, upgrading the firmware data in the main area. Specifically, the CPU controls a Flash read-write control module in the programmable device through an LPC bus to realize the upgrading of the original check values of the main area firmware and the data check area; after the upgrade is finished, the firmware data and the check value in the main area are read back again, the check value algorithm module of the CPU calculates the check value B1 of the read-back firmware data, the check value read back from the data check area is recorded as B0, if B0 and B1 are consistent, the firmware data in the main area after the upgrade is represented to be correct, and the firmware data in the main area is loaded through the firmware selection module; and if the B0 and the B1 are inconsistent, the upgraded firmware data in the main area is represented to be abnormal, and the firmware data upgrading processing of the main area is continued.
Step 808, return to performing step 802.
By adopting the method provided by the embodiment of the invention, the data in the main area of the Flash is damaged due to power failure in the upgrading process of the Flash of the programmable device or failure in upgrading and writing the Flash, or due to other external methods such as an emulator erasing the contents in the main area of the Flash, and the like. The embodiment of the application provides the functions of automatically detecting and judging whether the firmware data in the main area of the Flash is damaged or not and upgrading the firmware data in the main area of the Flash for multiple times, so that the reliability of the system is improved.
Continuing with the exemplary structure of the firmware loading apparatus 2022 implemented as software modules provided in this embodiment of the present application, in some embodiments, as shown in fig. 2, the software modules stored in the firmware loading apparatus 2022 of the memory 202 may include:
a reading module 20221, configured to read the firmware data and the corresponding first check value from the programmable device;
a calculating module 20222, configured to calculate a check value of the firmware data through a check value algorithm, so as to obtain a corresponding second check value;
a comparison module 20223, configured to compare the first check value and the second check value to obtain a corresponding comparison result;
the sending module 20224, when the comparison result indicates that the first check value is consistent with the second check value, sends a firmware loading instruction to the programmable device, so that the programmable device loads a firmware program corresponding to the firmware data.
In some embodiments, the firmware loading apparatus further comprises: the firmware upgrading module is used for obtaining new firmware data when the comparison result represents that the first check value is inconsistent with the second check value; and upgrading the firmware data in the programmable device by using the new firmware data.
In some embodiments, the firmware upgrade module is further configured to send the new firmware data to the programmable device, so that the programmable device replaces the firmware data with the new firmware data to upgrade the firmware data.
In some embodiments, the firmware upgrade module is further configured to obtain a check value of the new firmware data; sending the obtained verification value to the programmable device, so that the programmable device stores the verification value as a first verification value corresponding to the new firmware data; and returning to execute the step of reading the firmware data and the corresponding first check value from the programmable device.
Continuing to describe an exemplary structure of a firmware loading apparatus implemented as a software module according to an embodiment of the present application, the firmware loading apparatus according to the embodiment of the present application includes:
the acquisition module is used for acquiring firmware data and a corresponding first check value;
the transmission module is used for responding to a data reading instruction sent by the CPU, transmitting the firmware data and a corresponding first check value to the CPU so that the CPU calculates the check value of the firmware data through a check value algorithm to obtain a corresponding second check value, comparing the first check value with the second check value to obtain a corresponding comparison result, and sending a firmware loading instruction to the programmable device when the comparison result represents that the first check value is consistent with the second check value;
and the loading module is used for responding to the firmware loading instruction and loading the firmware program corresponding to the firmware data.
In some embodiments, the programmable device includes a main area and a data verification area, and the obtaining module is further configured to obtain firmware data from the main area and obtain a first verification value corresponding to the firmware data from the data verification area.
In some embodiments, the programmable device further comprises a spare area, and the firmware loading apparatus further comprises: the original firmware loading module is used for obtaining original firmware data from the standby area when the programmable device is changed from the non-powered state to the powered state; and loading a firmware program corresponding to the original firmware data.
It should be noted that the description of the apparatus in the embodiment of the present application is similar to the description of the method embodiment, and has similar beneficial effects to the method embodiment, and therefore, the description is not repeated.
Embodiments of the present application provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, so that the computer device executes the firmware loading method described in the embodiment of the present application.
Embodiments of the present application provide a computer-readable storage medium storing executable instructions, which, when executed by a processor, cause the processor to execute the firmware loading method provided by the embodiments of the present application.
In some embodiments, the computer-readable storage medium may be memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.
In some embodiments, the executable instructions may be in the form of a program, software module, script, or code written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages, and it may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
By way of example, executable instructions may correspond, but do not necessarily have to correspond, to files in a file system, and may be stored in a portion of a file that holds other programs or data, such as in one or more scripts in a hypertext Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code).
By way of example, executable instructions may be deployed to be executed on one computing device or on multiple computing devices at one site or distributed across multiple sites and interconnected by a communication network.
In summary, the embodiment of the present application can improve the stability and reliability of the communication system in which the programmable device is located.
The above description is only an example of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims (11)

1. A firmware loading method is applied to a Central Processing Unit (CPU) which is in communication connection with a programmable device, and comprises the following steps:
reading firmware data and a corresponding first check value from the programmable device;
calculating a check value of the firmware data through a check value algorithm to obtain a corresponding second check value;
comparing the first check value with the second check value to obtain a corresponding comparison result;
and when the comparison result represents that the first check value is consistent with the second check value, sending a firmware loading instruction to the programmable device so that the programmable device loads a firmware program corresponding to the firmware data.
2. The method of claim 1, further comprising:
when the comparison result represents that the first check value is inconsistent with the second check value, new firmware data is obtained;
and upgrading the firmware data in the programmable device by using the new firmware data.
3. The method of claim 2, wherein the upgrading the firmware data in the programmable device using the new firmware data comprises:
and sending the new firmware data to the programmable device so that the programmable device replaces the firmware data with the new firmware data to upgrade the firmware data.
4. The method of claim 2, further comprising:
obtaining a check value of the new firmware data;
sending the obtained check value to the programmable device, so that the programmable device stores the check value as a first check value corresponding to the new firmware data;
and returning to execute the step of reading the firmware data and the corresponding first check value from the programmable device.
5. A firmware loading method is applied to a programmable device which is in communication connection with a CPU, and comprises the following steps:
acquiring firmware data and a corresponding first check value;
responding to a data reading instruction sent by the CPU, transmitting the firmware data and a corresponding first check value to the CPU, so that the CPU calculates the check value of the firmware data through a check value algorithm to obtain a corresponding second check value, comparing the first check value with the second check value to obtain a corresponding comparison result, and sending a firmware loading instruction to the programmable device when the comparison result indicates that the first check value is consistent with the second check value;
and responding to the firmware loading instruction, and loading a firmware program corresponding to the firmware data.
6. The method of claim 5, wherein the programmable device comprises a main region and a data verification region, and the obtaining the firmware data and the corresponding first verification value comprises:
and acquiring firmware data from the main area, and acquiring a first verification value corresponding to the firmware data from the data verification area.
7. The method of claim 5, wherein the programmable device further comprises a spare area, and wherein prior to the obtaining the firmware data and the corresponding first check value, the method further comprises:
when the programmable device is changed from a non-power-on state to a power-on state, obtaining original firmware data from the standby area;
and loading a firmware program corresponding to the original firmware data.
8. An apparatus for loading firmware, the apparatus comprising:
the reading module is used for reading the firmware data and the corresponding first check value from the programmable device;
the calculation module is used for calculating the check value of the firmware data through a check value algorithm to obtain a corresponding second check value;
the comparison module is used for comparing the first check value with the second check value to obtain a corresponding comparison result;
and the sending module is used for sending a firmware loading instruction to the programmable device when the comparison result represents that the first check value is consistent with the second check value, so that the programmable device loads a firmware program corresponding to the firmware data.
9. An apparatus for loading firmware, the apparatus comprising:
the acquisition module is used for acquiring firmware data and a corresponding first check value;
the transmission module is used for responding to a data reading instruction sent by a CPU (central processing unit), transmitting the firmware data and a corresponding first check value to the CPU so that the CPU calculates the check value of the firmware data through a check value algorithm to obtain a corresponding second check value, comparing the first check value with the second check value to obtain a corresponding comparison result, and sending a firmware loading instruction to the programmable device when the comparison result represents that the first check value is consistent with the second check value;
and the loading module is used for responding to the firmware loading instruction and loading the firmware program corresponding to the firmware data.
10. An electronic device, comprising:
a memory for storing executable instructions;
a processor, configured to implement the firmware loading method of any one of claims 1 to 7 when executing the executable instructions stored in the memory.
11. A computer-readable storage medium storing executable instructions for implementing the firmware loading method of any one of claims 1 to 7 when executed by a processor.
CN202210272778.2A 2022-03-18 2022-03-18 Firmware loading method and device, electronic equipment and computer readable storage medium Pending CN114741091A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210272778.2A CN114741091A (en) 2022-03-18 2022-03-18 Firmware loading method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210272778.2A CN114741091A (en) 2022-03-18 2022-03-18 Firmware loading method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN114741091A true CN114741091A (en) 2022-07-12

Family

ID=82277110

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210272778.2A Pending CN114741091A (en) 2022-03-18 2022-03-18 Firmware loading method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN114741091A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116305169A (en) * 2023-05-12 2023-06-23 天津市中环电子计算机有限公司 Firmware security detection method and firmware verification method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116305169A (en) * 2023-05-12 2023-06-23 天津市中环电子计算机有限公司 Firmware security detection method and firmware verification method
CN116305169B (en) * 2023-05-12 2023-08-11 天津市中环电子计算机有限公司 Firmware security detection method and firmware verification method

Similar Documents

Publication Publication Date Title
EP1591893A1 (en) Method and system for fail-safe updating of boot code
US20150154092A1 (en) Bios maintenance method
CN111240720A (en) Boot program upgrading method and device and storage medium
CN106776122A (en) A kind of method of main-apparatus protection in start-up course based on Flash
CN113110891B (en) Firmware loading method and device for solid state disk, computer equipment and storage medium
CN108182078B (en) Optimized missile-borne device non-dismantling software online upgrading method
CN101807152A (en) Basic output and input system for self verification of selection read only memory and verification method thereof
CN108345464A (en) A kind of the startup method and Android vehicle device of Android system
CN108920168B (en) Bootloader method supporting simultaneous upgrading of multiple similar ECUs and having function of preventing program mismatching
CN111651304B (en) Software recovery method and device based on double-core intelligent ammeter and computer equipment
CN111562932B (en) High-reliability embedded software upgrading method and system
CN109634781A (en) One kind is based on embedded program two-region Backup Images system and starting method
CN112433769A (en) BMC starting method and device, computer equipment and storage medium
CN111897595A (en) Satellite housekeeping computer software starting and guiding method
CN114741091A (en) Firmware loading method and device, electronic equipment and computer readable storage medium
CN114895845A (en) EMmC data storage control method and embedded mainboard
CN114489732A (en) Method and device for updating FPGA (field programmable Gate array) firmware of equipment and electronic equipment
CN111273928B (en) Bootloader design method for self-upgrading
CN117130672A (en) Server start flow control method, system, terminal and storage medium
CN116795408A (en) ECU software upgrading method and system and vehicle
CN104636574A (en) Terminal device upgrade method and terminal device
CN113377425A (en) BMC firmware generation method and device, BMC starting method and device and storage medium
CN111783162A (en) Data protection implementation method and device and computer equipment
CN112925542B (en) Test method for supporting silent upgrading of wireless router
US11048521B2 (en) Resilient upgradable boot loader with power reset

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