[go: up one dir, main page]

CN117573174A - Method and device for updating Bootloader based on chip - Google Patents

Method and device for updating Bootloader based on chip Download PDF

Info

Publication number
CN117573174A
CN117573174A CN202311440132.1A CN202311440132A CN117573174A CN 117573174 A CN117573174 A CN 117573174A CN 202311440132 A CN202311440132 A CN 202311440132A CN 117573174 A CN117573174 A CN 117573174A
Authority
CN
China
Prior art keywords
bootloader program
bootloader
updated
program
flag bit
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
CN202311440132.1A
Other languages
Chinese (zh)
Inventor
单波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingwei Hirain Tech Co Ltd
Original Assignee
Beijing Jingwei Hirain Tech 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 Beijing Jingwei Hirain Tech Co Ltd filed Critical Beijing Jingwei Hirain Tech Co Ltd
Priority to CN202311440132.1A priority Critical patent/CN117573174A/en
Publication of CN117573174A publication Critical patent/CN117573174A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/654Updates using techniques specially adapted for alterable solid state memories, e.g. for EEPROM or flash memories

Landscapes

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

Abstract

The invention provides a method and a device for updating Bootloader based on a chip, if a check value in a first flag bit is valid, and a Bootloader program to be updated passes through integrity check, the check value in the first flag bit is erased through the Bootloader program to be updated; erasing Bootloader programs in the storage space; storing Bootloader data into a storage space; if the Bootloader data passes the integrity check, writing a check value in the first flag bit and executing the reset operation. After the chip is electrified, checking a check value in the first flag bit to avoid the occurrence of the condition that the chip runs off; and the Bootloader program to be updated is stored, so that the storage space is saved, the Bootloader data is updated by the Bootloader program to be updated, the updating time is shortened, and the updating efficiency is improved.

Description

