CN113254048B - Method, device and equipment for updating boot program and computer readable medium - Google Patents

Method, device and equipment for updating boot program and computer readable medium Download PDF

Info

Publication number
CN113254048B
CN113254048B CN202110682819.0A CN202110682819A CN113254048B CN 113254048 B CN113254048 B CN 113254048B CN 202110682819 A CN202110682819 A CN 202110682819A CN 113254048 B CN113254048 B CN 113254048B
Authority
CN
China
Prior art keywords
program
bootstrap
boot
update
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.)
Active
Application number
CN202110682819.0A
Other languages
Chinese (zh)
Other versions
CN113254048A (en
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.)
Shenzhilan Tianjin Underwater Intelligent Technology Co ltd
Original Assignee
Shenzhilan Tianjin Underwater 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 Shenzhilan Tianjin Underwater Intelligent Technology Co ltd filed Critical Shenzhilan Tianjin Underwater Intelligent Technology Co ltd
Priority to CN202110682819.0A priority Critical patent/CN113254048B/en
Publication of CN113254048A publication Critical patent/CN113254048A/en
Application granted granted Critical
Publication of CN113254048B publication Critical patent/CN113254048B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1433Saving, restoring, recovering or retrying at system level during software upgrading

Landscapes

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

Abstract

The application relates to a bootstrap program updating method, a bootstrap program updating device, a bootstrap program updating equipment and a computer readable medium. The method comprises the following steps: starting a second bootstrap program under the condition that the first bootstrap program detects the update identification of the bootstrap program; in the second bootstrap program, receiving program data of a third bootstrap program, and updating a target application program by using the program data of the third bootstrap program as an update file, wherein the third bootstrap program carries a bootstrap program update file, the bootstrap program update file comprises an update file of the first bootstrap program and/or the second bootstrap program, and the third bootstrap program is used for updating the first bootstrap program and/or the second bootstrap program; the updated target application is executed to update the first boot program using the update file of the first boot program and/or update the second boot program using the update file of the second boot program. The method and the device solve the technical problems of complex bootloader upgrading process and low security.

Description