Method and device for updating Bootloader based on chip
Technical Field
The invention relates to the technical field of software updating, in particular to a method and a device for updating Bootloader based on a chip.
Background
Bootloader is the first piece of code that the embedded system executes after power-up to boot, update programs and data. Along with the rapid development of the automobile embedded technology, higher requirements are put forward on the updating speed of embedded software and the reliability of the software, so that Bootloader is updated and upgraded in time to ensure that the application program normally realizes the functions of the Bootloader.
The current method for upgrading Bootloader mainly uses two bootloaders, the first Bootloader is used for updating the second Bootloader, and the second Bootloader is used for updating the app and starting the app, and the method occupies more flash space, and when updating the second Bootloader, the time required for updating is longer, and the updating efficiency is lower.
Disclosure of Invention
In view of this, the embodiment of the invention provides a method and a device for updating Bootloader based on a chip, so as to solve the problems of longer Bootloader updating time and lower updating efficiency.
In order to achieve the above object, the embodiment of the present invention provides the following technical solutions:
the first aspect of the embodiment of the invention discloses a method for updating Bootloader based on a chip, which comprises the following steps:
checking whether the check value in the first flag bit is valid;
if the check value in the first flag bit is valid, receiving a Bootloader program to be updated sent by an upper computer through the Bootloader program, and performing integrity check on the Bootloader program to be updated;
if the Bootloader program to be updated passes the integrity check, the check value in the first flag bit is erased through the Bootloader program to be updated;
erasing the Bootloader program from a flash space through the Bootloader program to be updated;
storing Bootloader data in the Bootloader program to be updated into the flash space;
carrying out integrity check on the Bootloader data in the flash space through the Bootloader program to be updated;
and when the Bootloader data passes the integrity check, writing the check value in the first flag bit and executing the reset operation.
Preferably, before the Bootloader program to be updated erases the Bootloader program from the flash space, the method further includes:
if the check value in the first flag bit is invalid, checking whether the check value in the second flag bit is valid;
and when the check value in the second flag bit is valid, erasing the check value in the first flag bit through the Bootloader program to be updated.
Preferably, the method further comprises:
and when the check value in the second zone bit is invalid, generating alarm information and displaying the alarm information to a user.
Preferably, if the check value in the first flag bit is valid, the Bootloader program to be updated sent by the upper computer is received through the Bootloader program, and after the integrity check is performed on the Bootloader program to be updated, the method further includes:
if the Bootloader program to be updated does not pass the integrity check, downloading a target Bootloader program through the Bootloader program;
carrying out integrity check on the target Bootloader program;
and if the target Bootloader program passes the integrity check, marking the target Bootloader program as the Bootloader program to be updated, and executing a reset operation.
Preferably, if the Bootloader program to be updated does not pass the integrity check, downloading the target Bootloader program by the Bootloader program includes:
if the Bootloader program to be updated does not pass the integrity check, receiving an update message sent by an upper computer through the Bootloader program, wherein the update message comprises the initial address information and the data length information of a target Bootloader program;
and feeding back a receiving message to the upper computer according to the updating message, and receiving a target Bootloader program sent by the upper computer.
The second aspect of the embodiment of the invention discloses a device for updating Bootloader based on a chip, which comprises:
the first checking unit is used for checking whether the check value in the first flag bit is valid or not;
the second checking unit is used for receiving the Bootloader program to be updated sent by the upper computer through the Bootloader program if the check value in the first flag bit is valid, and checking the integrity of the Bootloader program to be updated;
the first erasing unit is used for erasing the check value in the first flag bit through the Bootloader program to be updated if the Bootloader program to be updated passes the integrity check;
the second erasing unit is used for erasing the Bootloader program from the flash space through the Bootloader program to be updated;
the storage unit is used for storing Bootloader data in the Bootloader program to be updated into the flash space;
the third checking unit is used for carrying out integrity check on the Bootloader data in the flash space through the Bootloader program to be updated;
and the writing unit is used for writing the check value in the first flag bit and executing reset operation when the Bootloader data passes the integrity check.
Preferably, the method further comprises:
a fourth checking unit, configured to check whether the check value in the second flag bit is valid if the check value in the first flag bit is invalid;
and the third erasing unit is used for erasing the check value in the first flag bit through the Bootloader program to be updated when the check value in the second flag bit is valid.
Preferably, the method further comprises:
and the generating unit is used for generating alarm information and displaying the alarm information to a user when the check value in the second flag bit is invalid.
Preferably, the method further comprises:
the downloading unit is used for downloading a target Bootloader program through the Bootloader program if the Bootloader program to be updated does not pass the integrity check;
a fifth checking unit, configured to perform integrity check on the target Bootloader program;
and the marking unit is used for marking the target Bootloader program as the Bootloader program to be updated if the target Bootloader program passes the integrity check, and executing the reset operation.
Preferably, the downloading unit includes:
the first receiving module is used for receiving an update message sent by an upper computer through the Bootloader program if the Bootloader program to be updated fails to pass the integrity check, wherein the update message comprises the initial address information and the data length information of the target Bootloader program;
and the second receiving module is used for feeding back a receiving message to the upper computer according to the updating message and receiving a target Bootloader program sent by the upper computer.
Based on the method and the device for updating Bootloader based on the chip provided by the embodiment of the invention, the method comprises the following steps: checking whether the check value in the first flag bit is valid; if the check value in the first flag bit is valid, receiving a Bootloader program to be updated sent by an upper computer through the Bootloader program, and performing integrity check on the Bootloader program to be updated; if the Bootloader program to be updated passes the integrity check, the check value in the first flag bit is erased through the Bootloader program to be updated; erasing the Bootloader program from the flash space through the Bootloader program to be updated; storing Bootloader data in the Bootloader program to be updated into a flash space; carrying out integrity check on Bootloader data in the flash space through a Bootloader program to be updated; when the Bootloader data passes the integrity check, writing a check value in the first flag bit and executing a reset operation. After the chip is powered on, checking whether a check value in the first flag bit is valid or not so as to avoid the occurrence of the condition that the chip Bootloader runs out caused by unexpected power failure; the Bootloader program to be updated is stored through the Bootloader program, the flash space is saved, the Bootloader data is updated through the Bootloader program to be updated, the updating time is shortened, and the updating efficiency is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for updating Bootloader based on a chip according to an embodiment of the present invention;
FIG. 2 is another flowchart of a method for updating Bootloader based on a chip according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of on-chip power-on-chip jump according to an embodiment of the present invention;
fig. 4 is a block diagram of a device for updating Bootloader based on a chip according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In this application, 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 one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The background technology shows that the current method for upgrading Bootloader mainly uses two Bootloader programs to update, occupies more flash space, and requires longer time and has lower updating efficiency when updating Bootloader.
Therefore, an embodiment of the present invention provides a method and an apparatus for updating Bootloader based on a chip, including: checking whether the check value in the first flag bit is valid; if the check value in the first flag bit is valid, receiving a Bootloader program to be updated sent by an upper computer through the Bootloader program, and performing integrity check on the Bootloader program to be updated; if the Bootloader program to be updated passes the integrity check, the check value in the first flag bit is erased through the Bootloader program to be updated; erasing the Bootloader program from the flash space through the Bootloader program to be updated; storing Bootloader data in the Bootloader program to be updated into a flash space; carrying out integrity check on Bootloader data in the flash space through a Bootloader program to be updated; when the Bootloader data passes the integrity check, writing a check value in the first flag bit and executing a reset operation. After the chip is powered on, checking whether a check value in the first flag bit is valid or not so as to avoid the occurrence of the condition that the chip Bootloader runs out caused by unexpected power failure; the Bootloader program to be updated is stored through the Bootloader program, the flash space is saved, the Bootloader data is updated through the Bootloader program to be updated, the updating time is shortened, and the updating efficiency is improved.
Referring to fig. 1, a flowchart of a method for updating Bootloader based on a chip according to an embodiment of the present invention is shown. Taking the inflight TC22x chip as an example, the jump function of the chip is utilized in the embodiment of the present invention (i.e. when powering up, specific address information is automatically read to determine which data segment needs to be jumped to in order to run the corresponding code).
The Bootloader updating method comprises the following steps:
step S101: checking whether the check value in the first flag bit is valid; if the check value in the first flag bit is valid, executing step S102; if the check value in the first flag bit is invalid, the following details of fig. 2 are described in the following embodiment of the present invention.
It should be noted that, in a specific application, effective Bootloader and jump_back Jump software are written into the chip in advance, and effective data of BMHD0 and BMHD1 are also written into the flash space of the chip together.
Wherein, BMHD0 and BMHD1 are a section of data structure inherent in the InfraRed chip manual, and check values indicating whether the data in the corresponding address sections are valid are stored in BMHD0 and BMHD 1.
In the process of implementing step S101, checking whether the check value in the first flag bit (BMHD 0) is valid, for example, checking whether the value of BMHDID in the first flag bit (BMHD 0) is B359, and checking whether the data from Chkstart to chknend is valid; checking whether the crc value of the BMHD data structure is correct; checking whether the BMI value in the BMHD header is correct; detecting whether the third bit in the BMI array is 0 and detecting otp protection mode; detecting ststat. Hwcfg status to select whether ABM mode is enabled; checking whether CRC values of data in the data segments corresponding to the BMHD heads are valid or not, and if all the checks are passed, determining that the check values in the first flag bits are valid.
When the check value in the first flag bit (BMHD 0) is valid, the Bootloader program is indicated to be valid, and step S102 is performed. When the check value in the first flag bit (BMHD 0) is invalid, indicating that the Bootloader program is invalid, the check value in the second flag bit (BMHD 1) needs to be checked, and the detailed implementation manner is shown in fig. 2 below.
In the application process, service interruption caused by accident outage can occur, so that a Bootloader program in a chip is damaged, and the problem that the Bootloader program runs off can be avoided by detecting the validity of the first flag bit when the Bootloader program is electrified.
Step S102: and receiving the Bootloader program to be updated sent by the upper computer through the Bootloader program, and carrying out integrity check on the Bootloader program to be updated.
It should be noted that, based on the principle of updating an application program by using a Bootloader program, the Bootloader program to be updated sent by the upper computer is received by using the Bootloader program, and the Bootloader program to be updated (also referred to as a reverse-brushing Bootloader program) is used as an application software brush to a memory space where the application program in the Bootloader program is located.
In the specific implementation process of step S102, when the check value in the first flag bit (BMHD 0) is valid, a Bootloader program is started, the Bootloader program to be updated sent by the upper computer is received through the Bootloader program, and integrity check is performed on the Bootloader program to be updated. For example, the integrity of the Bootloader program to be updated is checked through 31 services, and specifically, the integrity of the Bootloader program to be updated can be checked through a CRC32 check algorithm or a CRC16 check algorithm.
Specifically, according to 34, 36 and 37 services in the 14229 protocol, the Bootloader program receives an update message (for example, a message of 34 services) sent by the upper computer, where the update message includes start address information and data length information of the target Bootloader program; and feeding back a receiving message (the receiving message for the service feedback 34 contains 7400 content) to the upper computer according to the updating message, (after the upper computer receives the receiving message, the upper computer sends 36 messages to the Bootloader program, and the 36 messages contain the Bootloader program to be updated) and receives the Bootloader program to be updated, which is sent by the upper computer.
It can be understood that the Bootloader program to be updated (the anti-brushing Bootloader program) is used as the application software to be written into the Bootloader program, so that the memory space of the chip is saved, and the purpose of updating the Bootloader program can be achieved if the Bootloader program to be updated passes the integrity check; the execution efficiency is higher when the Bootloader program is reversely brushed, and the Bootloader program can be updated without the cooperation of an upper computer.
Step S103: and if the Bootloader program to be updated passes the integrity check, the check value in the first flag bit is erased through the Bootloader program to be updated.
In the specific implementation process of step S103, if the Bootloader program to be updated (the anti-brush Bootloader program) passes the integrity check, the Bootloader program to be updated (the anti-brush Bootloader program) is started by the Bootloader program, and the check value in the flash space where the first flag bit (BMHD 0) is located is erased by the Bootloader program to be updated (the anti-brush Bootloader program).
It can be understood that the flash driver driving code is integrated in the Bootloader program to be updated (the reverse-brushing Bootloader program), so that the operation on the flash space can be realized, including erasing the data in the flash space or writing the data into the flash space; the Bootloader program to be updated is also integrated with new Bootloader data, and the Bootloader data is integrated in a block address of the flash space in an array mode.
It should be noted that, after the check value in the first flag bit (BMHD 0) is erased by the Bootloader program to be updated, the Bootloader program to be updated is indicated to be successfully written, and at this time, the Bootloader program executes the reset operation through 1101 services.
Step S104: and erasing the Bootloader program from the flash space through the Bootloader program to be updated.
In the specific implementation process of step S104, the Bootloader program is erased from the Flash space by the Bootloader program to be updated, and specifically, the Bootloader program is erased by the Flash driver.
It can be understood that the Bootloader program is erased from the flash space, so that Bootloader data in the Bootloader program to be updated is stored in the corresponding flash space.
Step S105: and storing Bootloader data in the Bootloader program to be updated into the flash space.
In the specific implementation process of step S105, after the old Bootloader program is erased, the Bootloader data in the array is written into the flash space where the old Bootloader program is located, by the Bootloader program to be updated, in a way of, for example, 256 bytes and one segment.
It can be understood that writing the new Bootloader data into the flash space where the old Bootloader program is located, so as to realize that the new Bootloader data "replaces" the old Bootloader program, so as to update the Bootloader program in the chip.
Step S106: and carrying out integrity check on Bootloader data in the flash space through the Bootloader program to be updated.
In the specific implementation process of step S106, the Bootloader data in the flash space is subjected to integrity check by the Bootloader program to be updated, for example, the Bootloader data is subjected to integrity check by a CRC32 algorithm.
It should be noted that, if Bootloader data in the flash space fails the integrity check, generating alarm information and displaying the alarm information to the user. The method comprises the steps of generating alarm information based on Bootloader data in a flash space.
It can be understood that integrity verification is performed on Bootloader data in the flash space, so that the Bootloader data written in the flash space is ensured to be complete and effective, and success of updating the Bootloader is further ensured.
Step S107: when the Bootloader data passes the integrity check, writing a check value in the first flag bit and executing a reset operation.
In the specific implementation process of step S107, when the Bootloader data passes the integrity check, a check value (i.e., the correct BMHD array structure) is written in the first flag bit (BMHD 0), that is, the check value in the first flag bit (BMHD 0) is set to be valid, and a reset operation is performed.
It should be noted that, at this time, the reset operation is 1101 service in the Bootloader program to be updated (the anti-brush Bootloader program), that is, the chip is run from scratch by entering the reset on the software or hardware through 1101 service. After reset, the new Bootloader program is entered to execute the flow.
In the embodiment of the invention, the first flag bit is checked after the chip is electrified, so that the problem that the Bootloader program is electrified again and runs out due to failure in the Bootloader brushing caused by power failure when the Bootloader program to be updated (the reversely-brushed Bootloader program) erases or copies data can be effectively avoided; the Bootloader program to be updated (the anti-brush Bootloader program) is stored in the Bootloader program in an APP mode, and is started through the Bootloader program, so that the storage space of a chip is saved, and the purpose of upgrading the Bootloader program without matching an upper computer is achieved. The updating time is shortened, and the updating efficiency is improved.
Referring to fig. 2, another flowchart of a method for updating Bootloader based on a chip according to the embodiment of the present invention is shown in the specific implementation manner of the embodiment of the present invention in fig. 1 when the check value in the first flag bit is invalid, where the method includes:
step S201: checking whether the check value in the first flag bit is valid; if the check value in the first flag bit is valid, step S202 is executed; if the check value in the first flag bit is invalid, step S203 is performed.
In the process of implementing step S201, checking whether the check value in the first flag bit (BMHD 0) is valid, for example, checking whether the value of BMHDID in the first flag bit (BMHD 0) is B359, and checking whether the data from Chkstart to chknend is valid; checking whether the crc value of the BMHD data structure is correct; checking whether the BMI value in the BMHD header is correct; detecting whether the third bit in the BMI array is 0 and detecting otp protection mode; detecting ststat. Hwcfg status to select whether ABM mode is enabled; checking whether CRC values of data in the data segments corresponding to the BMHD heads are valid or not, and if all the checks are passed, determining that the check values in the first flag bits are valid.
When the check value in the first flag bit (BMHD 0) is valid, step S202 is performed; when the check value in the first flag bit (BMHD 0) is invalid, step S203 is performed.
Step S202: and receiving the Bootloader program to be updated sent by the upper computer through the Bootloader program, and carrying out integrity check on the Bootloader program to be updated. If the Bootloader program to be updated passes the integrity check, executing step S204; if the Bootloader to be updated fails to pass the integrity check, step S209 is executed.
In the specific implementation process of step S202, when the check value in the first flag bit (BMHD 0) is valid, a Bootloader program is started, the Bootloader program to be updated sent by the upper computer is received through the Bootloader program, and the integrity check is performed on the Bootloader program to be updated. When the Bootloader program to be updated passes the integrity check, executing step S204; when the Bootloader program to be updated fails the integrity check, step S209 is executed.
For example, the integrity of the Bootloader program to be updated is checked through 31 services, and specifically, the integrity of the Bootloader program to be updated can be checked through a CRC32 check algorithm or a CRC16 check algorithm.
Step S203: and checking whether the check value in the second flag bit is valid. When the check value in the second flag bit is valid, step S204 is executed; when the check value in the second flag bit is invalid, step S211 is performed.
In the specific implementation process of step S203, if the check value in the first flag bit (BMHD 0) is invalid, checking whether the check value in the second flag bit (BMHD 1) is valid; for example, check whether the value of BMHDID in the second flag bit (BMHD 1) is B359, and check whether data from Chkstart to chknend is valid; checking whether the crc value of the BMHD data structure is correct; checking whether the BMI value in the BMHD header is correct; detecting whether the third bit in the BMI array is 0 and detecting otp protection mode; detecting ststat. Hwcfg status to select whether ABM mode is enabled; checking whether CRC values of data in the data segments corresponding to the BMHD heads are valid or not, and if all the checks are passed, determining that the check values in the second flag bits are valid. When the check value in the second flag bit is valid, step S204 is executed; when the check value in the second flag bit is invalid, step S211 is performed.
It can be understood that when the Bootloader program to be updated is in the process of executing erasing or writing data, if the Bootloader program in the chip becomes unavailable (i.e. a program which cannot normally run) due to the sudden power-off, the Bootloader program can be directly executed when the chip is powered on again without special processing, and at this time, the situation that the chip runs and cannot normally run occurs. Therefore, if the first flag bit is verified to be invalid after power-up, it may be caused by sudden power-off of the Bootloader program to be updated in the process of executing erasing or writing data, at this time, whether the second flag bit is valid is verified, if the second flag bit is valid, it indicates that the updating operation can be continued through the Bootloader program to be updated, that is, step S204 is executed.
Step S204: and when the Bootloader program to be updated passes the integrity check or the check value in the second flag bit is valid, erasing the check value in the first flag bit through the Bootloader program to be updated.
In the specific implementation process of step S204, if the Bootloader program to be updated (the anti-brush Bootloader program) passes the integrity check, the Bootloader program to be updated (the anti-brush Bootloader program) is started by the Bootloader program, and the check value in the flash space where the first flag bit (BMHD 0) is located is erased by the Bootloader program to be updated (the anti-brush Bootloader program).
Or if the check value in the second flag bit (BMHD 1) is valid, starting a Bootloader program to be updated (a Back-flushing Bootloader program) by using Jump software in the second flag bit (BMHD 1), and erasing the check value in the flash space where the first flag bit (BMHD 0) is located by using the Bootloader program to be updated (the Back-flushing Bootloader program).
Step S205: and erasing the Bootloader program from the flash space through the Bootloader program to be updated.
Step S206: and storing Bootloader data in the Bootloader program to be updated into the flash space.
Step S207: and carrying out integrity check on Bootloader data in the flash space through the Bootloader program to be updated. When the Bootloader data passes the integrity check, executing step S208; when the Bootloader data does not pass the integrity check, generating alarm information and displaying the alarm information to a user.
Step S208: when the Bootloader data passes the integrity check, writing a check value in the first flag bit and executing a reset operation.
It should be noted that, the specific implementation manner of step S204 to step S208 is shown in fig. 1 in the embodiment of the present invention, and will not be described herein.
Step S209: and when the Bootloader program to be updated does not pass the integrity check, downloading the target Bootloader program by the Bootloader program, and carrying out the integrity check on the target Bootloader program. If the target Bootloader program passes the integrity check, executing step S210; if the target Bootloader program fails the integrity check, step S211 is executed.
It should be noted that, when the Bootloader program to be updated fails the integrity check, the target Bootloader program is downloaded through the Bootloader program according to the services 34, 36 and 37 in the 14229 protocol. Specifically, the Bootloader program receives an update message (for example, a message of 34 services) sent by the upper computer, where the update message includes start address information and data length information of the target Bootloader program; and feeding back a receiving message (the receiving message for the service feedback 34 contains 7400 content) to the upper computer according to the updating message, (after the upper computer receives the receiving message, the upper computer sends 36 messages to the Bootloader program, and the 36 messages contain the target Bootloader program) and receives the target Bootloader program sent by the upper computer.
In some embodiments, after all target Bootloader data is transferred, the upper level may inform the Bootloader that the transfer of the Bootloader data is completed through the 37 service. That is, the Bootloader program receives a message sent by the host computer based on the 37 services.
It can be understood that the integrity of the target Bootloader program is checked by the Bootloader program; the implementation principle of the verification is the same as that of the Bootloader program to be updated through the Bootloader program, if the target Bootloader program passes the integrity verification, the step S210 is executed; if the target Bootloader program fails the integrity check, step S211 is executed.
Step S210: if the target Bootloader program passes the integrity check, marking the target Bootloader program as the Bootloader program to be updated, and executing the reset operation.
In the specific implementation process of step S210, when the target Bootloader program passes the integrity check, the target Bootloader program is marked as the Bootloader program to be updated, and a reset operation is performed, so as to achieve the purpose of re-powering on the chip to perform the update operation.
Step S211: when the target Bootloader program fails the integrity check or when the check value in the second flag bit is invalid, generating alarm information and displaying the alarm information to a user.
In the specific implementation process of step S211, when the target Bootloader program fails the integrity check, generating alarm information based on the target Bootloader program; or when the check value in the second zone bit is invalid, generating alarm information based on the check value in the second zone bit, and displaying the alarm information to a user.
In the embodiment of the invention, the first flag bit is checked after the chip is electrified, so that the problem that the Bootloader program is electrified again and runs out due to failure in the Bootloader brushing caused by power failure when the Bootloader program to be updated (the reversely-brushed Bootloader program) erases or copies data can be effectively avoided; the Bootloader program to be updated (the anti-brush Bootloader program) is stored in the Bootloader program in an APP mode, and is started through the Bootloader program, so that the storage space of a chip is saved, and the purpose of upgrading the Bootloader program without matching an upper computer is achieved. The updating time is shortened, and the updating efficiency is improved.
In order to better explain whether to skip to the content in the reverse brush Bootloader by checking the BMHD0 and the BMHD1 after the chip is powered on, referring to FIG. 3, a schematic diagram of the on-chip power-on skip is shown.
It can be understood that when the Bootloader program to be updated (the anti-brush Bootloader program) performs erasing or writing operation, if the Bootloader program in the chip is damaged and unavailable due to sudden power failure, the Bootloader program is directly executed by the chip after the chip is powered up again without special processing, so that the chip runs out and cannot normally run.
Therefore, when the chip is powered on, whether the Bootloader program is effective or not is judged, and if the Bootloader program is effective, the Bootloader program is directly accessed; if the Bootloader program to be updated (the anti-brush Bootloader program) is valid, the process is skipped to the Bootloader program to be updated (the anti-brush Bootloader program) to be executed through a section of skip code, and the process does not directly enter the Bootloader program.
As shown in fig. 3, there are two scenarios, in case 1, the Bootloader program is valid, after the chip is powered up, it is checked whether the data in the BMHD0 is valid, if so, the Bootloader program is executed, and then the Bootloader program to be updated (anti-brushing Bootloader program) is started, so that it is not checked whether the data in the BMHD1 is valid.
In case 2, the Bootloader program is invalid, but after the Bootloader program to be updated (the anti-brush Bootloader program) is valid, after the chip is powered up, it is checked whether the data in the BMHD0 is valid, if the data in the BMHD1 is valid, the corresponding jump_back software is executed, and then the Jump is made to the Bootloader program to be updated (the anti-brush Bootloader program).
Corresponding to the method for updating Bootloader based on the chip provided by the embodiment of the invention, referring to fig. 4, a block diagram of a device for updating Bootloader based on the chip provided by the embodiment of the invention is shown; the device comprises: a first verification unit 401, a second verification unit 402, a first erase unit 403, a second erase unit 404, a storage unit 405, a third verification unit 406, and a write unit 407.
A first checking unit 401, configured to check whether the check value in the first flag bit is valid.
And the second checking unit 402 is configured to receive, by the Bootloader program, the Bootloader program to be updated sent by the upper computer if the check value in the first flag bit is valid, and perform integrity check on the Bootloader program to be updated.
The first erasing unit 403 is configured to erase the check value in the first flag bit by the Bootloader program to be updated if the Bootloader program to be updated passes the integrity check.
And a second erasing unit 404, configured to erase the Bootloader program from the flash space through the Bootloader program to be updated.
And the storage unit 405 is configured to store Bootloader data in the Bootloader program to be updated into the flash space.
And a third checking unit 406, configured to perform integrity check on Bootloader data in the flash space through the Bootloader program to be updated.
The writing unit 407 is configured to write a check value in the first flag bit and perform a reset operation when Bootloader data passes the integrity check.
In the embodiment of the invention, the first flag bit is checked after the chip is electrified, so that the problem that the Bootloader program is electrified again and runs out due to failure in the Bootloader brushing caused by power failure when the Bootloader program to be updated (the reversely-brushed Bootloader program) erases or copies data can be effectively avoided; the Bootloader program to be updated (the anti-brush Bootloader program) is stored in the Bootloader program in an APP mode, and is started through the Bootloader program, so that the storage space of a chip is saved, and the purpose of upgrading the Bootloader program without matching an upper computer is achieved. The updating time is shortened, and the updating efficiency is improved.
Preferably, in combination with the content shown in fig. 4, the apparatus further comprises: a fourth verify unit and a third erase unit.
And the fourth checking unit is used for checking whether the check value in the second flag bit is valid or not if the check value in the first flag bit is invalid.
And the third erasing unit is used for erasing the check value in the first flag bit through the Bootloader program to be updated when the check value in the second flag bit is valid.
Preferably, in combination with the content shown in fig. 4, the apparatus further comprises: and the generating unit is used for generating alarm information and displaying the alarm information to a user when the check value in the second flag bit is invalid.
Preferably, in combination with the content shown in fig. 4, the apparatus further comprises: the device comprises a downloading unit, a fifth checking unit and a marking unit.
And the downloading unit is used for downloading the target Bootloader program through the Bootloader program if the Bootloader program to be updated does not pass the integrity check.
And the fifth checking unit is used for carrying out integrity check on the target Bootloader program.
And the marking unit is used for marking the target Bootloader program as the Bootloader program to be updated if the target Bootloader program passes the integrity check, and executing the reset operation.
Preferably, in combination with the content shown in fig. 4, the downloading unit includes: a first receiving module and a second receiving module.
The first receiving module is configured to receive, by the Bootloader program, an update message sent by the upper computer if the Bootloader program to be updated fails to pass the integrity check, where the update message includes start address information and data length information of the target Bootloader program.
And the second receiving module is used for feeding back a receiving message to the upper computer according to the updating message and receiving a target Bootloader program sent by the upper computer.
In summary, the embodiment of the invention provides a method and a device for updating Bootloader based on a chip, if a check value in a first flag bit is valid, and a Bootloader program to be updated passes integrity check, the check value in the first flag bit is erased by the Bootloader program to be updated; erasing Bootloader programs in the storage space; storing Bootloader data into a storage space; if the Bootloader data passes the integrity check, writing a check value in the first flag bit and executing the reset operation. After the chip is electrified, checking a check value in the first flag bit to avoid the occurrence of the condition that the chip runs off; and the Bootloader program to be updated is stored, so that the storage space is saved, the Bootloader data is updated by the Bootloader program to be updated, the updating time is shortened, and the updating efficiency is improved.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for a system or system embodiment, since it is substantially similar to a method embodiment, the description is relatively simple, with reference to the description of the method embodiment being made in part. The systems and system embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. 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 invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. 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 scope of the invention. Thus, the present invention 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 updating Bootloader based on a chip, the method comprising:
checking whether the check value in the first flag bit is valid;
if the check value in the first flag bit is valid, receiving a Bootloader program to be updated sent by an upper computer through the Bootloader program, and performing integrity check on the Bootloader program to be updated;
if the Bootloader program to be updated passes the integrity check, the check value in the first flag bit is erased through the Bootloader program to be updated;
erasing the Bootloader program from a flash space through the Bootloader program to be updated;
storing Bootloader data in the Bootloader program to be updated into the flash space;
carrying out integrity check on the Bootloader data in the flash space through the Bootloader program to be updated;
and when the Bootloader data passes the integrity check, writing the check value in the first flag bit and executing the reset operation.
2. The method according to claim 1, wherein before the Bootloader program to be updated erases the Bootloader program from the flash space, further comprising:
if the check value in the first flag bit is invalid, checking whether the check value in the second flag bit is valid;
and when the check value in the second flag bit is valid, erasing the check value in the first flag bit through the Bootloader program to be updated.
3. The method as recited in claim 2, further comprising:
and when the check value in the second zone bit is invalid, generating alarm information and displaying the alarm information to a user.
4. The method of claim 1, wherein if the check value in the first flag bit is valid, receiving, by the Bootloader program, the Bootloader program to be updated sent by the upper computer, and after performing integrity check on the Bootloader program to be updated, further comprising:
if the Bootloader program to be updated does not pass the integrity check, downloading a target Bootloader program through the Bootloader program;
carrying out integrity check on the target Bootloader program;
and if the target Bootloader program passes the integrity check, marking the target Bootloader program as the Bootloader program to be updated, and executing a reset operation.
5. The method of claim 4, wherein if the Bootloader program to be updated fails the integrity check, downloading the target Bootloader program by the Bootloader program comprises:
if the Bootloader program to be updated does not pass the integrity check, receiving an update message sent by an upper computer through the Bootloader program, wherein the update message comprises the initial address information and the data length information of a target Bootloader program;
and feeding back a receiving message to the upper computer according to the updating message, and receiving a target Bootloader program sent by the upper computer.
6. A device for updating Bootloader based on a chip, the device comprising:
the first checking unit is used for checking whether the check value in the first flag bit is valid or not;
the second checking unit is used for receiving the Bootloader program to be updated sent by the upper computer through the Bootloader program if the check value in the first flag bit is valid, and checking the integrity of the Bootloader program to be updated;
the first erasing unit is used for erasing the check value in the first flag bit through the Bootloader program to be updated if the Bootloader program to be updated passes the integrity check;
the second erasing unit is used for erasing the Bootloader program from the flash space through the Bootloader program to be updated;
the storage unit is used for storing Bootloader data in the Bootloader program to be updated into the flash space;
the third checking unit is used for carrying out integrity check on the Bootloader data in the flash space through the Bootloader program to be updated;
and the writing unit is used for writing the check value in the first flag bit and executing reset operation when the Bootloader data passes the integrity check.
7. The apparatus as recited in claim 6, further comprising:
a fourth checking unit, configured to check whether the check value in the second flag bit is valid if the check value in the first flag bit is invalid;
and the third erasing unit is used for erasing the check value in the first flag bit through the Bootloader program to be updated when the check value in the second flag bit is valid.
8. The apparatus as recited in claim 6, further comprising:
and the generating unit is used for generating alarm information and displaying the alarm information to a user when the check value in the second flag bit is invalid.
9. The apparatus as recited in claim 6, further comprising:
the downloading unit is used for downloading a target Bootloader program through the Bootloader program if the Bootloader program to be updated does not pass the integrity check;
a fifth checking unit, configured to perform integrity check on the target Bootloader program;
and the marking unit is used for marking the target Bootloader program as the Bootloader program to be updated if the target Bootloader program passes the integrity check, and executing the reset operation.
10. The apparatus of claim 6, wherein the download unit comprises:
the first receiving module is used for receiving an update message sent by an upper computer through the Bootloader program if the Bootloader program to be updated fails to pass the integrity check, wherein the update message comprises the initial address information and the data length information of the target Bootloader program;
and the second receiving module is used for feeding back a receiving message to the upper computer according to the updating message and receiving a target Bootloader program sent by the upper computer.
CN202311440132.1A 2023-11-01 2023-11-01 Method and device for updating Bootloader based on chip Pending CN117573174A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311440132.1A CN117573174A (en) 2023-11-01 2023-11-01 Method and device for updating Bootloader based on chip

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311440132.1A CN117573174A (en) 2023-11-01 2023-11-01 Method and device for updating Bootloader based on chip