Method, device and equipment for updating boot program and computer readable medium
Technical Field
The present application relates to the field of embedded technologies, and in particular, to a method, an apparatus, a device, and a computer-readable medium for updating a bootstrap program.
Background
An embedded MCU (Microcontroller Unit ) bootloader is used as a boot program for starting and running the MCU, and is responsible for upgrading the firmware of the application program, but a bug existing in the bootloader program may seriously affect the normal running of the MCU, so the bootloader program also faces the requirement of upgrading and updating.
At present, in the related art, the scheme for upgrading the bootloader is complicated, and configuration parameters and system operation data are easily lost, so that downtime is easily caused.
Aiming at the problems of complicated bootloader upgrading process and low security, an effective solution is not provided at present.
Disclosure of Invention
The application provides a bootstrap program updating method, a bootstrap program updating device, a bootstrap program updating equipment and a computer readable medium, and aims to solve the technical problems of complex bootloader upgrading process and low security.
According to an aspect of an embodiment of the present application, there is provided a bootstrap update method, including:
under the condition that the first bootstrap program detects a bootstrap program updating identifier, starting a second bootstrap program, wherein the first bootstrap program is used for guiding the microcontroller to start and determining an execution program to be jumped, the second bootstrap program is used for updating an application program of the microcontroller, and the application program is used for recording control services provided by the microcontroller;
in the second bootstrap program, receiving program data of a third bootstrap program, and updating a target application program by using the program data of the third bootstrap program as an update file, wherein the third bootstrap program carries a bootstrap program update file, the bootstrap program update file comprises an update file of the first bootstrap program and/or the second bootstrap program, and the third bootstrap program is used for updating the first bootstrap program and/or the second bootstrap program;
the updated target application is executed to update the first boot program using the update file of the first boot program and/or update the second boot program using the update file of the second boot program.
Optionally, the program data of the first boot program is stored in the first partition, the program data of the second boot program is stored in the second partition, and the first partition and the second partition are boot program areas; in the event that the first boot program detects a boot program update identification, initiating a second boot program comprises:
extracting program data of a second bootstrap program from the second partition, and acquiring a first original check code of the program data of the second bootstrap program, wherein the first original check code is generated after the second bootstrap program is encoded, and the first original check code is stored in a check code storage sector in the second partition;
determining a first current check code of program data of a second bootstrap program;
and starting a second bootstrap program under the condition that the first current check code is consistent with the first original check code.
Optionally, program data of the target application program is stored in a third partition, the third partition is an application program area, and both the bootstrap program area and the application program area are sectors in the first buffer; in the second boot program, receiving the program data of the third boot program, and updating the program data of the third boot program as the update file update target application program includes:
receiving program data of a third bootstrap program, and transferring the program data of the third bootstrap program to a first backup area, wherein the first backup area is a sector in a second cache;
after the program data of the third bootstrap program is transferred, erasing the original data of the target application program stored in the third partition;
and copying the program data of the third bootstrap program in the first backup area to the third partition so as to update the target application program.
Optionally, after the target application is updated, the method further includes:
extracting the updated program data of the target application program from the third partition, and acquiring a second original check code of the program data of the third bootstrap program, wherein the second original check code is generated after the third bootstrap program is encoded, and the second original check code is stored in a check code storage sector in the third partition;
determining a second current check code of the program data of the updated target application program;
and under the condition that the second current check code is consistent with the second original check code, transmitting a normal starting identifier to the first bootstrap program, and restarting the first bootstrap program.
Optionally, executing the updated target application to update the first boot program with the update file of the first boot program, and/or updating the second boot program with the update file of the second boot program includes:
under the condition that the first bootstrap program detects a normal starting identifier, starting an updated target application program, wherein the updated target application program is used for realizing the preset function of a third bootstrap program;
copying the original data of the first bootstrap program stored in the first partition to a second backup area in the updated target application program, wherein the second backup area is a sector in a second cache;
after the backup is finished, erasing the original data stored in the first partition;
copying an update file of the first bootstrap program to the first partition so as to update the first bootstrap program;
and/or the presence of a gas in the gas,
under the condition that the first bootstrap program detects a normal starting identifier, starting an updated target application program, wherein the updated target application program is used for realizing the preset function of a third bootstrap program;
copying the original data of the second bootstrap program stored in the second partition to a third backup area in the updated target application program, wherein the third backup area is a sector in the second cache;
after the backup is finished, erasing the original data stored in the second partition;
and copying the update file of the second bootstrap program to the second partition so as to update the second bootstrap program.
Optionally, after the first boot program is updated and/or the second boot program is updated, the method further includes:
extracting the updated program data of the first bootstrap program from the first partition, and acquiring a third original check code of the update file of the first bootstrap program, wherein the third original check code is generated after the update file of the first bootstrap program is encoded, and the third original check code is stored in a check code storage sector in the first partition;
determining a third current check code of the updated program data of the first bootstrap program;
under the condition that the third current check code is consistent with the third original check code, determining that the first bootstrap program is successfully updated;
and/or the presence of a gas in the gas,
extracting the updated program data of the second bootstrap program from the second partition, and acquiring a fourth original check code of the update file of the second bootstrap program, wherein the fourth original check code is generated after the encoding of the update file of the second bootstrap program is completed, and the fourth original check code is stored in a check code storage sector in the second partition;
determining a fourth current check code of the updated program data of the second bootstrap program;
and under the condition that the fourth current check code is consistent with the fourth original check code, determining that the second bootstrap program is successfully updated.
Alternatively,
under the condition that the process of receiving the program data of the third bootstrap program is interrupted, transmitting a transmission failure identifier to the first bootstrap program, so that when the first bootstrap program detects the transmission failure identifier, starting the second bootstrap program to renew the target application program;
under the condition that the process of copying the program data of the third bootstrap program in the first backup area to the third partition is interrupted and/or the verification of the updated target application program is failed, sending a first update failure identifier to the first bootstrap program, so that when the first bootstrap program detects the first update failure identifier, starting a second bootstrap program to update the target application program again;
under the condition that the process of copying the original data of the first bootstrap program stored in the first partition to the second backup area is interrupted and/or the verification of the updated first bootstrap program fails, recovering the original data of the first bootstrap program from the second backup area, and sending a second update failure identifier to the first bootstrap program so as to execute the original first bootstrap program and redirect the target application program to update the first bootstrap program;
and under the condition that the process of copying the original data of the second bootstrap program stored in the second partition to the third backup area is interrupted and/or the verification of the updated second bootstrap program fails, sending a third update failure identifier to the first bootstrap program so as to execute the first bootstrap program and redirect the target application program to update the second bootstrap program.
According to another aspect of the embodiments of the present application, there is provided a bootstrap updating apparatus, including:
the starting module is used for starting a second bootstrap program under the condition that the first bootstrap program detects a bootstrap program updating identifier, the first bootstrap program is used for guiding the microcontroller to start and determining an executive program to be jumped, the second bootstrap program is used for updating an application program of the microcontroller, and the application program is used for recording control services provided by the microcontroller;
the application program updating module is used for receiving program data of a third bootstrap program in the second bootstrap program and updating the target application program by taking the program data of the third bootstrap program as an updating file, the third bootstrap program carries a bootstrap program updating file, the bootstrap program updating file comprises an updating file of the first bootstrap program and/or the second bootstrap program, and the third bootstrap program is used for updating the first bootstrap program and/or the second bootstrap program;
and the bootstrap program reverse updating module is used for executing the updated target application program so as to update the first bootstrap program by using the update file of the first bootstrap program and/or update the second bootstrap program by using the update file of the second bootstrap program.
According to another aspect of the embodiments of the present application, there is provided an electronic device, including a memory, a processor, a communication interface, and a communication bus, where the memory stores a computer program executable on the processor, and the memory and the processor communicate with each other through the communication bus and the communication interface, and the processor implements the steps of the method when executing the computer program.
According to another aspect of embodiments of the present application, there is also provided a computer readable medium having non-volatile program code executable by a processor, the program code causing the processor to perform the above-mentioned method.
Compared with the related art, the technical scheme provided by the embodiment of the application has the following advantages:
the method and the device have the technical scheme that under the condition that a first bootstrap program detects a bootstrap program updating identifier, a second bootstrap program is started, the first bootstrap program is used for guiding the microcontroller to start and determining an executive program to be jumped, the second bootstrap program is used for updating an application program of the microcontroller, and the application program is used for recording control services provided by the microcontroller; in the second bootstrap program, receiving program data of a third bootstrap program, and updating a target application program by using the program data of the third bootstrap program as an update file, wherein the third bootstrap program carries a bootstrap program update file, the bootstrap program update file comprises an update file of the first bootstrap program and/or the second bootstrap program, and the third bootstrap program is used for updating the first bootstrap program and/or the second bootstrap program; the updated target application is executed to update the first boot program using the update file of the first boot program and/or update the second boot program using the update file of the second boot program. The method and the device do not need to set a plurality of guide programs and a plurality of application programs to update the target guide program, only one application program needs to be upgraded into a virtual guide program to reversely upgrade the target guide program, the safety is improved while the flow is simplified, the cost is reduced, the method and the device can be deployed in microcontrollers of various scales, the technical problems that the bootloader upgrading flow is complex and the safety is low are solved, the bootloader0 is updated to enable the bootloader0 to be adaptive to and matched with newly expanded partitions and the functions added by the partitions, the occurrence of directional errors is avoided, and the occurrence of unknown errors is effectively reduced.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the technical solutions in the embodiments or related technologies of the present application, the drawings needed to be used in the description of the embodiments or related technologies will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without any creative effort.
Fig. 1 is a flowchart of an alternative boot program update method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of an optional Flash partition provided according to an embodiment of the present application;
FIG. 3 is a flow chart illustrating an alternative boot validity check according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating an alternative application update process provided in accordance with an embodiment of the present application;
FIG. 5 is a flowchart illustrating an alternative application validity check according to an embodiment of the present application;
FIG. 6 is a flowchart illustrating an alternative first bootstrap update process provided in accordance with an embodiment of the present application;
FIG. 7 is a flowchart illustrating an alternative second bootstrap update process provided in accordance with an embodiment of the present application;
FIG. 8 is a flowchart illustrating an alternative first boot validity check process according to an embodiment of the present application;
FIG. 9 is a flow chart illustrating an alternative second bootstrap validity check provided in accordance with an embodiment of the present application;
FIG. 10 is a block diagram of an alternative boot update apparatus according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of an alternative electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the following description, suffixes such as "module", "component", or "unit" used to denote elements are used only for the convenience of description of the present application, and have no specific meaning in themselves. Thus, "module" and "component" may be used in a mixture.
In the related art, the scheme for upgrading the bootloader is complicated, and configuration parameters and system operation data are easily lost, so that downtime is easily caused.
Prior art solutions generally fall into the following categories:
the bootloader + app mode is suitable for small-sized mcus, and has the defects that upgrading needs to be carried out again when upgrading fails, and safe upgrading of the bootloader cannot be guaranteed;
in the bootloader + app + bank mode, safe upgrade of the bootloader cannot be guaranteed;
the bootloader + app1+ app2 mode can ensure that the upgrading of the apps can be started from another app after the apps fail to be upgraded;
the bootloader1+ bootloader2+ app1 mode (both bootloader1 and bootloader2 can be used as boot programs of the mcu, and the functions are complementary), and the scheme is suitable for the mcu with large-space flash, and is high in cost and tedious to implement;
the bootloader1+ bootloader2+ app1+ app2 mode is suitable for the mcu with large space flash, and is high in cost and cumbersome to implement.
Therefore, bootloader upgrading with low cost, easy implementation, high safety and simple flow is urgently needed.
To solve the problems mentioned in the background, according to an aspect of embodiments of the present application, an embodiment of a bootstrap update method is provided.
Optionally, in this embodiment of the present application, the above boot program update method may be executed by a microcontroller, and as shown in fig. 1, the method may include the following steps:
step S102, under the condition that the first bootstrap program detects the update identification of the bootstrap program, starting a second bootstrap program, wherein the first bootstrap program is used for guiding the microcontroller to start and determining the execution program to be jumped, the second bootstrap program is used for updating the application program of the microcontroller, and the application program is used for recording the control service provided by the microcontroller.
The Bootloader is used as a bootstrap program for starting and running the embedded MCU, and is also responsible for upgrading the application program.
In this embodiment of the application, the first boot program may be used as a boot program for starting and running the embedded MCU, and may be denoted as bootloader0, and the second boot program may be responsible for upgrading an application program, and may be denoted as bootloader 1. The bootstrap update identifier is used to indicate to update bootloader0 and/or bootloader1, that is, in the technical solution of the present application, the bootstrap program started and run by the embedded MCU may be updated, and a second bootstrap program used to update the application program may also be updated.
In the prior art, the bootloader0 program cannot be upgraded, because the bootloader0 program only serves as a function of guiding jump to a target partition and recovering firmware, and other functions cannot be added to the program. However, as the partition expansion and bootloader1, function iteration of the application program, the original bootloader0 program inevitably has directional errors or other unknown errors, so in order to match the partition expansion and function iteration in time, and also in order to reduce the occurrence of unknown errors, the bootloader0 program needs to be updated.
The bootstrap update identification can be sent to the microcontroller by the developer after the update files of the first bootstrap program and the second bootstrap program are coded. After the microcontroller receives the boot loader update identifier, at the next power-on or user-specified time, the first boot loader0 detects the boot loader update identifier, and the first boot loader0 directs the execution of the second boot loader1 instead of the application app, thereby starting the update procedure of the boot loader.
Step S104, in the second boot program, receiving program data of a third boot program, and updating the target application program with the program data of the third boot program as an update file, where the third boot program carries a boot program update file, the boot program update file includes an update file of the first boot program and/or the second boot program, and the third boot program is used to update the first boot program and/or the second boot program.
In the embodiment of the present application, in the process of booting from the first boot loader0 to the second boot loader1, the second boot loader1 waits for an update command of the upper computer. After the second boot loader1 receives the update instruction and returns an instruction message ready for updating in response to the update instruction, the upper computer sends program data of the third boot program to the microcontroller. Since the second boot loader1 is used to upgrade the application app in the microcontroller, the second boot loader1 updates the target application program by using the program data of the third boot program as an update file of the application app. And the third boot program carries the update file of the first boot loader0 and/or the second boot loader1, and the third boot program is used for updating the first boot loader0 and/or the second boot loader1, so that the function of the target application program after updating is replaced by the function of the third boot program, namely the first boot loader0 and/or the second boot loader1 are/is updated, and the target application program is changed into a virtual boot program.
And step S106, executing the updated target application program to update the first bootstrap program by using the update file of the first bootstrap program and/or update the second bootstrap program by using the update file of the second bootstrap program.
In the embodiment of the present application, after the target application is updated, the function of the target application is replaced with the function of the third boot program, so that the target application becomes a virtual boot program, and at this time, the target application can be executed to update the first boot loader0 and/or the second boot loader 1.
By adopting the technical scheme, a plurality of boot programs and a plurality of application programs are not required to be set to update the target boot program, only one application program needs to be upgraded into a virtual boot program to reversely upgrade the target boot program, the process is simplified, the safety is improved, the cost is reduced, the method can be deployed in microcontrollers of various scales, the technical problems that the bootloader upgrading process is complex and the safety is low are solved, the bootloader0 is updated to enable the bootloader0 to be adaptive to and matched with newly-expanded partitions and the functions added by the partitions, the occurrence of directional errors is avoided, and the occurrence of unknown errors is effectively reduced.
Optionally, the program data of the first boot program is stored in the first partition, the program data of the second boot program is stored in the second partition, and the first partition and the second partition are boot program areas.
In the embodiment of the present application, as shown in fig. 2, the program data of the first boot loader0 is stored in the first partition, i.e., the boot loader0 area, and the program data of the second boot loader1 is stored in the second partition, i.e., the boot loader1 area. When the microcontroller is powered on and started, the program data in the bootloader0 area is loaded first, so as to execute the first boot loader0, and the first boot loader0 boots the microcontroller to load the program data in the bootloader1 area according to the boot loader update identifier, so as to execute the second boot loader. The bootloader0 area and bootloader1 area are boot program areas.
As shown in fig. 3, the step S102, in the case that the first boot program detects the boot program update identifier, starting the second boot program may include the following steps:
step S302, extracting the program data of the second boot program from the second partition, and obtaining a first original check code of the program data of the second boot program, where the first original check code is generated after the second boot program is encoded, and the first original check code is stored in a check code storage sector in the second partition.
In this embodiment, for the stability and safe operation of the system, the first boot loader0 needs to perform validity check on the second boot loader1 before the boot microcontroller loads the boot loader1 area to execute the second boot loader 1. First, program data of the second boot program is extracted from the bootloader1 area, and the first raw check code of the second boot program is obtained from the bootloader1 area. The first original check code is generated after the developer completes the coding of the second bootstrap program and is used for identifying the original code data of the second bootstrap program.
In step S304, a first current check code of the program data of the second boot program is determined.
In this embodiment, the program data extracted from the bootloader1 area is used to calculate the first current check code of the bootloader1, where the first current check code is the identifier of the current program data of the bootloader 1.
Step S306, starting a second boot program when the first current check code is consistent with the first original check code.
In the embodiment of the application, the first current check code and the first original check code of the second boot program are compared, and the two check codes are consistent, which indicates that the second boot program is the same as the original code and is not tampered, and indicates that the current second boot program is valid. At this time, the first boot loader0 can boot the microcontroller to load the program data in the boot loader1 area, thereby starting the second boot loader 1.
In this embodiment, the program data in the bootloader1 area may be backed up in another buffer independent from the microcontroller, so that when the bootloader1 is invalid, the backed-up bootloader1 program data is extracted from the corresponding buffer to ensure that the system can operate normally in an emergency.
Optionally, the program data of the target application program is stored in a third partition, the third partition is an application program area, and the bootstrap program area and the application program area are sectors in the first buffer.
In the embodiment of the present application, as shown in fig. 2, the program data of the target application program is stored in the third partition, i.e., the APP application program area, and both the boot program area and the application program area in the figure are cache sectors in the microcontroller, i.e., sectors in the first cache.
As shown in fig. 4, the step S104, in the second boot program, of receiving the program data of the third boot program, and updating the program data of the third boot program as the update file update target application program includes the steps of:
step S402, receiving the program data of the third boot program, and transferring the program data of the third boot program to the first backup area, where the first backup area is a sector in the second buffer.
In this embodiment of the application, after the bootloader1 of the second boot program is started, the bootloader1 waits for an update instruction of the upper computer. After the bootloader1 receives the update instruction and returns an instruction message ready for updating in response to the update instruction, the upper computer sends program data of the third boot program to the microcontroller. The bootloader1 transfers the program data of the third boot program to a first backup area, as shown in fig. 2, the first backup area may be a backup 1 area in the figure, which is used to temporarily store and backup the program data of the third boot program, and the buffer in which the backup 1 area is located is another buffer separate from the buffer of the microcontroller, i.e. an off-chip Flash partition, so that when the microcontroller encounters a data loss, the corresponding data can be extracted from the backup area for use.
In step S404, after the program data of the third boot program is completely transferred, the original data of the target application program stored in the third partition is erased.
In this embodiment of the present application, after the backup is completed, bootloader1 erases the data in the APP application area, thereby freeing up a data storage space for the upgrade target application.
Step S406, copying the program data of the third boot program in the first backup area to the third partition, so as to update the target application program.
In this embodiment of the application, after the bootloader1 erases the data in the APP application area, the program data of the third boot program stored in the backup 1 area may be copied to the APP application area, so as to upgrade the target application program to a virtual boot program (virtual bootloader).
In this embodiment of the present application, before executing an updated target application (virtual bootloader), a third boot program stored in an APP application region needs to be compiled to generate a bin file, and then the bin file is converted into an array, and the array is defined in a data region of the target application, so as to obtain the virtual bootloader.
Optionally, if an unexpected situation such as failure of erasing the original data of the APP application area, failure of copying the program data of the third boot program, process interruption, etc. occurs, the microcontroller may be restarted, and after the bootloader0 is executed, the bootloader0 directs to the bootloader1, the bootloader1 erases the original data of the APP application area again, and copies the program data of the third boot program to the APP application area again, thereby upgrading the target application program to the virtual boot program.
After the target application program is upgraded to the virtual bootloader, in order to ensure the stability and safe operation of the system, validity check needs to be performed on the upgraded target application program, i.e., the virtual bootloader.
Optionally, as shown in fig. 5, after the target application is updated, the method further includes:
step S502, extracting the updated program data of the target application program from the third partition, and obtaining a second original check code of the program data of the third boot program, where the second original check code is generated after the third boot program is encoded, and the second original check code is stored in a check code storage sector in the third partition.
In this embodiment of the present application, when validity check is performed on an upgraded target application, that is, a virtual bootloader, first, program data of a current target application (that is, program data of a third boot program) is extracted from an APP application area, and a second original check code of the third boot program is obtained from the APP application area. The second original check code is generated after the developer completes the encoding of the third bootstrap program and is used for identifying the original code data of the third bootstrap program.
Step S504, determining a second current check code of the updated program data of the target application program.
In this embodiment of the present application, a second current check code of a current target application (a third boot program) is calculated by using program data extracted from an APP application area, where the second current check code is an identifier of current program data of the third boot program.
Step S506, when the second current check code is consistent with the second original check code, transmitting a normal start identifier to the first boot program, and restarting the first boot program.
In the embodiment of the application, the second current check code and the second original check code of the third boot program are compared, and the two check codes are consistent, which indicates that the third boot program is the same as the original code and is not tampered, and indicates that the current third boot program is valid. At this time, the second boot loader1 sends a normal boot flag to the first boot loader0, and boots the microcontroller to restart the first boot loader0, and when the first boot loader0 is restarted, software reset is required.
When the bootloader0 re-executes the first boot program, the bootloader0 detects the normal boot flag, so as to boot the microcontroller to load the program data of the APP application program area, and then execute the updated target application program.
Optionally, as shown in fig. 6, executing the updated target application to update the first boot program with the update file of the first boot program includes the following steps:
step S602, when the first bootstrap program detects a normal start identifier, start an updated target application program, where the updated target application program is used to implement a preset function of the third bootstrap program.
In this embodiment of the application, when the bootloader0 of the first boot program is re-executed, the bootloader0 detects the normal start identifier, so as to boot the microcontroller to load the program data of the APP application program area, and then execute the updated target application program. The updated target application program actually realizes the preset function of the third boot program, and at this time, the third boot program carries the update file of the first boot program, that is, the third boot program is used to update the first boot program, and at this time, the target application program actually becomes the virtual bootloader.
In step S604, in the updated target application, the original data of the first boot program stored in the first partition is copied to a second backup area, where the second backup area is a sector in the second buffer.
In this embodiment, the virtual bootloader first backs up the original data of the bootloader0 stored in the bootloader0 area to the second backup area, so that when the update of the bootloader0 fails, the original data of the bootloader0 can be recovered from the second backup area, and the system is prevented from being unable to operate. As shown in fig. 2, the second backup area may be a backup 2 area in the figure, which is used to temporarily store and backup the original data of the first boot program, and the buffer in which the backup 2 area is located is another buffer that is separate from the buffer of the microcontroller, i.e., an off-chip Flash partition, so that when the microcontroller encounters a data loss, the corresponding data can be extracted from the backup area for use. In the off-chip Flash partition, an equipment information area can be further arranged and used for storing the running information of the microcontroller, and an upgrading state area is arranged and used for recording the upgrading states of the application program and the bootstrap program.
Step S606, after the backup is completed, the original data stored in the first partition is erased.
In the embodiment of the application, after the backup is completed, the virtual bootloader erases the data in the bootloader0 area, thereby freeing up a data storage space for upgrading the bootloader 0.
In step S608, the update file of the first boot program is copied to the first partition, so as to update the first boot program.
In this embodiment of the application, after the virtual bootloader erases the data in the bootloader0 area, the update file of the first boot program carried by the virtual bootloader may be copied to the bootloader0 area, so as to update the bootloader 0.
Optionally, if an unexpected situation occurs, such as failure to erase original data in the bootloader0 area, failure to copy an update file of the first boot program, process interruption, etc., the microcontroller may be restarted, where data in the bootloader0 area is damaged and the bootloader0 cannot be started, and in order to ensure normal system startup, the microcontroller may directly load data in the bootloader1 area, so as to directly start with the bootloader1, and continuously wait for an update instruction in the bootloader1, so as to update the bootloader0 again. The microcontroller may also load data from the spare boot area to boot up, waiting for the update instruction to update bootloader0 again. When bootloader0 is updated again, bootloader1 or other spare boot program guides the execution of the virtual bootloader, which backs up and erases the original data in bootloader0 again, and copies the update file of bootloader0 to bootloader0 again, and then updates bootloader 0. Alternatively, bootloader0 update may be interrupted to ensure system security, i.e. bootloader1 or other spare boot program may restore the original data of bootloader0 from the second backup area, so that the microcontroller may start normally from bootloader0 at the next power-on start.
Optionally, as shown in fig. 7, executing the updated target application to update the second boot program with the update file of the second boot program includes the following steps:
step S702, starting the updated target application program when the first boot program detects the normal start identifier, where the updated target application program is used to implement the preset function of the third boot program.
In this embodiment of the application, when the bootloader0 of the first boot program is re-executed, the bootloader0 detects the normal start identifier, so as to boot the microcontroller to load the program data of the APP application program area, and then execute the updated target application program. The updated target application program actually realizes the preset function of the third boot program, and at this time, the third boot program carries the update file of the second boot program, that is, the third boot program is used for updating the second boot program, and at this time, the target application program actually becomes the virtual bootloader.
Step S704, in the updated target application, copies the original data of the second boot program stored in the second partition to a third backup area, where the third backup area is a sector in the second buffer.
In this embodiment, the virtual bootloader first backs up the original data of the bootloader1 stored in the bootloader1 area to the third backup area, so that when updating of the second bootloader1 fails, the original data of the bootloader1 can be recovered from the third backup area, and the system is prevented from being unable to operate. In the off-chip Flash partition shown in fig. 2, the third backup area may be expanded.
Step S706, after the backup is completed, the original data stored in the second partition is erased.
In the embodiment of the application, after the backup is completed, the virtual bootloader erases the data in the bootloader1 area, thereby freeing up a data storage space for upgrading the bootloader 1.
In step S708, the update file of the second boot program is copied to the second partition to update the second boot program.
In this embodiment of the application, after the virtual bootloader erases the data in the bootloader1 area, the update file of the second boot program can be copied to the bootloader1 area, so as to update the bootloader 1.
Optionally, if an unexpected situation occurs, such as failure to erase the original data in the bootloader1 area, failure to copy the update file of the second boot program, process interruption, etc., the microcontroller may be restarted, and after executing bootloader0, bootloader0 directs to execute the virtual bootloader, which backs up and erases the original data in the bootloader1 again, and copies the update file of the bootloader1 to the bootloader1 area, thereby updating bootloader 1.
Optionally, after the bootloader1 is updated, the data in the APP application area is erased, i.e. the function of the virtual bootloader is deleted, and the application data is refilled, so that the microcontroller can provide the corresponding control service.
In this embodiment of the application, the bootloader0 and the bootloader1 may be updated simultaneously or separately, that is, the third boot program may simultaneously carry the update file of the first boot program and the update file of the second boot program, or may separately carry the update file of any boot program.
After the bootloader0 and bootloader1 are updated, in order to ensure the stability and safe operation of the system, validity check needs to be performed on the updated bootloader0 and bootloader 1.
Optionally, as shown in fig. 8, after the updating of the first boot program, the method further includes:
step S802, extracting the updated program data of the first boot program from the first partition, and obtaining a third original check code of the update file of the first boot program, where the third original check code is generated after the update file of the first boot program is encoded, and the third original check code is stored in a check code storage sector in the first partition.
In this embodiment of the present application, when verifying the validity of the updated bootloader0, first, the program data of the current bootloader0 is extracted from the bootloader0 area, and the third original check code of the update file of the bootloader0 is obtained from the bootloader0 area. The third original check code is generated by the developer after encoding the update file of bootloader0, and is used to identify the original code data of the update file of bootloader 0.
Step S804, determining a third current check code of the updated program data of the first boot program.
In this embodiment, the program data extracted from the bootloader0 area is used to calculate a third current check code of the current bootloader0, where the third current check code is an identifier of the current program data of the bootloader 0.
Step S806, determining that the first bootstrap program is successfully updated when the third current check code is consistent with the third original check code.
In the embodiment of the present application, the third current check code of the bootloader0 is compared with the third original check code, and the two check codes are consistent, which indicates that the updated bootloader0 is the same as the original code and has not been tampered with, indicates that the current bootloader0 is valid, and determines that the bootloader0 is updated successfully.
Optionally, as shown in fig. 9, after updating the second boot program, the method further includes:
step S902, extracting the updated program data of the second boot program from the second partition, and acquiring a fourth original check code of the update file of the second boot program, where the fourth original check code is generated after the update file of the second boot program is encoded, and the fourth original check code is stored in a check code storage sector in the second partition.
In this embodiment of the present application, when verifying the validity of the updated bootloader1, first, the program data of the current bootloader1 is extracted from the bootloader1 area, and the fourth original check code of the update file of the bootloader1 is obtained from the bootloader1 area. The fourth original check code is generated by the developer after encoding the update file of bootloader1, and is used to identify the original code data of the update file of bootloader 1.
Step S904, determining a fourth current check code of the updated program data of the second boot program.
In this embodiment, the fourth current check code of the current bootloader1 is calculated by using the program data extracted from the bootloader1 area, where the fourth current check code is the identifier of the current program data of the bootloader 1.
Step S906, determining that the second bootstrap program is successfully updated when the fourth current check code is consistent with the fourth original check code.
In the embodiment of the present application, the fourth current check code of the bootloader1 is compared with the fourth original check code, and the comparison result is the same, which indicates that the updated bootloader1 is the same as the original code and has not been tampered with, indicates that the current bootloader1 is valid, and determines that the bootloader1 is updated successfully.
Alternatively,
under the condition that the process of receiving the program data of the third bootstrap program is interrupted, transmitting a transmission failure identifier to the first bootstrap program, so that when the first bootstrap program detects the transmission failure identifier, starting the second bootstrap program to renew the target application program;
under the condition that the process of copying the program data of the third bootstrap program in the first backup area to the third partition is interrupted and/or the verification of the updated target application program is failed, sending a first update failure identifier to the first bootstrap program, so that when the first bootstrap program detects the first update failure identifier, starting a second bootstrap program to update the target application program again;
under the condition that the process of copying the original data of the first bootstrap program stored in the first partition to the second backup area is interrupted and/or the verification of the updated first bootstrap program fails, recovering the original data of the first bootstrap program from the second backup area, and sending a second update failure identifier to the first bootstrap program so as to execute the original first bootstrap program and redirect the target application program to update the first bootstrap program;
and under the condition that the process of copying the original data of the second bootstrap program stored in the second partition to the third backup area is interrupted and/or the verification of the updated second bootstrap program fails, sending a third update failure identifier to the first bootstrap program so as to execute the first bootstrap program and redirect the target application program to update the second bootstrap program.
By adopting the technical scheme, a plurality of boot programs and a plurality of application programs are not required to be set to update the target boot program, only one application program needs to be upgraded into a virtual boot program to reversely upgrade the target boot program, the process is simplified, the safety is improved, the cost is reduced, the method can be deployed in microcontrollers of various scales, the technical problems that the bootloader upgrading process is complex and the safety is low are solved, the bootloader0 is updated to enable the bootloader0 to be adaptive to and matched with newly-expanded partitions and the functions added by the partitions, the occurrence of directional errors is avoided, and the occurrence of unknown errors is effectively reduced.
According to still another aspect of the embodiments of the present application, as shown in fig. 10, there is provided a bootstrap updating apparatus including:
the starting module 1001 is configured to start a second boot program when the first boot program detects a boot program update identifier, where the first boot program is used to boot the microcontroller to start and determine an execution program to be skipped, the second boot program is used to update an application program of the microcontroller, and the application program is used to record a control service provided by the microcontroller;
an application program update module 1003, configured to receive, in the second boot program, program data of a third boot program, and update the target application program with the program data of the third boot program as an update file, where the third boot program carries a boot program update file, the boot program update file includes an update file of the first boot program and/or the second boot program, and the third boot program is used to update the first boot program and/or the second boot program;
a bootstrap reverse update module 1005, configured to execute the updated target application to update the first bootstrap with the update file of the first bootstrap, and/or update the second bootstrap with the update file of the second bootstrap.
It should be noted that the starting module 1001 in this embodiment may be configured to execute step S102 in this embodiment, the application updating module 1003 in this embodiment may be configured to execute step S104 in this embodiment, and the bootstrap reverse updating module 1005 in this embodiment may be configured to execute step S106 in this embodiment.
It should be noted here that the modules described above are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the disclosure of the above embodiments. It should be noted that the modules may be implemented by software or hardware.
Optionally, the program data of the first boot program is stored in the first partition, the program data of the second boot program is stored in the second partition, and the first partition and the second partition are boot program areas; the starting module is specifically configured to:
extracting program data of a second bootstrap program from the second partition, and acquiring a first original check code of the program data of the second bootstrap program, wherein the first original check code is generated after the second bootstrap program is encoded, and the first original check code is stored in a check code storage sector in the second partition;
determining a first current check code of program data of a second bootstrap program;
and starting a second bootstrap program under the condition that the first current check code is consistent with the first original check code.
Optionally, program data of the target application program is stored in a third partition, the third partition is an application program area, and both the bootstrap program area and the application program area are sectors in the first buffer; the application program update module is specifically configured to:
receiving program data of a third bootstrap program, and transferring the program data of the third bootstrap program to a first backup area, wherein the first backup area is a sector in a second cache;
after the program data of the third bootstrap program is transferred, erasing the original data of the target application program stored in the third partition;
and copying the program data of the third bootstrap program in the first backup area to the third partition so as to update the target application program.
Optionally, the application update module further includes an application verification unit, configured to:
extracting the updated program data of the target application program from the third partition, and acquiring a second original check code of the program data of the third bootstrap program, wherein the second original check code is generated after the third bootstrap program is encoded, and the second original check code is stored in a check code storage sector in the third partition;
determining a second current check code of the program data of the updated target application program;
and under the condition that the second current check code is consistent with the second original check code, transmitting a normal starting identifier to the first bootstrap program, and restarting the first bootstrap program.
Optionally, the bootstrap reverse update module is specifically configured to:
under the condition that the first bootstrap program detects a normal starting identifier, starting an updated target application program, wherein the updated target application program is used for realizing the preset function of a third bootstrap program;
copying the original data of the first bootstrap program stored in the first partition to a second backup area in the updated target application program, wherein the second backup area is a sector in a second cache;
after the backup is finished, erasing the original data stored in the first partition;
copying an update file of the first bootstrap program to the first partition so as to update the first bootstrap program;
and/or the presence of a gas in the gas,
under the condition that the first bootstrap program detects a normal starting identifier, starting an updated target application program, wherein the updated target application program is used for realizing the preset function of a third bootstrap program;
copying the original data of the second bootstrap program stored in the second partition to a third backup area in the updated target application program, wherein the third backup area is a sector in the second cache;
after the backup is finished, erasing the original data stored in the second partition;
and copying the update file of the second bootstrap program to the second partition so as to update the second bootstrap program.
Optionally, the bootstrap reverse update module further includes a bootstrap verification unit, configured to:
extracting the updated program data of the first bootstrap program from the first partition, and acquiring a third original check code of the update file of the first bootstrap program, wherein the third original check code is generated after the update file of the first bootstrap program is encoded, and the third original check code is stored in a check code storage sector in the first partition;
determining a third current check code of the updated program data of the first bootstrap program;
under the condition that the third current check code is consistent with the third original check code, determining that the first bootstrap program is successfully updated;
and/or the presence of a gas in the gas,
extracting the updated program data of the second bootstrap program from the second partition, and acquiring a fourth original check code of the update file of the second bootstrap program, wherein the fourth original check code is generated after the encoding of the update file of the second bootstrap program is completed, and the fourth original check code is stored in a check code storage sector in the second partition;
determining a fourth current check code of the updated program data of the second bootstrap program;
and under the condition that the fourth current check code is consistent with the fourth original check code, determining that the second bootstrap program is successfully updated.
Optionally, the bootstrap updating apparatus further includes an exception handling module, configured to:
under the condition that the process of receiving the program data of the third bootstrap program is interrupted, transmitting a transmission failure identifier to the first bootstrap program, so that when the first bootstrap program detects the transmission failure identifier, starting the second bootstrap program to renew the target application program;
under the condition that the process of copying the program data of the third bootstrap program in the first backup area to the third partition is interrupted and/or the verification of the updated target application program is failed, sending a first update failure identifier to the first bootstrap program, so that when the first bootstrap program detects the first update failure identifier, starting a second bootstrap program to update the target application program again;
under the condition that the process of copying the original data of the first bootstrap program stored in the first partition to the second backup area is interrupted and/or the verification of the updated first bootstrap program fails, recovering the original data of the first bootstrap program from the second backup area, and sending a second update failure identifier to the first bootstrap program so as to execute the original first bootstrap program and redirect the target application program to update the first bootstrap program;
and under the condition that the process of copying the original data of the second bootstrap program stored in the second partition to the third backup area is interrupted and/or the verification of the updated second bootstrap program fails, sending a third update failure identifier to the first bootstrap program so as to execute the first bootstrap program and redirect the target application program to update the second bootstrap program.
By adopting the technical scheme, a plurality of boot programs and a plurality of application programs are not required to be set to update the target boot program, only one application program needs to be upgraded into a virtual boot program to reversely upgrade the target boot program, the process is simplified, the safety is improved, the cost is reduced, the method can be deployed in microcontrollers of various scales, the technical problems that the bootloader upgrading process is complex and the safety is low are solved, the bootloader0 is updated to enable the bootloader0 to be adaptive to and matched with newly-expanded partitions and the functions added by the partitions, the occurrence of directional errors is avoided, and the occurrence of unknown errors is effectively reduced.
According to another aspect of the embodiments of the present application, as shown in fig. 11, an electronic device is provided, which includes a memory 1101, a processor 1103, a communication interface 1105 and a communication bus 1107, wherein a computer program that can be run on the processor 1103 is stored in the memory 1101, the memory 1101 and the processor 1103 communicate with each other through the communication interface 1105 and the communication bus 1107, and the steps of the method are implemented when the processor 1103 executes the computer program.
The memory and the processor in the electronic equipment are communicated with the communication interface through a communication bus. The communication bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
There is also provided, in accordance with yet another aspect of an embodiment of the present application, a computer-readable medium having non-volatile program code executable by a processor.
Optionally, in an embodiment of the present application, a computer readable medium is configured to store program code for the processor to perform the following steps:
under the condition that the first bootstrap program detects a bootstrap program updating identifier, starting a second bootstrap program, wherein the first bootstrap program is used for guiding the microcontroller to start and determining an execution program to be jumped, the second bootstrap program is used for updating an application program of the microcontroller, and the application program is used for recording control services provided by the microcontroller;
in the second bootstrap program, receiving program data of a third bootstrap program, and updating a target application program by using the program data of the third bootstrap program as an update file, wherein the third bootstrap program carries a bootstrap program update file, the bootstrap program update file comprises an update file of the first bootstrap program and/or the second bootstrap program, and the third bootstrap program is used for updating the first bootstrap program and/or the second bootstrap program;
the updated target application is executed to update the first boot program using the update file of the first boot program and/or update the second boot program using the update file of the second boot program.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment is not described herein again.
When the embodiments of the present application are specifically implemented, reference may be made to the above embodiments, and corresponding technical effects are achieved.
It is to be understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or any combination thereof. For a hardware implementation, the Processing units may be implemented within one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), general purpose processors, controllers, micro-controllers, microprocessors, other electronic units configured to perform the functions described herein, or a combination thereof.
For a software implementation, the techniques described herein may be implemented by means of units performing the functions described herein. The software codes may be stored in a memory and executed by a processor. The memory may be implemented within the processor or external to the processor.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical division, and in actual implementation, there may be other divisions, for example, multiple modules or components may be combined or integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially implemented or make a contribution to the prior art, or may be implemented in the form of a software product stored in a storage medium and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk. It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is merely exemplary of the present application and is presented to enable those skilled in the art to understand and practice the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for bootstrap update, comprising:
starting a second bootstrap program under the condition that a first bootstrap program detects a bootstrap program updating identification, wherein the first bootstrap program is used for booting a microcontroller to start and determining an execution program to be jumped, the second bootstrap program is used for updating an application program of the microcontroller, and the application program is used for recording control services provided by the microcontroller;
receiving program data of a third bootstrap program in the second bootstrap program, and updating a target application program by using the program data of the third bootstrap program as an update file, wherein the third bootstrap program carries a bootstrap program update file, the bootstrap program update file comprises the update file of the first bootstrap program and/or the second bootstrap program, and the third bootstrap program is used for updating the first bootstrap program and/or the second bootstrap program;
executing the updated target application program to update the first bootstrap program by using the update file of the first bootstrap program and/or update the second bootstrap program by using the update file of the second bootstrap program.
2. The method of claim 1, wherein the program data of the first boot program is stored in a first partition, the program data of the second boot program is stored in a second partition, and the first partition and the second partition are boot program areas; in the event that the first boot program detects a boot program update identification, initiating a second boot program comprises:
extracting program data of the second bootstrap program from the second partition, and acquiring a first original check code of the program data of the second bootstrap program, wherein the first original check code is generated after the second bootstrap program is encoded, and the first original check code is stored in a check code storage sector in the second partition;
determining a first current check code of the program data of the second bootstrap program;
and starting the second bootstrap program under the condition that the first current check code is consistent with the first original check code.
3. The method of claim 2, wherein the program data of the target application is stored in a third partition, the third partition is an application area, and the boot area and the application area are sectors in a first buffer; in the second boot program, receiving program data of a third boot program, and updating the program data of the third boot program as an update file update target application program includes:
receiving program data of the third boot program, and transferring the program data of the third boot program to a first backup area, wherein the first backup area is a sector in a second buffer;
after the program data of the third boot program is transferred, erasing the original data of the target application program stored in the third partition;
copying the program data of the third boot program in the first backup area to the third partition to update the target application program.
4. The method of claim 3, wherein after updating the target application, the method further comprises:
extracting the updated program data of the target application program from the third partition, and acquiring a second original check code of the program data of the third boot program, wherein the second original check code is generated after the third boot program is encoded, and the second original check code is stored in a check code storage sector in the third partition;
determining a second current check code of the updated program data of the target application program;
and under the condition that the second current check code is consistent with the second original check code, transmitting a normal starting identifier to the first bootstrap program, and restarting the first bootstrap program.
5. The method of claim 4, wherein executing the updated target application to update the first boot program with the update file of the first boot program and/or to update the second boot program with the update file of the second boot program comprises:
under the condition that the first bootstrap program detects the normal starting identifier, starting the updated target application program, wherein the updated target application program is used for realizing the preset function of the third bootstrap program;
copying original data of the first boot program stored in the first partition to a second backup area in the updated target application program, wherein the second backup area is a sector in the second cache;
after the backup is finished, erasing the original data stored in the first partition;
copying an update file of the first boot program to the first partition to update the first boot program;
and/or the presence of a gas in the gas,
under the condition that the first bootstrap program detects the normal starting identifier, starting the updated target application program, wherein the updated target application program is used for realizing the preset function of the third bootstrap program;
copying original data of the second boot program stored in the second partition to a third backup area in the updated target application program, wherein the third backup area is a sector in the second cache;
after the backup is finished, erasing the original data stored in the second partition;
copying the update file of the second boot program to the second partition to update the second boot program.
6. The method of claim 5, wherein after updating the first boot program and/or updating the second boot program, the method further comprises:
extracting updated program data of the first bootstrap program from the first partition, and acquiring a third original check code of an update file of the first bootstrap program, wherein the third original check code is generated after encoding of the update file of the first bootstrap program is completed, and the third original check code is stored in a check code storage sector in the first partition;
determining a third current check code of the updated program data of the first bootstrap program;
determining that the first bootstrap program is successfully updated under the condition that the third current check code is consistent with the third original check code;
and/or the presence of a gas in the gas,
extracting the updated program data of the second bootstrap program from the second partition, and acquiring a fourth original check code of the update file of the second bootstrap program, wherein the fourth original check code is generated after the encoding of the update file of the second bootstrap program is completed, and the fourth original check code is stored in a check code storage sector in the second partition;
determining a fourth current check code of the updated program data of the second bootstrap program;
and determining that the second bootstrap program is successfully updated under the condition that the fourth current check code is consistent with the fourth original check code.
7. The method of claim 6,
under the condition that the process of receiving the program data of the third bootstrap program is interrupted, transmitting a transmission failure identifier to the first bootstrap program, so that when the first bootstrap program detects the transmission failure identifier, starting the second bootstrap program to renew the target application program;
under the condition that the process of copying the program data of the third bootstrap program in the first backup area to the third partition is interrupted and/or the target application program after updating is checked to be failed, sending a first updating failure identifier to the first bootstrap program, so that when the first bootstrap program detects the first updating failure identifier, starting the second bootstrap program to update the target application program again;
under the condition that the process of copying the original data of the first bootstrap program stored in the first partition to a second backup area is interrupted and/or the verification of the updated first bootstrap program fails, recovering the original data of the first bootstrap program from the second backup area, and sending a second update failure identifier to the first bootstrap program so as to execute the original first bootstrap program and redirect the target application program to update the first bootstrap program;
and under the condition that the process of copying the original data of the second bootstrap program stored in the second partition to a third backup area is interrupted and/or the second bootstrap program after updating fails to check, sending a third updating failure identifier to the first bootstrap program so as to execute the first bootstrap program and redirect the target application program to update the second bootstrap program.
8. A boot program update apparatus, comprising:
the starting module is used for starting a second bootstrap program under the condition that a first bootstrap program detects a bootstrap program updating identifier, wherein the first bootstrap program is used for guiding a microcontroller to start and determining an execution program to be jumped, the second bootstrap program is used for updating an application program of the microcontroller, and the application program is used for recording control services provided by the microcontroller;
an application program update module, configured to receive, in the second boot program, program data of a third boot program, and update a target application program with an update file using the program data of the third boot program, where the third boot program carries a boot program update file, the boot program update file includes the update file of the first boot program and/or the second boot program, and the third boot program is used to update the first boot program and/or the second boot program;
and the bootstrap program reverse updating module is used for executing the updated target application program so as to update the first bootstrap program by using the update file of the first bootstrap program and/or update the second bootstrap program by using the update file of the second bootstrap program.
9. An electronic device comprising a memory, a processor, a communication interface and a communication bus, wherein the memory stores a computer program operable on the processor, and the memory and the processor communicate via the communication bus and the communication interface, wherein the processor implements the steps of the method according to any of the claims 1 to 7 when executing the computer program.
10. A computer-readable medium having non-volatile program code executable by a processor, wherein the program code causes the processor to perform the method of any of claims 1 to 7.
CN202110682819.0A 2021-06-21 2021-06-21 Method, device and equipment for updating boot program and computer readable medium Active CN113254048B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110682819.0A CN113254048B (en) 2021-06-21 2021-06-21 Method, device and equipment for updating boot program and computer readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110682819.0A CN113254048B (en) 2021-06-21 2021-06-21 Method, device and equipment for updating boot program and computer readable medium

Publications (2)

Publication Number Publication Date
CN113254048A CN113254048A (en) 2021-08-13
CN113254048B true CN113254048B (en) 2021-09-28

Family

ID=77188845

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110682819.0A Active CN113254048B (en) 2021-06-21 2021-06-21 Method, device and equipment for updating boot program and computer readable medium

Country Status (1)

Country Link
CN (1) CN113254048B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115033261A (en) * 2022-06-16 2022-09-09 中国第一汽车股份有限公司 Program updating method, device, equipment and storage medium
CN115220758B (en) * 2022-06-24 2023-06-02 武汉联特科技股份有限公司 Method for on-line upgrading of single chip microcomputer firmware
CN115268971B (en) * 2022-09-27 2023-01-10 北京东远润兴科技有限公司 Updating method, device, equipment and storage medium of signal processing system

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902556A (en) * 2012-09-06 2013-01-30 深圳市共进电子股份有限公司 Multistage boot load method of embedded equipment
CN103699421A (en) * 2014-01-08 2014-04-02 金三立视频科技(深圳)有限公司 Method and device for upgrading embedded device system
CN105094903A (en) * 2015-07-16 2015-11-25 广州飞米电子科技有限公司 Method and device for upgrading firmware
CN106293824A (en) * 2016-08-04 2017-01-04 青岛海信电器股份有限公司 A kind of from the method and device processing chip upgrade
CN111240720A (en) * 2020-03-27 2020-06-05 武汉光谷信息光电子创新中心有限公司 Boot program upgrading method and device and storage medium
CN111796848A (en) * 2020-07-08 2020-10-20 中国第一汽车股份有限公司 Bootloader software updating method and device, embedded controller and storage medium
CN112052025A (en) * 2020-08-31 2020-12-08 中汽研扬州汽车工程研究院有限公司 System design method for self-updating and incremental updating of application program based on bootloader

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2310941A1 (en) * 2008-06-02 2011-04-20 Awox Method and device for updating a computer application
CN103299311B (en) * 2011-12-29 2015-04-29 英特尔公司 Methods and apparatus for trusted boot optimization
DE102017125172A1 (en) * 2017-10-26 2019-05-02 Schréder S.A. Method for updating a bootloader of a controller of a luminaire
US10810017B2 (en) * 2019-01-02 2020-10-20 Dell Products L.P. Systems and methods for handling firmware driver dependencies in host operating systems while applying updates from bootable image file

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902556A (en) * 2012-09-06 2013-01-30 深圳市共进电子股份有限公司 Multistage boot load method of embedded equipment
CN103699421A (en) * 2014-01-08 2014-04-02 金三立视频科技(深圳)有限公司 Method and device for upgrading embedded device system
CN105094903A (en) * 2015-07-16 2015-11-25 广州飞米电子科技有限公司 Method and device for upgrading firmware
CN106293824A (en) * 2016-08-04 2017-01-04 青岛海信电器股份有限公司 A kind of from the method and device processing chip upgrade
CN111240720A (en) * 2020-03-27 2020-06-05 武汉光谷信息光电子创新中心有限公司 Boot program upgrading method and device and storage medium
CN111796848A (en) * 2020-07-08 2020-10-20 中国第一汽车股份有限公司 Bootloader software updating method and device, embedded controller and storage medium
CN112052025A (en) * 2020-08-31 2020-12-08 中汽研扬州汽车工程研究院有限公司 System design method for self-updating and incremental updating of application program based on bootloader