Publications (1)

Publication Number Publication Date
CN117573174A true CN117573174A (en) 2024-02-20

Family

ID=89883434

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311440132.1A Pending CN117573174A (en) 2023-11-01 2023-11-01 Method and device for updating Bootloader based on chip

Country Status (1)

Country Link
CN (1) CN117573174A (en)

Similar Documents

Publication Publication Date Title
CN110231952B (en) ECU program backup and cyclic upgrade control method and device
ES2824830T3 (en) Software update procedure for an embedded device
KR100584338B1 (en) Software update method and system
US20110004871A1 (en) Embedded electronic device and firmware updating method thereof
US20070055969A1 (en) System and method for updating firmware
CN101826027A (en) Embedded system and updating method thereof
CN111796848A (en) Bootloader software updating method and device, embedded controller and storage medium
US5933595A (en) Computer apparatus having electrically rewritable nonvolatile memory, and nonvolatile semiconductor memory
CN105677409B (en) A kind of method for upgrading system and device
US20080140920A1 (en) Microcomputer for flash memory rewriting
CN110597532A (en) Data acquisition module, firmware upgrading method thereof and storage medium
EP1679599B1 (en) File update system and boot management system of mobile communication terminal, and corresponding methods
CN117573174A (en) Method and device for updating Bootloader based on chip
CN112527341B (en) Vehicle system upgrading method, vehicle system and computer storage medium
JP2008504628A (en) Safe flushing
KR100228717B1 (en) Method of coping with power off in laser printer
JP4238930B2 (en) Memory rewrite control system.
CN116185299A (en) Flash memory controller and related device and method
CN111796839B (en) Controller program management method and device
CN111158660B (en) Multi-mode on-orbit programming method for on-board software EEPROM (electrically erasable programmable read-Only memory)
CN111611000B (en) High-reliability firmware air upgrading method and system
CN114115755B (en) Method and device for data writing and storage medium
CN111190627A (en) System upgrading method and device
JP2004094628A (en) Flash memory memory rewrite control system, memory rewrite control method, and program for executing each step of memory rewrite control method
KR100624723B1 (en) Mobile communication terminal with hardware version control function and its operation method

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