Also Published As

Publication number Publication date
CN113254048A (en) 2021-08-13

Similar Documents

Publication Publication Date Title
CN113254048B (en) Method, device and equipment for updating boot program and computer readable medium
CN106020865B (en) System upgrading method and device
KR100750132B1 (en) Method and system for booting, updating software automatically and recovering update error, and computer readable medium recording the method
US8539471B2 (en) Updating firmware of an electronic device
JP5607863B2 (en) Secure recovery apparatus and method
US20170255459A1 (en) Embedded device and program updating method
CN106775610B (en) Electronic equipment starting method and electronic equipment
EP2375323A1 (en) Firmware image update and management
CN101308470A (en) Computer system for initiative restoration, backup and update of BIOS
US20130061090A1 (en) Partial rebooting recovery apparatus and method
CN111506454A (en) Method and system for recovering and updating basic input/output system
CN106775674B (en) Equipment based on universal boot loader and starting method thereof
CN111625295A (en) Embedded system starting method, device, equipment and storage medium
CN113157303A (en) Upgrading method, embedded system, terminal and computer storage medium
TW202131170A (en) Firmware corruption recovery
CN111045709B (en) Firmware upgrading method and firmware upgrading device
CN112667444A (en) System upgrading method, storage medium and terminal equipment
WO2020043361A1 (en) Installing application program code on a vehicle control system
CN117331593A (en) Dual-backup upgrading method, computer equipment and storage medium
KR20120030573A (en) A method, apparatus and computer program for loading files during a boot-up process
CN113687851A (en) Embedded equipment upgrading method and device
CN116257265A (en) Firmware updating method and device of wearable device and wearable device
JP2005228225A (en) Memory card adaptor
CN117215657A (en) System starting method, device, computer equipment and readable storage medium
CN114265603A (en) System upgrading method and device based on asymmetric partition and electronic equipment

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
GR01 Patent grant
GR01 Patent grant