WO2012071945A1 - Method and device for backing up and upgrading bootstrap - Google Patents

Method and device for backing up and upgrading bootstrap Download PDF

Info

Publication number
WO2012071945A1
WO2012071945A1 PCT/CN2011/080599 CN2011080599W WO2012071945A1 WO 2012071945 A1 WO2012071945 A1 WO 2012071945A1 CN 2011080599 W CN2011080599 W CN 2011080599W WO 2012071945 A1 WO2012071945 A1 WO 2012071945A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage area
boot program
upgrade
backup
module
Prior art date
Application number
PCT/CN2011/080599
Other languages
French (fr)
Chinese (zh)
Inventor
杨细龙
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2012071945A1 publication Critical patent/WO2012071945A1/en

Links

Classifications

    • 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/1417Boot up procedures

Definitions

  • the present invention relates to the field of embedded and computer, and in particular, to a method and apparatus for booting and upgrading a boot program. Background technique
  • the central processing unit (CPU) is configured to boot the minimum system startup. After the CPU's minimum system has successfully run, the drivers and system software of the peripheral function devices are loaded and the embedded products are functioning properly.
  • the boot code is generally stored in a non-volatile memory device, and the code size is generally 1K to 512K bytes. Due to various abnormal conditions, the data in the storage device may change, causing the device or board to fail to start, which affects the reliability of the product performance. Therefore, it is important to make the necessary backups of the startup program code.
  • startup code backup methods there are three popular startup code backup methods: 1. Using two identical storage devices to back up the boot code, which will occupy more hardware resources and occupy more storage space. Store the memory of the boot program, and specify one of the memories as the main boot memory.
  • the embodiment of the invention provides a method for booting and upgrading a boot program, which is used for implementing backup of the boot program and improving the reliability of the system.
  • a bootloader backup method comprising:
  • the first storage area is a current storage area
  • the identification information of the first storage area is recorded
  • a bootloader upgrade method comprising:
  • the first storage area After starting according to the main boot program in the first storage area, determine if an upgrade is required! a program; wherein, the first storage area is a current storage area;
  • the backup boot program in the second storage area is upgraded according to the obtained upgrade information.
  • a boot program backup device includes: an operation module and a control module; wherein, the operation module is configured to obtain a main boot program in the first storage area according to the default or the recorded identification information of the first storage area, And starting, wherein the first storage area is a current storage area;
  • control module configured to: after the startup is successful, record the identification information of the first storage area; and back up the primary boot program in the first storage area to the second storage area in the same storage.
  • a booting program upgrading apparatus comprising: a control module and an operation module; wherein, the control module is configured to determine whether the booting program needs to be upgraded after starting according to the main booting program in the first storage area;
  • the first storage area is the current storage area;
  • the operation module is configured to obtain upgrade information when determining that the boot program is to be upgraded, and upgrade the backup boot program in the second storage area according to the obtained upgrade information.
  • the first a main boot program in a storage area, and is started; wherein, the first storage area is a current storage area; after the startup is successful, the identification information of the first storage area is recorded; and the main boot program in the first storage area is Back up to the second storage area in the same storage.
  • the embodiment of the present invention provides two boot program storage areas in one memory, which does not occupy excessive hardware resources; no one of the two boot program storage areas is specified as the main boot program storage area, and the system can be started according to the last boot time.
  • the information of the boot program storage area saved after successful is started from the boot program storage area, and it is not necessary to be booted from the main boot program storage area, so that the startup speed is faster and the startup efficiency is higher; after the correct startup, the current storage area is The code is backed up to the non-current storage area, and the backup of the boot program is realized, which ensures the correctness of the boot program being backed up.
  • the backup process there is no need to modify the code of the current storage area, but only the corresponding register and other parts are modified, the modification content is small, the verification process is relatively simple, and the backup can be directly performed, and the operation process is simple.
  • the identification information of the current storage area is recorded as the chip selection signal, it can be completed by software without occupying hardware resources.
  • the embodiment of the present invention determines whether the boot program needs to be upgraded; when it is determined that the boot program is to be upgraded, the upgrade information is obtained; and the obtained upgrade information is used in the second storage area.
  • the backup bootloader is upgraded.
  • the embodiment of the present invention selects an upgrade in a non-current storage area to prevent the board from being restarted because the upgrade is unsuccessful, thereby improving the reliability of the system.
  • FIG. 1 is a main structural diagram of a bootloader backup device according to an embodiment of the present invention.
  • FIG. 1 is a detailed structural diagram of a bootloader backup device according to an embodiment of the present invention.
  • FIG. 3 is a main flowchart of a method for backing up a boot program according to an embodiment of the present invention
  • FIG. 4 is a flowchart of a detailed method for determining whether a startup is successful according to an embodiment of the present invention
  • FIG. 7 is a schematic diagram of whether it is required to upgrade after failing to upgrade a non-current storage area according to an embodiment of the present invention. Detailed method flow chart for the current storage area. detailed description
  • the embodiment of the present invention obtains the main booting program in the first storage area according to the default or the recorded identification information of the first storage area, and starts, wherein the first storage area is the current storage area; after the startup is successful And recording the identification information of the first storage area; and backing up the main navigation program in the first storage area to the second storage area in the same storage.
  • the embodiment of the present invention provides two boot program storage areas in one memory, which does not occupy excessive hardware resources; no one of the two boot program storage areas is specified as the main boot program storage area, and the program storage area is started, without limitation It must be started from the main boot program storage area to make the startup speed faster and the startup efficiency higher.
  • the current storage area code is backed up to the non-current storage area, which realizes the backup of the boot program and ensures the backup.
  • the correctness of the bootloader is During the backup process, there is no need to modify the code of the current storage area, and the backup can be directly performed, and the operation process is simple.
  • the identification information of the current storage area is recorded as a chip select signal, it can be completed by software without occupying hardware resources.
  • the embodiment of the present invention determines whether the boot program needs to be upgraded; when it is determined that the boot program is to be upgraded, the upgrade information is obtained; and the obtained upgrade information is used in the second storage area.
  • the backup bootloader is upgraded.
  • the embodiment of the present invention selects an upgrade in a non-current storage area to prevent the board from being restarted because the upgrade is unsuccessful, thereby improving the reliability of the system.
  • the bootloader backup device includes an operation module 101 and a control module 102.
  • the operation module 101 is configured to obtain a main booting program in the first storage area according to the default or the first identification information of the recorded storage area, and start, wherein the first storage area is a current storage area;
  • the boot program stored in the current storage area is referred to as a main boot program
  • the boot program stored in the non-current storage area is referred to as a backup boot program
  • the main boot program and the backup boot program are relatively speaking, for example, at a certain
  • the current storage area is the first storage area
  • the boot program stored in the first storage area is the main boot program
  • the boot program stored in the second storage area is the backup boot program
  • the current storage area For the second storage area, the boot program stored in the second storage area is the main boot program, and the boot program stored in the first storage area is the backup boot program.
  • the boot program storage area is determined in the storage module 103 according to the address information of the boot program storage area that was successfully started last time, and the boot program storage area is used as the current storage area. And starting according to the main boot program stored in the current storage area, that is, starting according to the code stored in the current storage area.
  • the startup is unsuccessful, and the reset operation is performed.
  • the reset operation may be a reset board. When the control technology overflows, a reset signal is sent to the operating module 101.
  • the control counter may be a watchdog counter, and when it overflows, a reset signal may be issued to reset the board.
  • the operation module 101 switches the backup boot program stored in the second storage area of the non-current storage area as the main boot program, that is, the first storage area and the second storage area are mutually switched, and the second storage area is the current storage area, and the operation is performed. The module 101 is restarted according to the main boot program stored in the second storage area.
  • the control module 102 records the total number of starts, and each time the start is performed, the total number of starts is incremented by one. If the control counter in the control module 102 overflows, the startup is still unsuccessful, the reset operation is performed, and the backup boot program stored in the first storage area is switched to the main boot program again, and the operation module 101 again according to the main storage stored in the first storage area. The boot program is started, and the startup process is repeated. If the number of startups reaches the first set value, for example, the first set value is M, and the startup is still unsuccessful, an alarm message may be sent, which may be a software alarm. It can also be a hardware alarm. For example, the hardware alarm can be the control module 102 with an indicator light or a buzzer.
  • the control module 102 can have a first counter for recording the total number of starts of the operation module 101 during the boot program backup process. The value of the first counter is incremented by one each time the operation module 101 starts. If the board is successfully started, the operation module 101 notifies the control module 102 to save the information of the current storage area, where the information includes at least the identification information of the current storage area, as the chip selection signal at the next startup.
  • the operation module 101 can copy the boot program code in the current storage area to the non-current storage area.
  • the backup of the bootloader Start downloading the full software version to get started.
  • the operation module 101 is further configured to: when it is determined that the boot program is to be upgraded, obtain upgrade information, and upgrade the backup boot program in the second storage area according to the obtained upgrade information.
  • the upgrade process may be automatically performed according to the setting of the control module 102, or may be performed after receiving the upgrade notification sent by the control module 102.
  • the operation module 101 first upgrades the non-current storage area according to the upgrade information.
  • the embodiment of the present invention takes the non-current storage area as the second storage area as an example. Because the current storage area, that is, the first storage area has been able to boot the operation module 101 to start normally, upgrading the second storage area first can ensure that the operation module 101 can still be normally started from the first storage area when the upgrade fails.
  • the operation module 101 After receiving the chip selection signal of the control module 102, the operation module 101 switches the upgraded boot program stored in the non-current storage area to the main boot program, performs a reset operation, and according to the main boot program stored in the second storage area. Start up. If the control counter in the control module 102 overflows, the startup is unsuccessful, and the operation module 101 switches the backup boot program stored in the first storage area to the main boot program, and upgrades the second storage area again, and thus repeats. If the number of upgrade failures of the second storage area reaches the second set value, for example, the second set value is N, it is determined that the upgrade to the non-current storage area, that is, the second storage area fails, and an alarm information may be sent, It is a software alarm or a hardware alarm.
  • the hardware alarm may be an alarm signal sent by the indicator light or buzzer of the control module 102.
  • an inquiry message is sent to ask whether to continue the upgrade process in the current storage area, that is, the first storage area. If the upgrade is selected to continue, the information stored in the first storage area is copied to the second storage area, and the old information stored in the second storage area is first erased before copying, and the backup stored in the second storage area is stored.
  • the boot program switches to the main boot program, performs a reset operation, starts according to the main boot program stored in the second storage area, and starts upgrading the first storage area. If you choose not to continue the upgrade, it is determined that the upgrade failed.
  • the number of upgrade failures N may be a preset value, and may be saved in the control module 102.
  • the control module 102 may have a second counter for calculating the number of upgrade failures for a bootloader storage area. When a bootloader is upgraded once, the value of the second counter is incremented by one.
  • the operation module 101 can be specifically a CPU.
  • the operation module 101 can be located on a single board.
  • the control module 102 is configured to record the identification information of the first storage area after the startup is successful; and back up the main boot program in the first storage area to the second storage area in the same storage.
  • a board needs to be started as an example.
  • the control module 102 can store information of a successful startup on the board, where the information includes at least the identification information of the bootloader storage area used in the last successful startup.
  • the device backed up by the program includes two bootstraps.
  • the program storage area is located in the storage module 103.
  • the two bootloader storage areas may have respective identification information, for example, one bootloader storage area is the first storage area and the other bootloader storage area is the second storage area.
  • the control module 102 reads the information of one successful startup of the board stored in the internal storage, and the storage module 103 according to the identifier information of the boot program storage area used in the last successful startup included in the information.
  • Determine the bootloader store for example,
  • the address information of the boot program storage area may be determined in the storage module 103, and the address information of the boot program storage area is used as a chip select signal, according to the!
  • the address information of the program storage area selects the boot program storage area to notify the operation module 101 to switch the boot program storage area to the current storage area, and starts according to the main boot program stored in the current storage area.
  • the notification may be sent to the operation module 101 through a lead to notify the operation module 101 according to the main stored in the boot program storage area!
  • the program starts.
  • control module 102 may include a control counter, and the control module 102 is further configured to determine whether the control counter overflows, and start the control counter while the control module 102 reads the information of the last successful startup stored in the internal control system.
  • the control counter starts counting automatically. If the board is successfully booted, the operation module 101 notifies the control module 102 to clear and close the control counter. If the control counter does not overflow, it is determined that the startup is successful, and if the control module 102 has not received the notification of clearing or closing the control counter for a certain period of time, the control counter will overflow, causing an interrupt, causing a system reset.
  • the control counter can be a watchdog counter.
  • the control module 102 When the watchdog counter overflows, a reset signal is generated to reset the board. If the board is successfully started, the control module 102 saves the information of the current storage area according to the notification of the operation module 101, and the information includes at least the identification information of the current storage area, and the counter is cleared and closed. The control module 102 is further configured to determine whether the boot program needs to be upgraded after booting according to the main boot program in the first storage area.
  • control module 102 is further configured to determine that the boot program needs to be upgraded after the operation module 101 starts according to the main boot program in the first storage area.
  • the control module 102 changes the chip selection signal, and sets the backup boot program stored in the upgraded non-current storage area as the main boot program, for example, upgrading the second storage area.
  • the second storage area and the first storage area are switched to each other, and the second storage area is selected as the current storage area.
  • the backup boot program stored in the second storage area is the main boot program, the control counter is turned on, and the operation is instructed.
  • Module 101 performs a reset operation and according to the main memory stored in the second storage area The bootloader starts.
  • control module 102 can be a programmable logic device, for example, an EPLD (Erasable Programmable Logic Device).
  • EPLD Erasable Programmable Logic Device
  • the control module 102 may or may not be located on a single board.
  • the control module 102 is not reset when the operation module 101 performs a reset operation.
  • FIG. 2 is a detailed structural diagram of a bootloader backup device according to an embodiment of the present invention. As shown in FIG. 2, the device further includes a storage module 103, a comparison module 104, and a determination module 105.
  • the storage module 103 is configured to provide Bootloader storage area.
  • the storage module 103 may include two boot program storage areas, that is, a first storage area and a second storage area, and the first storage area and the second storage area may be located in one memory.
  • the bootloader storage area used is called the current storage area when the board is booted, and the unused bootloader storage area is called the non-current storage area.
  • the storage module 103 can be located on the board or not on the board.
  • the memory module 103 is not reset when the operation module 101 performs a reset operation.
  • the comparison module 104 is configured to compare the bootstrap stored in the two bootloader storage areas.
  • the comparison module 104 compares the main boot program stored in the current storage area with the backup boot program stored in the non-current storage area. For example, a bitwise comparison manner may be adopted. Take the current storage area as the first storage area and the non-current storage area as the second storage area as an example. If the primary boot program stored in the first storage area is inconsistent with the backup boot program stored in the second storage area, the operation module 101 is notified to copy the boot program stored in the first storage area into the second storage area, and needs to be notified before copying. The operation module 101 first erases the old backup boot program stored in the second storage area.
  • the operation module 101 is notified that the startup process ends, so that the operation module 101 starts normal operation.
  • the control module 102 can be notified to generate a reset signal, and the reset signal is transmitted to the operation module 101, so that the operation module 101 performs a reset operation, resets the single-board device except the control module 102, and prepares the device.
  • the backup boot program stored in the second storage area is switched to the main boot program, and the operation module 101 continues to boot according to the main boot program stored in the second storage area to determine the backup! Whether the program can enable the operation module 101 to complete the startup, and verify the correctness of the backup boot program.
  • the comparison module 104 Before the upgrade process, the comparison module 104 first compares whether the main boot program stored in the current storage area is consistent with the backup boot program stored in the non-current storage area. If not, the operation module 101 can be notified to start the upgrade operation, otherwise the operation module 101 is notified. No upgrade is required. Take the current storage area as the first storage area and the non-current storage area as the second storage area as an example. In the upgrade process, after the operation module 101 upgrades the second storage area according to the upgrade information saved by itself, the comparison module 104 is further configured to save the backup boot program stored in the upgraded second storage area and the operation module 101. The upgrade information is compared. The second storage area is upgraded, and the upgrade information in the operation module 101 is burned into the non-current storage area.
  • the upgrade information in the operation module 101 is compared with the backup boot program stored in the second storage area after the burning, if the backup boot program stored in the upgraded second storage area is in the operation module 101. If the saved upgrade information is consistent, it is determined that the programming is successful. At this time, the control module 102 may be notified to set the backup boot program stored in the upgraded second storage area as the main boot program, if the upgraded second storage area is stored. If the backup boot program is inconsistent with the upgrade information saved in the operation module 101, if it is determined that the burning fails, the operation module 101 may be notified to perform the upgrade again, or the upgrade may be abandoned.
  • the comparison module 104 can receive the notification of the operation module 101, and perform the main boot program stored in the first storage area and the backup boot program stored in the second storage area. For comparison, if the unupgraded primary boot program stored in the first storage area is inconsistent with the upgraded backup boot program stored in the second storage area, the operation module 101 may be notified to copy the boot program stored in the second storage area to In the first storage area.
  • the determining module 105 is configured to determine whether the total number of starts exceeds the first set value.
  • the first set value may be M, and may be saved in the control module 102.
  • the determining module 105 determines, according to the value in the first counter, the total number of startups at this time is If the number of starts reaches M, the alarm information may be sent, which may be a software alarm or a hardware alarm.
  • the hardware alarm may be the control module 102 using an indicator light or a buzzer as an alarm signal. The system fails to start and the board is faulty. If the number of starts does not reach M, the notification operation module 101 can continue the startup operation.
  • the determining module 105 is further configured to determine whether the number of upgrade failures exceeds a second set value, and the second set value may be N, which may be saved in the control module 102.
  • the determining module 105 determines, according to the value in the second counter, whether the number of upgrade failures to the non-current storage area reaches N at this time. If the number of upgrades reaches N, an alarm message may be sent, which may be a software alarm. It can also be a hardware alarm.
  • the hardware alarm may be that the control module 102 uses an indicator light or a buzzer as an alarm signal to determine that the upgrade of the non-current storage area fails, and may notify the operation module 101 to send an inquiry message to ask whether Need to continue to upgrade the current storage area. If the number of upgrades does not reach N, the notification operation module 101 can continue the upgrade process.
  • the following describes the bootloader backup method through a specific process.
  • FIG. 3 is a main flowchart of a method for backing up a boot program according to an embodiment of the present invention. As shown in FIG. 3, the main method for booting a backup program in the embodiment of the present invention is as follows:
  • Step 301 Obtain a primary booting program in the first storage area according to the default or the recorded identification information of the first storage area, and start.
  • Step 302 After the startup is successful, record the identification information of the first storage area.
  • Step 303 Back up the main boot program in the first storage area to the second storage area in the same storage.
  • the method further includes: performing a reset operation, switching the second storage area to the current storage area, restarting, and recording the total number of startups.
  • the method further includes: determining whether the total number of startups is greater than the first set value, and when the determination result is yes, determining that the startup fails, and issuing an alarm message, Otherwise continue the reset operation.
  • the method further includes: determining whether the primary boot program stored in the first storage area is The backup boot program stored in the second storage area is consistent. When the determination result is no, the primary boot program stored in the first storage area is backed up to the second storage area.
  • the present invention also includes a bootloader upgrade method, the method comprising: determining whether a bootloader needs to be upgraded after booting according to a primary bootloader in the first storage area; wherein the first storage area is a current storage area When you are sure that you need to upgrade the bootloader, get the upgrade information; upgrade the backup bootloader in the second storage area according to the obtained upgrade information.
  • the method further includes: determining whether the primary booting program stored in the first storage area is consistent with the backup booting program stored in the second storage area, and determining whether the result is negative Upgrade the bootstrap.
  • the method further includes: switching the upgraded second storage area to the current storage area; according to the second storage area
  • the main boot program in the startup starts, and the upgrade is successful when the startup is successful.
  • the method further includes:
  • the determination result is yes, it is determined whether the number of upgrade failures is greater than a second preset value.
  • the backup boot program in the first storage area is switched to the primary boot program. Reset operation, and starting according to the main boot program stored in the first storage area;
  • the backup boot program in the first storage area is copied to the second storage area to perform a reset operation. And switching the second storage area to the current storage area, according to the main storage stored in the second storage area! The program starts.
  • FIG. 4 is a flowchart of a detailed method for determining whether the startup is successful according to an embodiment of the present invention. As shown in FIG. 4, the detailed method for determining whether the startup is successful in the embodiment of the present invention is as follows:
  • Step 401 The board is powered on. In the embodiment of the present invention, whether the board is successfully started is taken as an example; Step 402: reading the boot program storage area information that was successfully started last time;
  • the control module 102 saves the information of the boot program storage area that is successfully started, and the information includes at least the identification information of the successfully booted boot program storage area, so that the operation module 101 is based on the identification information.
  • the boot storage area is a first storage area as an example.
  • Step 403 Turn on the control counter.
  • the control module 102 turns on the control counter, and controls the counter to start counting;
  • control counter can be a watchdog counter.
  • Step 404 Place the bow stored in the first storage area! The program switches to the main boot program;
  • Step 405 According to the main memory stored in the first storage area! The program starts to start;
  • Step 403 and step 404 need to be performed simultaneously.
  • the control module 102 sends the identification information of the boot program storage area to the operation module 101 as a chip select signal, which is the identification information of the successfully booted boot program storage area recorded in step 402.
  • the operation module 101 determines the boot program stored in the first storage area as the main boot program according to the chip select signal, and starts the boot process.
  • Step 406 Determine whether the control counter overflows. When the result of the determination is YES, the process proceeds to step 407. Otherwise continue to step 413;
  • Step 407 Determine whether the number of starts is greater than M. When the judgment result is no, continue the step. 408, otherwise proceed to step 412;
  • Step 408 Switch the backup boot program stored in the second storage area to the main boot program, and reset the board.
  • control module 102 clears and closes the control counter while resetting the board, and the control counter starts counting again. If the operation module 101 and the control module 102 are both located on the board, the reset board operation in this step should be changed to the reset operation module 101. If the operation module 101 is located on the board and the control module 102 is not located on the board, then This step can be to reset the board.
  • Step 409 Start according to the main boot program stored in the second storage area
  • Step 410 Determine whether the control counter overflows. When the determination result is yes, proceed to step 411, otherwise continue to step 413;
  • Step 411 Determine whether the number of starts is greater than M, when the determination result is no, proceed to step 404, and still need to reset the board while performing step 404, otherwise continue to step 412;
  • Step 412 Determine that the startup fails, and issue an alarm message
  • Step 413 Determine that the startup is successful, and save the identification information of the current storage area. At the same time, control module 102 clears and closes the counter.
  • Step 501 The startup succeeds, and the identifier information of the current storage area is saved.
  • this step is the same as step 413 in the flow shown in FIG. 4, and after the step 413 in the flow of FIG. 4 is executed, the following flow can also be executed.
  • the current storage area is the first storage area
  • the non-current storage area is the second storage area.
  • Step 502 determining whether the primary boot program stored in the first storage area is consistent with the backup boot program stored in the second storage area, and if the determination result is no, proceed to step 503, otherwise proceed to step 505; Step 503: Back up the main boot program stored in the first storage area to the second storage area.
  • the backup is specifically performing backup processing on the main boot program stored in the first storage area after the successful startup.
  • the backup method can be copy.
  • Step 504 It is determined whether the primary boot program stored in the first storage area is consistent with the backup boot program stored in the second storage area. When the determination result is no, proceed to step 503, otherwise continue the step.
  • this step is to prevent errors during the backup process.
  • Step 505 The bootloader backup is complete.
  • the backup boot program stored in the second storage area can be further switched to the main boot program, the reset operation is performed, and the boot process is continued to verify whether the boot program after the backup can be The operation module 101 is caused to complete startup.
  • Step 601 Upgrade the second storage area
  • the upgrade information in the operation module 10 ⁇ is burned into the non-current storage area.
  • the second storage area is a non-current storage area
  • the first storage area is a current storage area.
  • Step 602 Determine whether the boot program burned in the second storage area is consistent with the upgrade information. When the determination result is yes, proceed to step 603, otherwise continue to step 601;
  • the upgrade information saved in the operation module 101 is compared with the boot program burned into the second storage area, if the upgrade information in the operation module 101 is burned into the non-current storage area. If the boot program is consistent, the burning is successful. If the upgrade information in the operation module 101 is inconsistent with the boot program in the non-current storage area, the burning is unsuccessful and the burning is required.
  • Step 603 Send the updated chip select signal to the operation module 101, and turn on the control counter.
  • the module 103 sends the updated identification information of the second storage area to the operation module 101 as a chip selection signal, and turns on the control counter, and the control counter starts counting.
  • Step 604 Set the upgraded backup boot program stored in the second storage area as the main boot program, perform a reset operation, and the operation module 101 stores the upgraded backup boot program stored in the second storage area according to the chip select signal. Set as the main boot program;
  • Step 605 Start according to the main boot program stored in the second storage area
  • Step 606 Determine whether the control counter overflows, when the determination result is yes, proceed to step 607, otherwise continue to step 610;
  • Step 607 determining whether the number of upgrade failures is greater than N, when the determination result is no, proceed to step 608, otherwise proceed to step 609;
  • Step 608 Switch the backup boot program stored in the first storage area to the main boot program, perform a reset operation, and continue to step 601.
  • the control module 102 clears the control counter, and the control counter starts to recount;
  • Step 609 Determine that the non-current storage area upgrade fails, and the alarm information may be sent;
  • Step 610 Determine that the non-current storage area is successfully upgraded.
  • FIG. 7 is a flowchart of a detailed method for determining whether to upgrade a current storage area after a failure to upgrade a non-current storage area according to an embodiment of the present invention. As shown in FIG. 7, the embodiment of the present invention determines that the upgrade to a non-current storage area fails. Whether you need to upgrade the current storage area detailed method flow:
  • Step 701 Determine that the second storage area upgrade fails.
  • this step is the same step as step 612 in the flow shown in FIG. 6.
  • the second storage area is a non-current storage area
  • the first storage area is a current storage area.
  • Step 702 Determine whether it is necessary to upgrade the first storage area. When the judgment result is yes, continue step Step 703, otherwise the process ends;
  • Step 703 Copy the primary boot program stored in the first storage area to the second storage area; wherein, the backup boot program stored in the second storage area needs to be erased before copying.
  • Step 704 Perform a reset operation. At this time, the control module 102 clears the control counter, and controls the counter to start counting again.
  • Step 705 Switch the backup boot program stored in the second storage area to the primary boot program.
  • Step 706 Upgrade the first storage area.
  • the upgrade information in the operation module 101 is burned into the first storage area. This step is the same as step 601 shown in Fig. 6.
  • the following flow is also consistent with Fig. 6. That is, when the upgrade to the non-current storage area fails, an attempt is made to continue the upgrade of the current storage area.
  • the operation module 101 may be automatically upgraded after being successfully started, or may be upgraded after receiving the upgrade notification.
  • the embodiment of the present invention obtains the main booting program in the first storage area according to the default or the recorded identification information of the first storage area, and starts, wherein the first storage area is the current storage area; after the startup is successful And recording the identification information of the first storage area; and backing up the main boot program in the first storage area to the second storage area in the same storage.
  • the embodiment of the present invention provides two boot program storage areas in one memory, which does not occupy excessive hardware resources; no one of the two boot program storage areas is specified as the main boot program storage area, and the system can be started according to the last boot time.
  • the information of the boot program storage area saved after successful is started from the boot program storage area, and it is not necessary to be booted from the main boot program storage area, so that the startup speed is faster and the startup efficiency is higher; after the correct startup, the current storage area is The code is backed up to the non-current storage area, and the backup of the boot program is realized, which ensures the correctness of the boot program being backed up.
  • the backup process there is no need to modify the code of the current storage area, and the backup can be directly performed, and the operation process is simple.
  • the identification information of the current storage area is recorded as the chip selection signal, it can be completed by software without occupying hardware resources.
  • the embodiment of the present invention further determines that the boot program needs to be upgraded under the main boot program in the first storage area; obtains the upgrade information; and performs the backup boot program in the second storage area according to the obtained upgrade information. Upgrade.
  • the embodiment of the present invention selects the upgrade in the non-current storage area to prevent the board from being restarted due to the unsuccessful upgrade, thereby improving the reliability of the system.
  • the upper limit value of the total number of times of starting the operation module 101 is set. If the total number of startups exceeds the upper limit value, it is determined that the startup fails, the operation module 101 is prevented from being continuously started, resources are wasted, and the hardware is easily damaged.
  • the operation module 101 can upgrade the boot program storage area to obtain a higher boot program version, and the board startup process is more optimized.
  • the master stored in the current store! The program is compared with the backup boot program stored in the non-current storage area. If the two are inconsistent, the upgrade process is performed. Otherwise, no upgrade is required to avoid waste of resources.
  • the upgrade information is first verified to ensure the correctness of the upgrade information. After the upgrade is completed, it is also required to start according to the boot program stored in the upgraded boot program storage area to further verify whether the upgrade is successful.
  • the non-current storage area is upgraded to ensure that when the upgrade is unsuccessful, the operation module 101 can also start according to the main boot program stored in the current storage area.
  • the method and device according to the embodiment of the present invention can support online upgrade, set an upper limit of the number of upgrade failures, and deal with faults that may occur during the upgrade, thereby ensuring the correctness of the upgrade.
  • embodiments of the present invention can be provided as a method, system, or computer program product.
  • the present invention can take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware.
  • the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) in which computer usable program code is embodied.
  • These computer program instructions can be provided to a processor of a general purpose computer, a special purpose computer, an embedded processor or other programmable data processing device to generate a A device that, by means of instructions executed by a processor of a computer or other programmable data processing device, produces means for implementing the functions specified in one or more flows of the flowchart, and/or in a block or blocks of the block diagram. .
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more flows of the flowchart, and/or in a block or blocks of the block diagram.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more flows of the flowchart, and/or in a block or blocks of the block diagram.

Abstract

Disclosed are a method for backing up a bootstrap, for achieving the backup of the bootstrap and improving the reliability of system start-up. The method includes: acquiring a master bootstrap in a first storage area and starting up according to the default or recorded identification information about the first storage area, wherein the first storage area is a current storage area; recording the identification information about the first storage area after successful start-up; and backing up the master bootstrap of the first storage area into a second storage area in the same storage. Also disclosed is a method for upgrading a bootstrap, for achieving the upgrading of the bootstrap. The method includes: determining whether a bootstrap is required to be upgraded after having started up according to a master bootstrap in a first storage area; acquiring upgrading information when it is determined to upgrade the bootstrap; and upgrading the backed up bootstrap in a second storage area according to the acquired upgrading information. Also disclosed is a device for achieving the method.

Description

一种引导程序备份和升级的方法及装置 技术领域  Method and device for booting program backup and upgrade
本发明涉及嵌入式及计算机领域, 特别涉及一种引导程序备份和升级 的方法及装置。 背景技术  The present invention relates to the field of embedded and computer, and in particular, to a method and apparatus for booting and upgrading a boot program. Background technique
在复杂嵌入式产品中, 设备上电或复位后通常需要一段简单的引导程 序代码, 对中央处理器(Central Processing Unit, CPU )做必要配置, 引导 CPU最小系统正常启动。 在 CPU最小系统成功运行之后, 再装载外围功能 器件的驱动程序和系统软件, 并实现嵌入式产品的正常运转。  In complex embedded products, a simple bootloader code is usually required after powering up or resetting the device. The central processing unit (CPU) is configured to boot the minimum system startup. After the CPU's minimum system has successfully run, the drivers and system software of the peripheral function devices are loaded and the embedded products are functioning properly.
引导程序代码一般存储于非易失性存储器件中, 代码大小一般为 1K~512K字节。 由于各种异常情况的存在,存储器件中的数据可能会变化, 导致设备或单板启动失败, 影响产品性能的可靠性。 因此, 对启动程序代 码作必要的备份就显得十分重要。 目前较为流行的启动代码备份方法主要 有以下三种: 一、 利用两个完全相同的存储器件对引导代码进行备份, 这 样会占用较多硬件资源, 也占用较多的存储空间; 二、 设置两个存储引导 程序的存储器, 并规定其中一个存储器为主引导存储器, 备份引导程序时 不仅需要修改相应寄存器等部分, 还需要将原引导程序信息进行相应修改, 这样会使校验方法较为复杂; 三、 在一个存储器中设置两个存储引导程序 的存储区, 并规定其中一个存储区为主引导存储区, 还另外增加了存储硬 件以存储片选信号, 系统每次启动都需从主引导存储器开始, 这样会使启 动速度减慢, 启动效率降低, 另外增加硬件资源来存放片选信号, 造成了 硬件资源的浪费。 并且, 上述方法增加了辅助器件, 同时增加了系统运行 的不可靠因素。 发明内容 The boot code is generally stored in a non-volatile memory device, and the code size is generally 1K to 512K bytes. Due to various abnormal conditions, the data in the storage device may change, causing the device or board to fail to start, which affects the reliability of the product performance. Therefore, it is important to make the necessary backups of the startup program code. At present, there are three popular startup code backup methods: 1. Using two identical storage devices to back up the boot code, which will occupy more hardware resources and occupy more storage space. Store the memory of the boot program, and specify one of the memories as the main boot memory. When backing up the boot program, not only the corresponding registers and other parts need to be modified, but also the original boot program information needs to be modified accordingly, which makes the verification method more complicated; Setting two storage areas for storing the boot program in one memory, and specifying one of the storage areas as the main boot storage area, and additionally adding storage hardware to store the chip select signal, the system needs to start from the main boot memory every time the system starts up. This will slow down the startup speed, reduce the startup efficiency, and increase the hardware resources to store the chip select signal, resulting in waste of hardware resources. Moreover, the above method increases the auxiliary device while increasing the unreliable factors of system operation. Summary of the invention
本发明实施例提供一种引导程序备份和升级的方法, 用于实现对引导 程序的备份, 提高了系统的可靠性。  The embodiment of the invention provides a method for booting and upgrading a boot program, which is used for implementing backup of the boot program and improving the reliability of the system.
一种引导程序备份方法, 所述方法包括:  A bootloader backup method, the method comprising:
根据默认的或者记录的第一存储区的标识信息, 获得第一存储区中的 主引导程序, 并进行启动; 其中, 所述第一存储区为当前存储区;  Obtaining, according to the identifier information of the default or the first storage area, the main booting program in the first storage area, and starting; wherein, the first storage area is a current storage area;
启动成功后, 记录第一存储区的标识信息;  After the startup is successful, the identification information of the first storage area is recorded;
将第一存储区中的主引导程序备份到同一存储器中的第二存储区。 一种引导程序升级方法, 所述方法包括:  The primary boot program in the first storage area is backed up to the second storage area in the same memory. A bootloader upgrade method, the method comprising:
在根据第一存储区中的主引导程序进行启动后, 确定是否需要升级 ! 导程序; 其中, 所述第一存储区为当前存储区;  After starting according to the main boot program in the first storage area, determine if an upgrade is required! a program; wherein, the first storage area is a current storage area;
当确定要升级引导程序时, 获得升级信息;  Obtain upgrade information when it is determined that the bootstrap is to be upgraded;
根据获得的升级信息对第二存储区中的备份引导程序进行升级。  The backup boot program in the second storage area is upgraded according to the obtained upgrade information.
一种引导程序备份装置, 所述装置包括: 操作模块和控制模块; 其中, 操作模块, 用于根据默认的或者记录的第一存储区的标识信息, 获得 第一存储区中的主引导程序, 并进行启动; 其中, 所述第一存储区为当前 存储区;  A boot program backup device, the device includes: an operation module and a control module; wherein, the operation module is configured to obtain a main boot program in the first storage area according to the default or the recorded identification information of the first storage area, And starting, wherein the first storage area is a current storage area;
控制模块, 用于在启动成功后, 记录第一存储区的标识信息; 将第一 存储区中的主引导程序备份到同一存储器中的第二存储区。  And a control module, configured to: after the startup is successful, record the identification information of the first storage area; and back up the primary boot program in the first storage area to the second storage area in the same storage.
一种引导程序升级装置, 所述装置包括: 控制模块和操作模块; 其中, 控制模块, 用于根据第一存储区中的主引导程序进行启动后, 确定是 否需要升级引导程序; 其中, 所述第一存储区为当前存储区;  A booting program upgrading apparatus, the apparatus comprising: a control module and an operation module; wherein, the control module is configured to determine whether the booting program needs to be upgraded after starting according to the main booting program in the first storage area; The first storage area is the current storage area;
操作模块, 用于当确定要升级引导程序时, 获得升级信息, 及根据获 得的升级信息对第二存储区中的备份引导程序进行升级。  The operation module is configured to obtain upgrade information when determining that the boot program is to be upgraded, and upgrade the backup boot program in the second storage area according to the obtained upgrade information.
本发明实施例根据默认的或者记录的第一存储区的标识信息, 获得第 一存储区中的主引导程序, 并进行启动; 其中, 所述第一存储区为当前存 储区; 在启动成功后, 记录第一存储区的标识信息; 将第一存储区中的主 引导程序备份到同一存储器中的第二存储区。 本发明实施例在一个存储器 中提供了两个引导程序存储区, 不会占用过多硬件资源; 没有规定两个引 导程序存储区中谁为主引导程序存储区, 系统启动时可根据上次启动成功 后保存的引导程序存储区的信息从该引导程序存储区进行启动, 无需限定 必须从主引导程序存储区启动, 使启动速度较快, 启动效率较高; 在正确 启动后将当前存储区的代码备份到非当前存储区中, 实现了引导程序的备 份, 保证了所备份的引导程序的正确性。 在备份过程中, 无需对当前存储 区的代码做出修改, 而只是修改了相应寄存器等部分, 修改内容较少, 校 验过程比较简单, 可以直接进行备份, 操作过程简便。 并且, 记录当前存 储区的标识信息作为片选信号时可以通过软件完成, 无需占用硬件资源。 According to the embodiment of the present invention, according to the default or recorded identification information of the first storage area, the first a main boot program in a storage area, and is started; wherein, the first storage area is a current storage area; after the startup is successful, the identification information of the first storage area is recorded; and the main boot program in the first storage area is Back up to the second storage area in the same storage. The embodiment of the present invention provides two boot program storage areas in one memory, which does not occupy excessive hardware resources; no one of the two boot program storage areas is specified as the main boot program storage area, and the system can be started according to the last boot time. The information of the boot program storage area saved after successful is started from the boot program storage area, and it is not necessary to be booted from the main boot program storage area, so that the startup speed is faster and the startup efficiency is higher; after the correct startup, the current storage area is The code is backed up to the non-current storage area, and the backup of the boot program is realized, which ensures the correctness of the boot program being backed up. In the backup process, there is no need to modify the code of the current storage area, but only the corresponding register and other parts are modified, the modification content is small, the verification process is relatively simple, and the backup can be directly performed, and the operation process is simple. Moreover, when the identification information of the current storage area is recorded as the chip selection signal, it can be completed by software without occupying hardware resources.
本发明实施例还在根据第一存储区中的主引导程序进行启动后, 确定 是否需要升级引导程序; 当确定要升级引导程序时, 获得升级信息; 根据 获得的升级信息对第二存储区中的备份引导程序进行升级。 本发明实施例 选择在非当前存储区中进行升级, 以避免因升级不成功而导致单板无法再 次启动, 提高了系统的可靠性。 附图说明  After the startup according to the main boot program in the first storage area, the embodiment of the present invention determines whether the boot program needs to be upgraded; when it is determined that the boot program is to be upgraded, the upgrade information is obtained; and the obtained upgrade information is used in the second storage area. The backup bootloader is upgraded. The embodiment of the present invention selects an upgrade in a non-current storage area to prevent the board from being restarted because the upgrade is unsuccessful, thereby improving the reliability of the system. DRAWINGS
图 1为本发明实施例中引导程序备份装置的主要结构图;  1 is a main structural diagram of a bootloader backup device according to an embodiment of the present invention;
图 1为本发明实施例中引导程序备份装置的详细结构图;  1 is a detailed structural diagram of a bootloader backup device according to an embodiment of the present invention;
图 3为本发明实施例中引导程序备份方法的主要流程图;  3 is a main flowchart of a method for backing up a boot program according to an embodiment of the present invention;
图 4为本发明实施例中判断是否启动成功的详细方法流程图;  4 is a flowchart of a detailed method for determining whether a startup is successful according to an embodiment of the present invention;
图 7为本发明实施例中在确定对非当前存储区升级失败后是否需要升 级当前存储区的详细方法流程图。 具体实施方式 FIG. 7 is a schematic diagram of whether it is required to upgrade after failing to upgrade a non-current storage area according to an embodiment of the present invention; Detailed method flow chart for the current storage area. detailed description
本发明实施例根据默认的或者记录的第一存储区的标识信息, 获得第 一存储区中的主引导程序, 并进行启动; 其中, 所述第一存储区为当前存 储区; 在启动成功后, 记录第一存储区的标识信息; 将第一存储区中的主 弓 I导程序备份到同一存储器中的第二存储区。  The embodiment of the present invention obtains the main booting program in the first storage area according to the default or the recorded identification information of the first storage area, and starts, wherein the first storage area is the current storage area; after the startup is successful And recording the identification information of the first storage area; and backing up the main navigation program in the first storage area to the second storage area in the same storage.
本发明实施例在一个存储器中提供了两个引导程序存储区, 不会占用 过多硬件资源; 没有规定两个引导程序存储区中谁为主引导程序存储区, 程序存储区进行启动, 无需限定必须从主引导程序存储区启动, 使启动速 度较快, 启动效率较高; 在正确启动后将当前存储区的代码备份到非当前 存储区中, 实现了引导程序的备份, 保证了所备份的引导程序的正确性。 在备份过程中, 无需对当前存储区的代码做出修改, 可以直接进行备份, 操作过程简便。 并且, 记录当前存储区的标识信息作为片选信号时可以通 过软件完成, 无需占用硬件资源。  The embodiment of the present invention provides two boot program storage areas in one memory, which does not occupy excessive hardware resources; no one of the two boot program storage areas is specified as the main boot program storage area, and the program storage area is started, without limitation It must be started from the main boot program storage area to make the startup speed faster and the startup efficiency higher. After the correct startup, the current storage area code is backed up to the non-current storage area, which realizes the backup of the boot program and ensures the backup. The correctness of the bootloader. During the backup process, there is no need to modify the code of the current storage area, and the backup can be directly performed, and the operation process is simple. Moreover, when the identification information of the current storage area is recorded as a chip select signal, it can be completed by software without occupying hardware resources.
本发明实施例还在根据第一存储区中的主引导程序进行启动后, 确定 是否需要升级引导程序; 当确定要升级引导程序时, 获得升级信息; 根据 获得的升级信息对第二存储区中的备份引导程序进行升级。 本发明实施例 选择在非当前存储区中进行升级, 以避免因升级不成功而导致单板无法再 次启动, 提高了系统的可靠性。  After the startup according to the main boot program in the first storage area, the embodiment of the present invention determines whether the boot program needs to be upgraded; when it is determined that the boot program is to be upgraded, the upgrade information is obtained; and the obtained upgrade information is used in the second storage area. The backup bootloader is upgraded. The embodiment of the present invention selects an upgrade in a non-current storage area to prevent the board from being restarted because the upgrade is unsuccessful, thereby improving the reliability of the system.
图 1为本发明实施例中引导程序备份装置的主要结构图, 如图 1所示, 本发明实施例中引导程序备份装置包括操作模块 101及控制模块 102。  1 is a main structural diagram of a bootloader backup device according to an embodiment of the present invention. As shown in FIG. 1, the bootloader backup device includes an operation module 101 and a control module 102.
操作模块 101 , 用于根据默认的或者记录的第一存储区的标识信息, 获 得第一存储区中的主引导程序, 并进行启动; 其中, 所述第一存储区为当 前存储区; 具体的, 当前存储区中存储的引导程序被称为主引导程序, 非当前存 储区中存储的引导程序被称为备份引导程序, 主引导程序与备份引导程序 是相对而言, 例如, 在某一时刻, 当前存储区为第一存储区, 则此时第一 存储区中存储的引导程序为主引导程序, 第二存储区中存储的引导程序为 备份引导程序; 在下一时刻, 当前存储区为第二存储区, 则此时第二存储 区中存储的引导程序为主引导程序, 第一存储区中存储的引导程序为备份 引导程序。 本实施例中操作模块 101得到控制模块 102的通知后, 根据上 一次成功启动的引导程序存储区的地址信息在存储模块 103 中确定该引导 程序存储区, 将该引导程序存储区作为当前存储区, 并根据该当前存储区 中存储的主引导程序进行启动, 即根据该当前存储区中存储的代码进行启 动。 The operation module 101 is configured to obtain a main booting program in the first storage area according to the default or the first identification information of the recorded storage area, and start, wherein the first storage area is a current storage area; Specifically, the boot program stored in the current storage area is referred to as a main boot program, and the boot program stored in the non-current storage area is referred to as a backup boot program, and the main boot program and the backup boot program are relatively speaking, for example, at a certain At one moment, the current storage area is the first storage area, then the boot program stored in the first storage area is the main boot program, and the boot program stored in the second storage area is the backup boot program; at the next moment, the current storage area For the second storage area, the boot program stored in the second storage area is the main boot program, and the boot program stored in the first storage area is the backup boot program. After the operation module 101 is notified by the control module 102 in this embodiment, the boot program storage area is determined in the storage module 103 according to the address information of the boot program storage area that was successfully started last time, and the boot program storage area is used as the current storage area. And starting according to the main boot program stored in the current storage area, that is, starting according to the code stored in the current storage area.
如果控制模块 102 中的用于控制复位操作的控制计数器溢出, 则启动 未成功, 进行复位操作, 其中, 如果操作模块 101 位于单板上, 则复位操 作可以是复位单板。 当控制技术器溢出时, 会向操作模块 101 发送复位信 号。 所述控制计数器可以是看门狗计数器, 当其溢出时, 可以发出复位信 号, 使单板复位。 操作模块 101 将非当前存储区的第二存储区中存储的备 份引导程序切换为主引导程序, 即将第一存储区和第二存储区互相切换, 此时第二存储区为当前存储区, 操作模块 101 根据第二存储区中存储的主 引导程序进行重新启动。 控制模块 102记录启动总次数, 每进行一次启动, 则将启动总次数加 1。如果控制模块 102中的控制计数器溢出, 启动仍未成 功, 进行复位操作, 再次将第一存储区中存储的备份引导程序切换为主引 导程序, 操作模块 101再次根据第一存储区中存储的主引导程序进行启动, 如此反复进行启动过程, 如果启动的次数达到了第一设定值, 例如第一设 定值为 M, 而启动仍未成功, 此时可以发出告警信息, 可以是软件告警, 也可以是硬件告警, 例如, 硬件告警可以是控制模块 102 以指示灯或蜂鸣 器作为告警信号, 则认为系统启动失败, 该单板故障。 其中, 次数 M可以 为预先设定值, 可以保存在控制模块 102中。 控制模块 102中可以有一个 第一计数器, 用于记录引导程序备份过程中操作模块 101 的启动总次数, 操作模块 101每进行一次启动, 则该第一计数器的值加 1。如果单板启动成 功, 则操作模块 101通知控制模块 102保存当前存储区的信息, 所述信息 至少包括当前存储区的标识信息, 以作为下次启动时的片选信号。 清零并 关闭控制计数器, 并且, 如果当前存储区中的主引导程序与非当前存储区 中的备份引导程序不一致, 则操作模块 101 可以将当前存储区中的引导程 序代码复制到非当前存储区中, 实现引导程序的备份。 开始下载完全软件 版本, 以开始正常工作。 If the control counter for controlling the reset operation in the control module 102 overflows, the startup is unsuccessful, and the reset operation is performed. If the operation module 101 is located on the board, the reset operation may be a reset board. When the control technology overflows, a reset signal is sent to the operating module 101. The control counter may be a watchdog counter, and when it overflows, a reset signal may be issued to reset the board. The operation module 101 switches the backup boot program stored in the second storage area of the non-current storage area as the main boot program, that is, the first storage area and the second storage area are mutually switched, and the second storage area is the current storage area, and the operation is performed. The module 101 is restarted according to the main boot program stored in the second storage area. The control module 102 records the total number of starts, and each time the start is performed, the total number of starts is incremented by one. If the control counter in the control module 102 overflows, the startup is still unsuccessful, the reset operation is performed, and the backup boot program stored in the first storage area is switched to the main boot program again, and the operation module 101 again according to the main storage stored in the first storage area. The boot program is started, and the startup process is repeated. If the number of startups reaches the first set value, for example, the first set value is M, and the startup is still unsuccessful, an alarm message may be sent, which may be a software alarm. It can also be a hardware alarm. For example, the hardware alarm can be the control module 102 with an indicator light or a buzzer. If the device is used as an alarm, the system fails to be started and the board is faulty. The number of times M may be a preset value and may be saved in the control module 102. The control module 102 can have a first counter for recording the total number of starts of the operation module 101 during the boot program backup process. The value of the first counter is incremented by one each time the operation module 101 starts. If the board is successfully started, the operation module 101 notifies the control module 102 to save the information of the current storage area, where the information includes at least the identification information of the current storage area, as the chip selection signal at the next startup. Clearing and closing the control counter, and if the main boot program in the current storage area is inconsistent with the backup boot program in the non-current storage area, the operation module 101 can copy the boot program code in the current storage area to the non-current storage area. In the implementation of the backup of the bootloader. Start downloading the full software version to get started.
进一步的, 操作模块 101 还用于当确定要升级引导程序时, 获得升级 信息, 及根据获得的升级信息对第二存储区中的备份引导程序进行升级。 在操作模块 101启动成功后, 可以根据控制模块 102的设置自动进行升级 过程, 或者也可以在接到控制模块 102发送的升级通知后进行升级过程。 操作模块 101 首先根据升级信息升级非当前存储区, 本发明实施例以非当 前存储区为第二存储区为例。 因为当前存储区, 即第一存储区已经能够引 导操作模块 101 正常启动, 先升级第二存储区可以确保升级失败时操作模 块 101仍然可以从第一存储区中正常启动。 操作模块 101在接到控制模块 102 的片选信号后将升级后的非当前存储区中存储的备份引导程序切换为 主引导程序, 进行复位操作, 并根据第二存储区中存储的主引导程序进行 启动。 如果控制模块 102 中的控制计数器溢出, 则启动不成功, 操作模块 101将第一存储区中存储的备份引导程序切换为主引导程序,再次对第二存 储区进行升级, 如此反复进行。 如果对第二存储区的升级失败次数达到了 第二设定值, 例如第二设定值为 N, 则确定对非当前存储区, 即第二存储 区的升级失败, 可以发出告警信息, 可以是软件告警, 也可以是硬件告警, 例如, 硬件告警可以是通过控制模块 102的指示灯或蜂鸣器发出告警信号。 并且发出询问信息, 以询问是否要继续在当前存储区, 即第一存储区进行 升级过程。 如果选择继续升级, 则将第一存储区中存储的信息复制到第二 存储区, 在复制之前首先要擦除第二存储区中存储的旧的信息, 并将第二 存储区中存储的备份引导程序切换为主引导程序, 进行复位操作, 根据第 二存储区中存储的主引导程序进行启动, 开始对第一存储区进行升级。 如 果选择不继续升级, 则确定本次升级失败。 Further, the operation module 101 is further configured to: when it is determined that the boot program is to be upgraded, obtain upgrade information, and upgrade the backup boot program in the second storage area according to the obtained upgrade information. After the operation module 101 is successfully started, the upgrade process may be automatically performed according to the setting of the control module 102, or may be performed after receiving the upgrade notification sent by the control module 102. The operation module 101 first upgrades the non-current storage area according to the upgrade information. The embodiment of the present invention takes the non-current storage area as the second storage area as an example. Because the current storage area, that is, the first storage area has been able to boot the operation module 101 to start normally, upgrading the second storage area first can ensure that the operation module 101 can still be normally started from the first storage area when the upgrade fails. After receiving the chip selection signal of the control module 102, the operation module 101 switches the upgraded boot program stored in the non-current storage area to the main boot program, performs a reset operation, and according to the main boot program stored in the second storage area. Start up. If the control counter in the control module 102 overflows, the startup is unsuccessful, and the operation module 101 switches the backup boot program stored in the first storage area to the main boot program, and upgrades the second storage area again, and thus repeats. If the number of upgrade failures of the second storage area reaches the second set value, for example, the second set value is N, it is determined that the upgrade to the non-current storage area, that is, the second storage area fails, and an alarm information may be sent, It is a software alarm or a hardware alarm. For example, the hardware alarm may be an alarm signal sent by the indicator light or buzzer of the control module 102. And an inquiry message is sent to ask whether to continue the upgrade process in the current storage area, that is, the first storage area. If the upgrade is selected to continue, the information stored in the first storage area is copied to the second storage area, and the old information stored in the second storage area is first erased before copying, and the backup stored in the second storage area is stored. The boot program switches to the main boot program, performs a reset operation, starts according to the main boot program stored in the second storage area, and starts upgrading the first storage area. If you choose not to continue the upgrade, it is determined that the upgrade failed.
其中, 所述升级失败次数 N可以为预先设定值, 可以保存在控制模块 102中,控制模块 102中可以有一个第二计数器, 用于计算对某一引导程序 存储区的升级失败次数, 每对某一引导程序存储区升级一次, 则第二计数 器的值加 1。  The number of upgrade failures N may be a preset value, and may be saved in the control module 102. The control module 102 may have a second counter for calculating the number of upgrade failures for a bootloader storage area. When a bootloader is upgraded once, the value of the second counter is incremented by one.
较佳的, 操作模块 101可以具体为 CPU。 操作模块 101可以位于单板 上。  Preferably, the operation module 101 can be specifically a CPU. The operation module 101 can be located on a single board.
控制模块 102, 用于在启动成功后, 记录第一存储区的标识信息; 将第 一存储区中的主引导程序备份到同一存储器中的第二存储区。  The control module 102 is configured to record the identification information of the first storage area after the startup is successful; and back up the main boot program in the first storage area to the second storage area in the same storage.
具体的, 本发明实施例中以单板需要启动为例。 控制模块 102可以存 储单板上一次成功启动的信息, 其中, 该信息中至少包括上一次成功启动 所使用的引导程序存储区的标识信息, 本发明实施例中以程序备份的装置 包括两个引导程序存储区为例, 该引导程序存储区位于存储模块 103 中。 两个引导程序存储区可以有各自的标识信息, 例如, 一个引导程序存储区 为第一存储区, 另一个引导程序存储区为第二存储区。 当单板启动成功时, 控制模块 102记录此时的当前存储区的标识信息, 以作为下一次启动的片 选信号。 当单板需要启动时, 控制模块 102读取自身内部存储的单板上一 次成功启动的信息, 根据所述信息中包含的上一次成功启动所使用的引导 程序存储区的标识信息在存储模块 103 中确定该引导程序存储区, 例如, 可以在存储模块 103 中确定该引导程序存储区的地址信息, 并将该引导程 序存储区的地址信息作为片选信号, 根据该 !导程序存储区的地址信息选 择引导程序存储区, 以通知操作模块 101 将该引导程序存储区切换为当前 存储区, 并根据该当前存储区中存储的主引导程序进行启动。 其中, 可以 通过一根引线向操作模块 101发送通知, 以通知操作模块 101根据该引导 程序存储区中存储的主 !导程序进行启动。 Specifically, in the embodiment of the present invention, a board needs to be started as an example. The control module 102 can store information of a successful startup on the board, where the information includes at least the identification information of the bootloader storage area used in the last successful startup. In the embodiment of the present invention, the device backed up by the program includes two bootstraps. For example, the program storage area is located in the storage module 103. The two bootloader storage areas may have respective identification information, for example, one bootloader storage area is the first storage area and the other bootloader storage area is the second storage area. When the board is successfully started, the control module 102 records the identification information of the current storage area at this time as the chip selection signal to be started next time. When the board needs to be started, the control module 102 reads the information of one successful startup of the board stored in the internal storage, and the storage module 103 according to the identifier information of the boot program storage area used in the last successful startup included in the information. Determine the bootloader store, for example, The address information of the boot program storage area may be determined in the storage module 103, and the address information of the boot program storage area is used as a chip select signal, according to the! The address information of the program storage area selects the boot program storage area to notify the operation module 101 to switch the boot program storage area to the current storage area, and starts according to the main boot program stored in the current storage area. Wherein, the notification may be sent to the operation module 101 through a lead to notify the operation module 101 according to the main stored in the boot program storage area! The program starts.
进一步的, 控制模块 102 中可以包括一个控制计数器, 控制模块 102 还用于判断该控制计数器是否溢出, 在控制模块 102读取自身内部存储的 上一次成功启动的信息的同时启动该控制计数器, 该控制计数器开始自动 计数。 如果单板启动成功, 则操作模块 101会通知控制模块 102将该控制 计数器清零并关闭。 该控制计数器没有溢出, 则确定启动成功, 而如果到 了一定的时间控制模块 102还未收到清零或关闭控制计数器的通知, 该控 制计数器就会溢出, 从而引起中断, 造成系统复位。 较佳的, 该控制计数 器可以是看门狗计数器, 当看门狗计数器溢出时, 会产生复位信号, 使单 板复位。 如果单板启动成功, 则控制模块 102根据操作模块 101 的通知保 存当前存储区的信息, 所述信息至少包括当前存储区的标识信息, 清零并 关闭计数器。 控制模块 102还用于在根据第一存储区中的主引导程序进行 启动后, 确定是否需要升级引导程序。  Further, the control module 102 may include a control counter, and the control module 102 is further configured to determine whether the control counter overflows, and start the control counter while the control module 102 reads the information of the last successful startup stored in the internal control system. The control counter starts counting automatically. If the board is successfully booted, the operation module 101 notifies the control module 102 to clear and close the control counter. If the control counter does not overflow, it is determined that the startup is successful, and if the control module 102 has not received the notification of clearing or closing the control counter for a certain period of time, the control counter will overflow, causing an interrupt, causing a system reset. Preferably, the control counter can be a watchdog counter. When the watchdog counter overflows, a reset signal is generated to reset the board. If the board is successfully started, the control module 102 saves the information of the current storage area according to the notification of the operation module 101, and the information includes at least the identification information of the current storage area, and the counter is cleared and closed. The control module 102 is further configured to determine whether the boot program needs to be upgraded after booting according to the main boot program in the first storage area.
进一步的,控制模块 102,还用于在操作模块 101根据第一存储区中的 主引导程序进行启动后, 确定需要升级引导程序。 在升级过程中, 控制模 块 102在收到比较模块 104的通知时, 更改片选信号, 将升级后的非当前 存储区中存储的备份引导程序设置为主引导程序, 例如, 升级第二存储区 后, 将第二存储区和第一存储区互相切换, 选择第二存储区作为当前存储 区, 则此时第二存储区中存储的备份引导程序为主引导程序, 开启控制计 数器, 并指示操作模块 101 进行复位操作及根据该第二存储区中存储的主 引导程序进行启动。 Further, the control module 102 is further configured to determine that the boot program needs to be upgraded after the operation module 101 starts according to the main boot program in the first storage area. During the upgrade process, when receiving the notification of the comparison module 104, the control module 102 changes the chip selection signal, and sets the backup boot program stored in the upgraded non-current storage area as the main boot program, for example, upgrading the second storage area. After that, the second storage area and the first storage area are switched to each other, and the second storage area is selected as the current storage area. At this time, the backup boot program stored in the second storage area is the main boot program, the control counter is turned on, and the operation is instructed. Module 101 performs a reset operation and according to the main memory stored in the second storage area The bootloader starts.
较佳的,控制模块 102可以具体为可编程逻辑器件,例如,可以是 EPLD (可擦除可编程逻辑器件) 。 控制模块 102可以位于单板上, 也可以不位 于单板上。 在操作模块 101进行复位操作时不复位控制模块 102。  Preferably, the control module 102 can be a programmable logic device, for example, an EPLD (Erasable Programmable Logic Device). The control module 102 may or may not be located on a single board. The control module 102 is not reset when the operation module 101 performs a reset operation.
图 2为本发明实施例中引导程序备份装置的详细结构图, 如图 2所示, 所述装置进一步还包括存储模块 103、比较模块 104及判断模块 105;其中, 存储模块 103 , 用于提供引导程序存储区。  2 is a detailed structural diagram of a bootloader backup device according to an embodiment of the present invention. As shown in FIG. 2, the device further includes a storage module 103, a comparison module 104, and a determination module 105. The storage module 103 is configured to provide Bootloader storage area.
具体的, 在本发明实施例中, 存储模块 103 可以包含两个引导程序存 储区, 即第一存储区和第二存储区, 第一存储区及第二存储区可以位于一 个存储器中。 其中, 当单板启动时, 所使用的引导程序存储区称为当前存 储区, 未使用的引导程序存储区称为非当前存储区。 存储模块 103 可以位 于单板上, 也可以不位于单板上。 在操作模块 101 进行复位操作时不复位 存储模块 103。  Specifically, in the embodiment of the present invention, the storage module 103 may include two boot program storage areas, that is, a first storage area and a second storage area, and the first storage area and the second storage area may be located in one memory. The bootloader storage area used is called the current storage area when the board is booted, and the unused bootloader storage area is called the non-current storage area. The storage module 103 can be located on the board or not on the board. The memory module 103 is not reset when the operation module 101 performs a reset operation.
比较模块 104, 用于比较两个引导程序存储区中存储的引导程序。  The comparison module 104 is configured to compare the bootstrap stored in the two bootloader storage areas.
具体的, 当单板启动成功后, 比较模块 104将当前存储区存储的主引 导程序与非当前存储区存储的备份引导程序进行比较, 例如, 可以采用按 位比较的方式。 以当前存储区为第一存储区, 非当前存储区为第二存储区 为例。 如果第一存储区存储的主引导程序与第二存储区存储的备份引导程 序不一致, 则通知操作模块 101 将第一存储区存储的引导程序复制到第二 存储区中, 并且在复制之前需要通知操作模块 101 先将第二存储区中存储 的旧的备份引导程序进行擦除。 如果第一存储区中存储的主引导程序与第 二存储区存储的备份引导程序一致, 则通知操作模块 101 本次启动过程结 束, 以便操作模块 101 开始正常工作。 备份过程完成之后, 还可以通知控 制模块 102生成一个复位信号, 并将该复位信号传递给操作模块 101 ,使操 作模块 101进行复位操作, 复位除控制模块 102以外的单板器件, 并将备 份后的第二存储区中存储的备份引导程序切换为主引导程序,操作模块 101 继续根据该第二存储区中存储的主引导程序进行启动, 以判断备份后的 ! 导程序是否能够使操作模块 101完成启动, 验证备份的引导程序的正确性。 Specifically, after the board is successfully booted, the comparison module 104 compares the main boot program stored in the current storage area with the backup boot program stored in the non-current storage area. For example, a bitwise comparison manner may be adopted. Take the current storage area as the first storage area and the non-current storage area as the second storage area as an example. If the primary boot program stored in the first storage area is inconsistent with the backup boot program stored in the second storage area, the operation module 101 is notified to copy the boot program stored in the first storage area into the second storage area, and needs to be notified before copying. The operation module 101 first erases the old backup boot program stored in the second storage area. If the main boot program stored in the first storage area coincides with the backup boot program stored in the second storage area, the operation module 101 is notified that the startup process ends, so that the operation module 101 starts normal operation. After the backup process is completed, the control module 102 can be notified to generate a reset signal, and the reset signal is transmitted to the operation module 101, so that the operation module 101 performs a reset operation, resets the single-board device except the control module 102, and prepares the device. The backup boot program stored in the second storage area is switched to the main boot program, and the operation module 101 continues to boot according to the main boot program stored in the second storage area to determine the backup! Whether the program can enable the operation module 101 to complete the startup, and verify the correctness of the backup boot program.
在进行升级过程之前, 比较模块 104首先比较当前存储区存储的主引 导程序与非当前存储区存储的备份引导程序是否一致, 如果不一致, 则通 知操作模块 101可以开始升级操作, 否则通知操作模块 101无需进行升级。 以当前存储区为第一存储区, 非当前存储区为第二存储区为例。 在升级过 程中, 当操作模块 101 根据自身保存的升级信息对第二存储区进行升级之 后, 比较模块 104还用于将升级后的第二存储区中存储的备份引导程序与 操作模块 101中保存的升级信息进行比较。 其中, 对第二存储区进行升级, 即将操作模块 101 中的升级信息烧录到非当前存储区中。 烧录完毕后, 将 操作模块 101 中的升级信息与烧录后的第二存储区中存储的备份引导程序 进行比较,如果升级后的第二存储区中存储的备份引导程序与操作模块 101 中保存的升级信息一致, 则确定烧录成功, 此时可以通知控制模块 102将 升级后的第二存储区中存储的备份引导程序设置为主引导程序, 如果升级 后的第二存储区中存储的备份引导程序与操作模块 101 中保存的升级信息 不一致, 则确定烧录失败, 则可以通知操作模块 101 重新进行升级, 或者 放弃升级。对第二存储区中存储的备份引导程序升级成功后, 比较模块 104 可以接到操作模块 101 的通知, 将第一存储区中存储的主引导程序与第二 存储区中存储的备份引导程序进行比较, 如果第一存储区中存储的未升级 的主引导程序与第二存储区中存储的已升级的备份引导程序不一致, 则可 以通知操作模块 101将第二存储区中存储的引导程序复制到第一存储区中。  Before the upgrade process, the comparison module 104 first compares whether the main boot program stored in the current storage area is consistent with the backup boot program stored in the non-current storage area. If not, the operation module 101 can be notified to start the upgrade operation, otherwise the operation module 101 is notified. No upgrade is required. Take the current storage area as the first storage area and the non-current storage area as the second storage area as an example. In the upgrade process, after the operation module 101 upgrades the second storage area according to the upgrade information saved by itself, the comparison module 104 is further configured to save the backup boot program stored in the upgraded second storage area and the operation module 101. The upgrade information is compared. The second storage area is upgraded, and the upgrade information in the operation module 101 is burned into the non-current storage area. After the programming is completed, the upgrade information in the operation module 101 is compared with the backup boot program stored in the second storage area after the burning, if the backup boot program stored in the upgraded second storage area is in the operation module 101. If the saved upgrade information is consistent, it is determined that the programming is successful. At this time, the control module 102 may be notified to set the backup boot program stored in the upgraded second storage area as the main boot program, if the upgraded second storage area is stored. If the backup boot program is inconsistent with the upgrade information saved in the operation module 101, if it is determined that the burning fails, the operation module 101 may be notified to perform the upgrade again, or the upgrade may be abandoned. After the upgrade of the backup boot program stored in the second storage area is successful, the comparison module 104 can receive the notification of the operation module 101, and perform the main boot program stored in the first storage area and the backup boot program stored in the second storage area. For comparison, if the unupgraded primary boot program stored in the first storage area is inconsistent with the upgraded backup boot program stored in the second storage area, the operation module 101 may be notified to copy the boot program stored in the second storage area to In the first storage area.
判断模块 105 , 用于判断启动总次数是否超过了第一设定值。  The determining module 105 is configured to determine whether the total number of starts exceeds the first set value.
具体的, 第一设定值可以是 M, 可以保存在控制模块 102中。 当启动 不成功时, 判断模块 105根据第一计数器中的值判断此时的启动总次数是 否达到了 M, 如果启动的次数达到了 M, 可以发出告警信息, 可以是软件 告警, 也可以是硬件告警, 例如, 硬件告警可以是控制模块 102 以指示灯 或蜂鸣器作为告警信号, 认为系统启动失败, 该单板故障。 如果启动的次 数未达到 M, 则通知操作模块 101 可以继续进行启动操作。 判断模块 105 还用于判断升级失败次数是否超过了第二设定值, 第二设定值可以是 N, 可以保存在控制模块 102中。 当升级不成功时, 判断模块 105根据第二计 数器中的值判断此时对非当前存储区的升级失败次数是否达到了 N, 如果 升级的次数达到了 N, 可以发出告警信息, 可以是软件告警, 也可以是硬 件告警, 例如, 硬件告警可以是控制模块 102 以指示灯或蜂鸣器作为告警 信号, 确定对非当前存储区的升级失败, 并可以通知操作模块 101 发出询 问信息 ,以询问是否需要继续在升级当前存储区。如果升级的次数未达到 N , 则通知操作模块 101可以继续进行升级过程。 Specifically, the first set value may be M, and may be saved in the control module 102. When the startup is unsuccessful, the determining module 105 determines, according to the value in the first counter, the total number of startups at this time is If the number of starts reaches M, the alarm information may be sent, which may be a software alarm or a hardware alarm. For example, the hardware alarm may be the control module 102 using an indicator light or a buzzer as an alarm signal. The system fails to start and the board is faulty. If the number of starts does not reach M, the notification operation module 101 can continue the startup operation. The determining module 105 is further configured to determine whether the number of upgrade failures exceeds a second set value, and the second set value may be N, which may be saved in the control module 102. When the upgrade is unsuccessful, the determining module 105 determines, according to the value in the second counter, whether the number of upgrade failures to the non-current storage area reaches N at this time. If the number of upgrades reaches N, an alarm message may be sent, which may be a software alarm. It can also be a hardware alarm. For example, the hardware alarm may be that the control module 102 uses an indicator light or a buzzer as an alarm signal to determine that the upgrade of the non-current storage area fails, and may notify the operation module 101 to send an inquiry message to ask whether Need to continue to upgrade the current storage area. If the number of upgrades does not reach N, the notification operation module 101 can continue the upgrade process.
下面通过具体的流程来介绍引导程序备份方法。  The following describes the bootloader backup method through a specific process.
图 3为本发明实施例中引导程序备份方法的主要流程图, 如图 3所示, 本发明实施例中引导程序备份的主要方法流程如下:  FIG. 3 is a main flowchart of a method for backing up a boot program according to an embodiment of the present invention. As shown in FIG. 3, the main method for booting a backup program in the embodiment of the present invention is as follows:
步驟 301 : 根据默认的或者记录的第一存储区的标识信息, 获得第一存 储区中的主引导程序, 并进行启动;  Step 301: Obtain a primary booting program in the first storage area according to the default or the recorded identification information of the first storage area, and start.
步驟 302: 启动成功后, 记录第一存储区的标识信息;  Step 302: After the startup is successful, record the identification information of the first storage area.
步驟 303:将第一存储区中的主引导程序备份到同一存储器中的第二存 储区。  Step 303: Back up the main boot program in the first storage area to the second storage area in the same storage.
进一步的, 在当前存储区启动不成功并接收到复位信号时, 所述方法 还包括: 进行复位操作, 将第二存储区切换为当前存储区后再重新启动, 并且记录启动总次数。  Further, when the current storage area is unsuccessful and receives the reset signal, the method further includes: performing a reset operation, switching the second storage area to the current storage area, restarting, and recording the total number of startups.
进一步的, 每次接到复位信号时, 所述方法还包括: 判断启动总次数 是否大于第一设定值, 当判断结果为是时, 确定启动失败, 发出告警信息, 否则继续进行复位操作。 Further, each time the reset signal is received, the method further includes: determining whether the total number of startups is greater than the first set value, and when the determination result is yes, determining that the startup fails, and issuing an alarm message, Otherwise continue the reset operation.
进一步的, 所述启动成功后, 在将第一存储区中的主引导程序备份到 同一存储器中的第二存储区之前, 所述方法还包括: 判断第一存储区存储 的主引导程序是否与第二存储区存储的备份引导程序一致, 当判断结果为 否时, 将第一存储区存储的主引导程序备份到第二存储区。  Further, after the startup is successful, before the primary boot program in the first storage area is backed up to the second storage area in the same storage, the method further includes: determining whether the primary boot program stored in the first storage area is The backup boot program stored in the second storage area is consistent. When the determination result is no, the primary boot program stored in the first storage area is backed up to the second storage area.
本发明还包括一种引导程序升级方法, 所述方法包括: 在根据第一存 储区中的主引导程序进行启动后, 确定是否需要升级引导程序; 其中, 所 述第一存储区为当前存储区; 当确定需要升级引导程序时, 获得升级信息; 根据获得的升级信息对第二存储区中的备份引导程序进行升级。  The present invention also includes a bootloader upgrade method, the method comprising: determining whether a bootloader needs to be upgraded after booting according to a primary bootloader in the first storage area; wherein the first storage area is a current storage area When you are sure that you need to upgrade the bootloader, get the upgrade information; upgrade the backup bootloader in the second storage area according to the obtained upgrade information.
进一步的, 所述确定需要升级引导程序之前, 所述方法还包括: 判断 第一存储区存储的主引导程序是否与第二存储区存储的备份引导程序一 致, 当判断结果为否时, 确定需要升级引导程序。  Further, before the determining needs to upgrade the booting program, the method further includes: determining whether the primary booting program stored in the first storage area is consistent with the backup booting program stored in the second storage area, and determining whether the result is negative Upgrade the bootstrap.
进一步的, 所述根据获得的升级信息对第二存储区中的备份引导程序 进行升级之后, 所述方法还包括: 将升级后的第二存储区切换为当前存储 区; 根据该第二存储区中的主引导程序进行启动, 在启动成功时确定升级 成功。  Further, after the upgrade booting program in the second storage area is upgraded according to the obtained upgrade information, the method further includes: switching the upgraded second storage area to the current storage area; according to the second storage area The main boot program in the startup starts, and the upgrade is successful when the startup is successful.
进一步的, 所述根据该第二存储区中的主引导程序进行启动之后, 所 述方法还包括:  Further, after the starting according to the main booting procedure in the second storage area, the method further includes:
判断控制计数器是否溢出, 当判断结果为否时, 确定启动成功, 进而 确定升级成功;  Determining whether the control counter overflows, and when the judgment result is no, determining that the startup is successful, thereby determining that the upgrade is successful;
当判断结果为是时, 继续判断升级失败次数是否大于第二预设值, 当 升级失败次数不大于第二预设值时, 将第一存储区中的备份引导程序切换 为主引导程序, 进行复位操作, 并根据该第一存储区中存储的主引导程序 进行启动;  When the determination result is yes, it is determined whether the number of upgrade failures is greater than a second preset value. When the number of upgrade failures is not greater than the second preset value, the backup boot program in the first storage area is switched to the primary boot program. Reset operation, and starting according to the main boot program stored in the first storage area;
当升级失败次数大于第二预设值时, 确定对第二存储区的升级失败, 发出告警信息, 并继续判断是否需要对第一存储区进行升级, 当需要对第 一存储区进行升级时, 将第一存储区中的备份引导程序复制到所述第二存 储区, 进行复位操作, 并将所述第二存储区切换为当前存储区, 根据第二 存储区中存储的主 !导程序进行启动。 When the number of upgrade failures is greater than the second preset value, it is determined that the upgrade to the second storage area fails. Sending an alarm message, and continuing to determine whether the first storage area needs to be upgraded. When the first storage area needs to be upgraded, the backup boot program in the first storage area is copied to the second storage area to perform a reset operation. And switching the second storage area to the current storage area, according to the main storage stored in the second storage area! The program starts.
图 4 为本发明实施例中判断是否启动成功的详细方法流程图, 如图 4 所示, 本发明实施例中判断是否启动成功的详细方法流程如下:  FIG. 4 is a flowchart of a detailed method for determining whether the startup is successful according to an embodiment of the present invention. As shown in FIG. 4, the detailed method for determining whether the startup is successful in the embodiment of the present invention is as follows:
步驟 401 : 单板上电。 本发明实施例以单板是否启动成功为例; 步驟 402: 读取上一次成功启动的引导程序存储区信息;  Step 401: The board is powered on. In the embodiment of the present invention, whether the board is successfully started is taken as an example; Step 402: reading the boot program storage area information that was successfully started last time;
其中, 在操作模块 101成功启动后, 控制模块 102保存成功启动的引 导程序存储区的信息, 该信息中至少包括该成功启动的引导程序存储区的 标识信息, 以使操作模块 101 根据该标识信息确定该引导程序存储区的地 址信息。 本发明实施例中以该引导程序存储区是第一存储区为例。  After the operation module 101 is successfully started, the control module 102 saves the information of the boot program storage area that is successfully started, and the information includes at least the identification information of the successfully booted boot program storage area, so that the operation module 101 is based on the identification information. Determine the address information for the bootloader store. In the embodiment of the present invention, the boot storage area is a first storage area as an example.
步驟 403: 开启控制计数器。 控制模块 102开启控制计数器, 控制计数 器开始计数;  Step 403: Turn on the control counter. The control module 102 turns on the control counter, and controls the counter to start counting;
较佳的, 该控制计数器可以是看门狗计数器。  Preferably, the control counter can be a watchdog counter.
步驟 404: 将第一存储区中存储的弓!导程序切换为主引导程序; 步驟 405: 根据该第一存储区中存储的主 !导程序开始启动;  Step 404: Place the bow stored in the first storage area! The program switches to the main boot program; Step 405: According to the main memory stored in the first storage area! The program starts to start;
其中, 步驟 403和步驟 404需同时进行。 控制模块 102将该引导程序 存储区的标识信息发送给操作模块 101 , 以作为片选信号, 所述片选信号即 步驟 402 中记载的成功启动的引导程序存储区的标识信息。 操作模块 101 根据该片选信号将该第一存储区中存储的引导程序确定为主引导程序, 并 开始启动过程。  Step 403 and step 404 need to be performed simultaneously. The control module 102 sends the identification information of the boot program storage area to the operation module 101 as a chip select signal, which is the identification information of the successfully booted boot program storage area recorded in step 402. The operation module 101 determines the boot program stored in the first storage area as the main boot program according to the chip select signal, and starts the boot process.
步驟 406: 判断控制计数器是否溢出。 当判断结果为是时, 继续步驟 407。 否则继续步驟 413;  Step 406: Determine whether the control counter overflows. When the result of the determination is YES, the process proceeds to step 407. Otherwise continue to step 413;
步驟 407: 判断启动的次数是否大于 M, 当判断结果为否时, 继续步驟 408, 否则继续步驟 412; Step 407: Determine whether the number of starts is greater than M. When the judgment result is no, continue the step. 408, otherwise proceed to step 412;
具体的, 通过第一计数器的值判断启动的次数是否大于 M。  Specifically, it is determined by the value of the first counter whether the number of starts is greater than M.
步驟 408: 将第二存储区中存储的备份引导程序切换为主引导程序, 并 复位单板;  Step 408: Switch the backup boot program stored in the second storage area to the main boot program, and reset the board.
具体的, 在复位单板的同时控制模块 102清零并关闭控制计数器, 该 控制计数器开始重新计数。 如果操作模块 101和控制模块 102均位于单板 上, 则本步驟中的复位单板操作应改为复位操作模块 101 , 如果操作模块 101位于单板上二控制模块 102不位于单板上,则本步驟中可以是复位单板。  Specifically, the control module 102 clears and closes the control counter while resetting the board, and the control counter starts counting again. If the operation module 101 and the control module 102 are both located on the board, the reset board operation in this step should be changed to the reset operation module 101. If the operation module 101 is located on the board and the control module 102 is not located on the board, then This step can be to reset the board.
步驟 409: 根据第二存储区中存储的主引导程序进行启动;  Step 409: Start according to the main boot program stored in the second storage area;
步驟 410: 判断控制计数器是否溢出。 当判断结果为是时, 继续步驟 411 , 否则继续步驟 413;  Step 410: Determine whether the control counter overflows. When the determination result is yes, proceed to step 411, otherwise continue to step 413;
步驟 411 : 判断启动的次数是否大于 M, 当判断结果为否时, 继续步驟 404, 并且在执行步驟 404的同时还需复位单板, 否则继续步驟 412;  Step 411: Determine whether the number of starts is greater than M, when the determination result is no, proceed to step 404, and still need to reset the board while performing step 404, otherwise continue to step 412;
步驟 412: 确定启动失败, 发出告警信息;  Step 412: Determine that the startup fails, and issue an alarm message;
步驟 413 : 确定启动成功, 保存当前存储区的标识信息。 同时控制模块 102清零并关闭计数器。  Step 413: Determine that the startup is successful, and save the identification information of the current storage area. At the same time, control module 102 clears and closes the counter.
步驟 501 : 启动成功, 保存当前存储区的标识信息; Step 501: The startup succeeds, and the identifier information of the current storage area is saved.
具体的, 本步驟与图 4所示的流程中的步驟 413为同一步驟, 在执行 完图 4流程中的步驟 413后还可以执行以下的流程。 本发明实施例中以当 前存储区为第一存储区, 非当前存储区为第二存储区为例。  Specifically, this step is the same as step 413 in the flow shown in FIG. 4, and after the step 413 in the flow of FIG. 4 is executed, the following flow can also be executed. In the embodiment of the present invention, the current storage area is the first storage area, and the non-current storage area is the second storage area.
步驟 502:判断第一存储区中存储的主引导程序与第二存储区中存储的 备份引导程序是否一致, 当判断结果为否时, 继续步驟 503 , 否则继续步驟 505; 步驟 503 : 将第一存储区中存储的主引导程序备份到第二存储区。 Step 502: determining whether the primary boot program stored in the first storage area is consistent with the backup boot program stored in the second storage area, and if the determination result is no, proceed to step 503, otherwise proceed to step 505; Step 503: Back up the main boot program stored in the first storage area to the second storage area.
具体的, 所述备份具体为将成功启动后的第一存储区中存储的的主引 导程序进行备份处理。 其中, 备份方法可以是复制。  Specifically, the backup is specifically performing backup processing on the main boot program stored in the first storage area after the successful startup. Among them, the backup method can be copy.
步驟 504:判断第一存储区中存储的主引导程序与第二存储区中存储的 备份引导程序是否一致, 当判断结果为否时, 继续步驟 503 , 否则继续步驟 Step 504: It is determined whether the primary boot program stored in the first storage area is consistent with the backup boot program stored in the second storage area. When the determination result is no, proceed to step 503, otherwise continue the step.
505; 505;
具体的, 本步驟为了防止在备份过程中出现错误。  Specifically, this step is to prevent errors during the backup process.
步驟 505: 引导程序备份完成。  Step 505: The bootloader backup is complete.
在执行完图 5流程中的步驟 505之后, 还可以继续将第二存储区中存 储的备份引导程序切换为主引导程序, 进行复位操作, 继续进行启动过程, 以验证备份后的引导程序是否能够使操作模块 101完成启动。  After the step 505 in the process of FIG. 5 is performed, the backup boot program stored in the second storage area can be further switched to the main boot program, the reset operation is performed, and the boot process is continued to verify whether the boot program after the backup can be The operation module 101 is caused to complete startup.
下: Next:
步驟 601 : 对第二存储区进行升级;  Step 601: Upgrade the second storage area;
具体的, 将操作模块 10ι 中的升级信息烧录到非当前存储区中。 本发 明实施例中, 所述第二存储区为非当前存储区, 第一存储区为当前存储区。 Specifically, the upgrade information in the operation module 10 ι is burned into the non-current storage area. In the embodiment of the present invention, the second storage area is a non-current storage area, and the first storage area is a current storage area.
步驟 602: 判断第二存储区中所烧录的引导程序是否与升级信息一致, 当判断结果为是时, 继续步驟 603 , 否则继续步驟 601 ;  Step 602: Determine whether the boot program burned in the second storage area is consistent with the upgrade information. When the determination result is yes, proceed to step 603, otherwise continue to step 601;
具体的, 烧录完毕后, 将操作模块 101 中保存的升级信息与烧录到第 二存储区中的引导程序进行比较, 如果操作模块 101 中的升级信息与烧录 到非当前存储区中的引导程序一致, 则说明烧录成功, 如果操作模块 101 中的升级信息与烧录到非当前存储区中的引导程序不一致, 则说明烧录不 成功, 需重新进行烧录。  Specifically, after the programming is completed, the upgrade information saved in the operation module 101 is compared with the boot program burned into the second storage area, if the upgrade information in the operation module 101 is burned into the non-current storage area. If the boot program is consistent, the burning is successful. If the upgrade information in the operation module 101 is inconsistent with the boot program in the non-current storage area, the burning is unsuccessful and the burning is required.
步驟 603 :将更新后的片选信号发送给操作模块 101 ,开启控制计数器; 具体的, 模块 103 将更新后的第二存储区的标识信息作为片选信号发 送给操作模块 101 , 并开启控制计数器, 该控制计数器开始计数。 Step 603: Send the updated chip select signal to the operation module 101, and turn on the control counter. Specifically, the module 103 sends the updated identification information of the second storage area to the operation module 101 as a chip selection signal, and turns on the control counter, and the control counter starts counting.
步驟 604:将第二存储区中存储的升级后的备份引导程序设置为主引导 程序, 进行复位操作, 操作模块 101 根据所述片选信号将第二存储区中存 储的升级后的备份引导程序设置为主引导程序;  Step 604: Set the upgraded backup boot program stored in the second storage area as the main boot program, perform a reset operation, and the operation module 101 stores the upgraded backup boot program stored in the second storage area according to the chip select signal. Set as the main boot program;
步驟 605: 根据第二存储区中存储的主引导程序进行启动;  Step 605: Start according to the main boot program stored in the second storage area;
步驟 606: 判断控制计数器是否溢出, 当判断结果为是时, 继续步驟 607, 否则继续步驟 610;  Step 606: Determine whether the control counter overflows, when the determination result is yes, proceed to step 607, otherwise continue to step 610;
具体的, 当判断结果为是时, 说明此次升级失败, 否则说明升级成功。 步驟 607: 判断升级失败次数是否大于 N, 当判断结果为否时, 继续步 驟 608, 否则继续步驟 609;  Specifically, when the judgment result is yes, it indicates that the upgrade fails, otherwise the upgrade is successful. Step 607: determining whether the number of upgrade failures is greater than N, when the determination result is no, proceed to step 608, otherwise proceed to step 609;
具体的, 通过第二计数器的值判断升级失败次数是否大于 N。  Specifically, it is determined by the value of the second counter whether the number of upgrade failures is greater than N.
步驟 608: 将第一存储区中存储的备份引导程序切换为主引导程序, 进 行复位操作, 继续步驟 601 , 此时控制模块 102将控制计数器清零, 控制计 数器开始重新计数;  Step 608: Switch the backup boot program stored in the first storage area to the main boot program, perform a reset operation, and continue to step 601. At this time, the control module 102 clears the control counter, and the control counter starts to recount;
步驟 609: 确定非当前存储区升级失败, 此时可以发出告警信息; 步驟 610: 确定非当前存储区升级成功。  Step 609: Determine that the non-current storage area upgrade fails, and the alarm information may be sent; Step 610: Determine that the non-current storage area is successfully upgraded.
图 7为本发明实施例中在确定对非当前存储区升级失败后是否需要升 级当前存储区的详细方法流程图, 如图 7所示, 本发明实施例为在确定对 非当前存储区升级失败后是否需要升级当前存储区的详细方法流程:  FIG. 7 is a flowchart of a detailed method for determining whether to upgrade a current storage area after a failure to upgrade a non-current storage area according to an embodiment of the present invention. As shown in FIG. 7, the embodiment of the present invention determines that the upgrade to a non-current storage area fails. Whether you need to upgrade the current storage area detailed method flow:
步驟 701 : 确定第二存储区升级失败;  Step 701: Determine that the second storage area upgrade fails.
具体的, 本步驟与图 6所示的流程中的步驟 612为同一步驟, 在执行 完图 6所示的流程中的步驟 612后, 可以继续执行以下步驟。 本发明实施 例中, 第二存储区为非当前存储区, 第一存储区为当前存储区。  Specifically, this step is the same step as step 612 in the flow shown in FIG. 6. After performing step 612 in the flow shown in FIG. 6, the following steps can be continued. In the embodiment of the present invention, the second storage area is a non-current storage area, and the first storage area is a current storage area.
步驟 702: 判断是否需要升级第一存储区, 当判断结果为是时, 继续步 驟 703 , 否则结束流程; Step 702: Determine whether it is necessary to upgrade the first storage area. When the judgment result is yes, continue step Step 703, otherwise the process ends;
步驟 703: 将第一存储区中存储的主引导程序复制到第二存储区; 其中 , 在复制之前需要先擦除第二存储区中存储的备份引导程序。 步驟 704: 进行复位操作, 此时控制模块 102将控制计数器清零, 控制 计数器开始重新计数;  Step 703: Copy the primary boot program stored in the first storage area to the second storage area; wherein, the backup boot program stored in the second storage area needs to be erased before copying. Step 704: Perform a reset operation. At this time, the control module 102 clears the control counter, and controls the counter to start counting again.
步驟 705: 将第二存储区中存储的备份引导程序切换为主引导程序; 步驟 706: 对第一存储区进行升级。 即将操作模块 101中的升级信息烧 录到第一存储区中。 本步驟与图 6所示的步驟 601为同一步驟, 以下流程 也与图 6—致。 即在对非当前存储区升级失败时, 尝试对当前存储区继续 进行升级。 其中, 可以是操作模块 101 成功启动后自动进行升级, 也可以 是在收到升级通知后进行升级。  Step 705: Switch the backup boot program stored in the second storage area to the primary boot program. Step 706: Upgrade the first storage area. The upgrade information in the operation module 101 is burned into the first storage area. This step is the same as step 601 shown in Fig. 6. The following flow is also consistent with Fig. 6. That is, when the upgrade to the non-current storage area fails, an attempt is made to continue the upgrade of the current storage area. The operation module 101 may be automatically upgraded after being successfully started, or may be upgraded after receiving the upgrade notification.
本发明实施例根据默认的或者记录的第一存储区的标识信息, 获得第 一存储区中的主引导程序, 并进行启动; 其中, 所述第一存储区为当前存 储区; 在启动成功后, 记录第一存储区的标识信息; 将第一存储区中的主 引导程序备份到同一存储器中的第二存储区。 本发明实施例在一个存储器 中提供了两个引导程序存储区, 不会占用过多硬件资源; 没有规定两个引 导程序存储区中谁为主引导程序存储区, 系统启动时可根据上次启动成功 后保存的引导程序存储区的信息从该引导程序存储区进行启动, 无需限定 必须从主引导程序存储区启动, 使启动速度较快, 启动效率较高; 在正确 启动后将当前存储区的代码备份到非当前存储区中, 实现了引导程序的备 份, 保证了所备份的引导程序的正确性。 在备份过程中, 无需对当前存储 区的代码做出修改, 可以直接进行备份, 操作过程简便。 并且, 记录当前 存储区的标识信息作为片选信号时可以通过软件完成, 无需占用硬件资源。 本发明实施例还在第一存储区中的主引导程序下确定需要升级引导程序; 获得升级信息; 根据获得的升级信息对第二存储区中的备份引导程序进行 升级。 本发明实施例选择在非当前存储区中进行升级, 以避免因升级不成 功而导致单板无法再次启动, 提高了系统的可靠性。 设置了操作模块 101 启动总次数的上限值, 如果启动总次数超过该上限值, 则确定启动失败, 避免操作模块 101 不停地启动, 浪费资源, 且容易损坏硬件。 在操作模块 101正确启动之后, 或在收到升级通知之后,操作模块 101可以对引导程序 存储区进行升级, 以获得更高的引导程序版本, 使单板启动过程更加优化。 在升级之前, 将当前存储区中存储的主 !导程序与非当前存储区中存储的 备份引导程序进行对比, 如果二者不一致, 进行升级过程, 否则无需进行 升级, 避免资源的浪费。 在升级过程中, 首先对升级信息进行校验, 以确 保升级信息的正确性, 升级完成后, 还需根据升级后的引导程序存储区中 存储的引导程序进行启动, 以进一步验证升级是否成功, 并且, 是对非当 前存储区进行升级, 以确保在升级不成功时, 操作模块 101 还可以根据当 前存储区中存储的主引导程序进行启动。 并且, 按照本发明实施例所介绍 的方法及装置, 可以支持在线升级, 设置了升级失败次数的上限, 对升级 时可能出现的故障做出了处理, 保证了升级的正确性。 The embodiment of the present invention obtains the main booting program in the first storage area according to the default or the recorded identification information of the first storage area, and starts, wherein the first storage area is the current storage area; after the startup is successful And recording the identification information of the first storage area; and backing up the main boot program in the first storage area to the second storage area in the same storage. The embodiment of the present invention provides two boot program storage areas in one memory, which does not occupy excessive hardware resources; no one of the two boot program storage areas is specified as the main boot program storage area, and the system can be started according to the last boot time. The information of the boot program storage area saved after successful is started from the boot program storage area, and it is not necessary to be booted from the main boot program storage area, so that the startup speed is faster and the startup efficiency is higher; after the correct startup, the current storage area is The code is backed up to the non-current storage area, and the backup of the boot program is realized, which ensures the correctness of the boot program being backed up. During the backup process, there is no need to modify the code of the current storage area, and the backup can be directly performed, and the operation process is simple. Moreover, when the identification information of the current storage area is recorded as the chip selection signal, it can be completed by software without occupying hardware resources. The embodiment of the present invention further determines that the boot program needs to be upgraded under the main boot program in the first storage area; obtains the upgrade information; and performs the backup boot program in the second storage area according to the obtained upgrade information. Upgrade. The embodiment of the present invention selects the upgrade in the non-current storage area to prevent the board from being restarted due to the unsuccessful upgrade, thereby improving the reliability of the system. The upper limit value of the total number of times of starting the operation module 101 is set. If the total number of startups exceeds the upper limit value, it is determined that the startup fails, the operation module 101 is prevented from being continuously started, resources are wasted, and the hardware is easily damaged. After the operation module 101 is properly started, or after receiving the upgrade notification, the operation module 101 can upgrade the boot program storage area to obtain a higher boot program version, and the board startup process is more optimized. Before the upgrade, the master stored in the current store! The program is compared with the backup boot program stored in the non-current storage area. If the two are inconsistent, the upgrade process is performed. Otherwise, no upgrade is required to avoid waste of resources. During the upgrade process, the upgrade information is first verified to ensure the correctness of the upgrade information. After the upgrade is completed, it is also required to start according to the boot program stored in the upgraded boot program storage area to further verify whether the upgrade is successful. Moreover, the non-current storage area is upgraded to ensure that when the upgrade is unsuccessful, the operation module 101 can also start according to the main boot program stored in the current storage area. Moreover, the method and device according to the embodiment of the present invention can support online upgrade, set an upper limit of the number of upgrade failures, and deal with faults that may occur during the upgrade, thereby ensuring the correctness of the upgrade.
本领域内的技术人员应明白, 本发明的实施例可提供为方法、 系统、 或计算机程序产品。 因此, 本发明可采用完全硬件实施例、 完全软件实施 例、 或结合软件和硬件方面的实施例的形式。 而且, 本发明可采用在一个 或多个其中包含有计算机可用程序代码的计算机可用存储介质 (包括但不 限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。  Those skilled in the art will appreciate that embodiments of the present invention can be provided as a method, system, or computer program product. Thus, the present invention can take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) in which computer usable program code is embodied.
本发明是参照根据本发明实施例的方法、 设备(系统) 、 和计算机程 序产品的流程图、 和 /或方框图来描述的。 应理解可由计算机程序指令实现 流程图、 和 /或方框图中的每一流程和 /或方框、 以及流程图、 和 /或方框图中 的流程、 和 /或方框的结合。 可提供这些计算机程序指令到通用计算机、 专 用计算机、 嵌入式处理机或其他可编程数据处理设备的处理器以产生一个 机器, 使得通过计算机或其他可编程数据处理设备的处理器执行的指令产 生用于实现在流程图一个流程或多个流程、 和 /或方框图一个方框或多个方 框中指定的功能的装置。 The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowcharts, and/or block diagrams, as well as the flow of the flowcharts, and/or block diagrams, and/or combinations of blocks can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, a special purpose computer, an embedded processor or other programmable data processing device to generate a A device that, by means of instructions executed by a processor of a computer or other programmable data processing device, produces means for implementing the functions specified in one or more flows of the flowchart, and/or in a block or blocks of the block diagram. .
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理 设备以特定方式工作的计算机可读存储器中, 使得存储在该计算机可读存 储器中的指令产生包括指令装置的制造品, 该指令装置实现在流程图一个 流程或多个流程、 和 /或方框图一个方框或多个方框中指定的功能。  The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus implements the functions specified in one or more flows of the flowchart, and/or in a block or blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备 上, 使得在计算机或其他可编程设备上执行一系列操作步驟以产生计算机 实现的处理, 从而在计算机或其他可编程设备上执行的指令提供用于实现 在流程图一个流程或多个流程、 和 /或方框图一个方框或多个方框中指定的 功能的步驟。  These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more flows of the flowchart, and/or in a block or blocks of the block diagram.
以上所述, 仅为本发明的较佳实施例而已, 并非用于限定本发明的保 护范围, 凡在本发明的精神和原则之内所作的任何修改、 等同替换和改进 等, 均应包含在本发明的保护范围之内。  The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included. Within the scope of protection of the present invention.

Claims

权利要求书 Claim
1、 一种引导程序备份方法, 其特征在于, 所述方法包括:  A boot program backup method, the method comprising:
根据默认的或者记录的第一存储区的标识信息, 获得第一存储区中的 主引导程序, 并进行启动; 其中, 所述第一存储区为当前存储区;  Obtaining, according to the identifier information of the default or the first storage area, the main booting program in the first storage area, and starting; wherein, the first storage area is a current storage area;
启动成功后, 记录第一存储区的标识信息;  After the startup is successful, the identification information of the first storage area is recorded;
将第一存储区中的主引导程序备份到同一存储器中的第二存储区。 The primary boot program in the first storage area is backed up to the second storage area in the same memory.
2、 如权利要求 1所述的方法, 其特征在于, 在启动成功前接收到复位 信号时, 所述方法还包括: 进行复位操作, 将第二存储区切换为当前存储 区后再重新启动, 并记录启动总次数。 2. The method according to claim 1, wherein when the reset signal is received before the startup is successful, the method further comprises: performing a reset operation, switching the second storage area to the current storage area, and then restarting, And record the total number of starts.
3、 如权利要求 2所述的方法, 其特征在于, 每次接到复位信号时, 所 述方法还包括: 判断启动总次数是否大于第一设定值, 如果是, 则确定启 动失败, 发出告警信息; 否则继续进行复位操作。  3. The method according to claim 2, wherein each time the reset signal is received, the method further comprises: determining whether the total number of starts is greater than the first set value, and if so, determining that the start fails, issuing Alarm information; otherwise continue the reset operation.
4、 如权利要求 1或 2所述的方法, 其特征在于, 所述启动成功后, 在 将第一存储区中的主引导程序备份到同一存储器中的第二存储区之前, 所 述方法还包括: 判断第一存储区存储的主引导程序是否与第二存储区存储 的备份引导程序一致, 当判断结果为否时, 将第一存储区存储的主引导程 序备份到第二存储区。  The method according to claim 1 or 2, wherein after the booting is successful, the method further: before backing up the main boot program in the first storage area to the second storage area in the same memory The method includes: determining whether the primary boot program stored in the first storage area is consistent with the backup boot program stored in the second storage area, and when the determination result is no, backing up the primary boot program stored in the first storage area to the second storage area.
5、 一种引导程序升级方法, 其特征在于, 所述方法包括:  A method for upgrading a boot program, the method comprising:
在根据第一存储区中的主引导程序进行启动后, 确定是否需要升级 ! 导程序; 其中, 所述第一存储区为当前存储区;  After starting according to the main boot program in the first storage area, determine if an upgrade is required! a program; wherein, the first storage area is a current storage area;
当确定需要升级引导程序时, 获得升级信息;  Obtain upgrade information when it is determined that the bootstrap needs to be upgraded;
根据获得的升级信息对第二存储区中的备份引导程序进行升级。  The backup boot program in the second storage area is upgraded according to the obtained upgrade information.
6、 如权利要求 5所述的方法, 其特征在于, 所述确定需要升级引导程 序之前, 所述方法还包括: 判断第一存储区存储的主引导程序是否与第二 存储区存储的备份引导程序一致, 当判断结果为否时, 确定需要升级引导 程序。 The method according to claim 5, wherein before the determining that the boot program needs to be upgraded, the method further comprises: determining whether the primary boot program stored in the first storage area and the backup boot stored in the second storage area The program is consistent. When the judgment result is no, it is determined that the upgrade is required. Program.
7、 如权利要求 5所述的方法, 其特征在于, 所述根据获得的升级信息 对第二存储区中的备份引导程序进行升级之后, 所述方法还包括: 将升级 后的第二存储区切换为当前存储区; 根据该第二存储区中的主引导程序进 行启动, 在启动成功时确定升级成功。  The method of claim 5, wherein after the upgrading the backup boot program in the second storage area according to the obtained upgrade information, the method further comprises: upgrading the second storage area Switch to the current storage area; start according to the main boot program in the second storage area, and determine that the upgrade is successful when the startup is successful.
8、 如权利要求 7所述的方法, 其特征在于, 所述根据该第二存储区中 的主引导程序进行启动之后, 所述方法还包括:  The method of claim 7, wherein the method further comprises: after the booting according to the main booting program in the second storage area, the method further comprises:
判断控制计数器是否溢出, 当判断结果为否时, 确定启动成功, 进而 确定升级成功;  Determining whether the control counter overflows, and when the judgment result is no, determining that the startup is successful, thereby determining that the upgrade is successful;
当判断结果为是时, 继续判断升级失败次数是否大于第二预设值, 当 升级失败次数不大于第二预设值时, 将第一存储区中的备份引导程序切换 为主引导程序, 进行复位操作, 并根据该第一存储区中存储的主引导程序 进行启动;  When the determination result is yes, it is determined whether the number of upgrade failures is greater than a second preset value. When the number of upgrade failures is not greater than the second preset value, the backup boot program in the first storage area is switched to the primary boot program. Reset operation, and starting according to the main boot program stored in the first storage area;
当升级失败次数大于第二预设值时, 确定对第二存储区的升级失败, 发出告警信息, 并继续判断是否需要对第一存储区进行升级, 当需要对第 一存储区进行升级时 , 将第一存储区中的备份引导程序复制到所述第二存 储区, 进行复位操作, 并将所述第二存储区切换为当前存储区, 根据第二 存储区中存储的主 !导程序进行启动。  When the number of upgrade failures is greater than the second preset value, it is determined that the upgrade of the second storage area fails, the alarm information is sent, and the first storage area needs to be upgraded. Copying the backup boot program in the first storage area to the second storage area, performing a reset operation, and switching the second storage area to the current storage area, according to the primary stored in the second storage area! The program starts.
9、 一种引导程序备份装置, 其特征在于, 所述装置包括: 操作模块和 控制模块; 其中,  A boot program backup device, the device comprising: an operation module and a control module;
操作模块, 用于根据默认的或者记录的第一存储区的标识信息, 获得 第一存储区中的主引导程序, 并进行启动; 其中, 所述第一存储区为当前 存储区;  An operation module, configured to obtain, according to the default or the first identification information of the first storage area, the main booting program in the first storage area, and start, wherein the first storage area is a current storage area;
控制模块, 用于在启动成功后, 记录第一存储区的标识信息; 将第一 存储区中的主引导程序备份到同一存储器中的第二存储区。 a control module, configured to: after the startup is successful, record the identification information of the first storage area; and back up the main boot program in the first storage area to the second storage area in the same storage.
10、 如权利要求 9所述的装置, 其特征在于, 所述控制模块, 还用于 在启动成功前接收到复位信号时, 指示操作模块进行复位操作, 并记录启 动总次数; The device according to claim 9, wherein the control module is further configured to: when the reset signal is received before the startup is successful, instruct the operation module to perform a reset operation, and record the total number of starts;
所述操作模块, 还用于在复位操作中将第二存储区切换为当前存储区 后再重新启动。  The operation module is further configured to restart the second storage area after switching to the current storage area in the reset operation.
11、 如权利要求 10所述的装置, 其特征在于, 所述装置还包括: 判断 模块, 用于当每次接到复位信号时, 判断启动总次数是否大于第一设定值; 所述控制模块, 还用于当判断结果为是时, 确定启动失败, 发出告警 信息; 判断结果为否时, 指示操作模块进行复位操作。  The device of claim 10, wherein the device further comprises: a determining module, configured to determine, when each time the reset signal is received, whether the total number of starts is greater than a first set value; The module is further configured to: when the judgment result is yes, determine that the startup fails, and issue an alarm information; when the determination result is no, instruct the operation module to perform a reset operation.
12、 如权利要求 9或 10所述的装置, 其特征在于, 所述装置还包括: 比较模块, 用于在启动成功后, 所述控制模块将第一存储区中的主引导程 序备份到同一存储器中的第二存储区之前, 判断第一存储区存储的主引导 程序是否与第二存储区存储的备份引导程序一致;  The device according to claim 9 or 10, wherein the device further comprises: a comparison module, configured to back up the main boot program in the first storage area to the same after the startup is successful Before the second storage area in the memory, determining whether the primary boot program stored in the first storage area is consistent with the backup boot program stored in the second storage area;
所述操作模块还用于当判断结果为否时, 将第一存储区存储的主引导 程序备份到第二存储区。  The operation module is further configured to back up the main boot program stored in the first storage area to the second storage area when the determination result is no.
13、 一种引导程序升级装置, 其特征在于, 所述装置包括: 控制模块 和操作模块; 其中,  A booting device upgrade device, the device comprising: a control module and an operation module;
控制模块, 用于根据第一存储区中的主引导程序进行启动后, 确定是 否需要升级引导程序; 其中, 所述第一存储区为当前存储区;  a control module, configured to determine, according to a primary boot program in the first storage area, whether to upgrade the boot program; wherein, the first storage area is a current storage area;
操作模块, 用于当确定要升级引导程序时, 获得升级信息, 根据获得 的升级信息对第二存储区中的备份引导程序进行升级。  The operation module is configured to obtain upgrade information when determining that the boot program is to be upgraded, and upgrade the backup boot program in the second storage area according to the obtained upgrade information.
14、 如权利要求 13所述的装置, 其特征在于, 所述装置还包括: 比较 模块, 用于在操作模块确定需要升级引导程序之前, 判断第一存储区存储 的主引导程序是否与第二存储区存储的备份引导程序一致, 当判断结果为 否时, 确定需要升级引导程序。 The device according to claim 13, wherein the device further comprises: a comparing module, configured to determine whether the main booting program stored in the first storage area is second or not before the operating module determines that the booting program needs to be upgraded The backup boot program stored in the storage area is consistent. When the judgment result is no, it is determined that the boot program needs to be upgraded.
15、 如权利要求 13所述的装置, 其特征在于, 所述操作模块, 还用于 在根据获得的升级信息对第二存储区中的备份引导程序进行升级之后, 将 升级后的第二存储区切换为当前存储区; 根据该第二存储区中的主引导程 序进行启动, 在启动成功时确定升级成功。 The device according to claim 13, wherein the operation module is further configured to: after upgrading the backup boot program in the second storage area according to the obtained upgrade information, to upgrade the second storage The area is switched to the current storage area; the startup is started according to the main boot program in the second storage area, and the upgrade is determined to be successful when the startup is successful.
16、 如权利要求 15所述的装置, 其特征在于, 所述控制模块, 还用于 在操作模块根据该第二存储区中的主引导程序进行启动之后, 判断控制计 数器是否溢出, 当判断结果为否时, 确定启动成功, 进而确定升级成功; 当升级失败次数大于第二预设值时, 发出告警信息;  The device according to claim 15, wherein the control module is further configured to: after the operation module starts according to the main boot program in the second storage area, determine whether the control counter overflows, when the judgment result is If no, the startup is successful, and then the upgrade is successful; when the number of upgrade failures is greater than the second preset value, an alarm message is sent;
所述装置还包括: 判断模块, 用于当判断控制计数器为溢出时, 继续 判断升级失败次数是否大于第二预设值; 当升级失败次数大于第二预设值 时, 继续判断是否需要对第一存储区进行升级;  The device further includes: a determining module, configured to: when determining that the control counter is overflow, continue to determine whether the number of upgrade failures is greater than a second preset value; when the number of upgrade failures is greater than a second preset value, continue to determine whether the A storage area is upgraded;
所述操作模块, 还用于当升级失败次数不大于第二预设值时, 将第一 存储区中的备份引导程序切换为主引导程序, 进行复位操作, 并根据该第 一存储区中存储的主 !导程序进行启动;  The operation module is further configured to: when the number of upgrade failures is not greater than the second preset value, switch the backup boot program in the first storage area to the main boot program, perform a reset operation, and store according to the first storage area. Lord! The program is started;
当升级失败次数大于第二预设值时, 确定对第二存储区的升级失败; 当需要对第一存储区进行升级时 , 将第一存储区中的备份?!导程序复 制到所述第二存储区, 进行复位操作, 将所述第二存储区切换为当前存储 区, 根据第二存储区中存储的主引导程序进行启动。  When the number of upgrade failures is greater than the second preset value, it is determined that the upgrade to the second storage area fails; when the first storage area needs to be upgraded, the backup in the first storage area is used? ! The program is copied to the second storage area, performs a reset operation, switches the second storage area to the current storage area, and starts according to the main boot program stored in the second storage area.
PCT/CN2011/080599 2010-12-03 2011-10-10 Method and device for backing up and upgrading bootstrap WO2012071945A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201010571959.2A CN102023908B (en) 2010-12-03 2010-12-03 Method and device for backing up boot program
CN201010571959.2 2010-12-03

Publications (1)

Publication Number Publication Date
WO2012071945A1 true WO2012071945A1 (en) 2012-06-07

Family

ID=43865229

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/080599 WO2012071945A1 (en) 2010-12-03 2011-10-10 Method and device for backing up and upgrading bootstrap

Country Status (2)

Country Link
CN (1) CN102023908B (en)
WO (1) WO2012071945A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104915226A (en) * 2015-05-21 2015-09-16 北京星网锐捷网络技术有限公司 Network device software starting method, device and network device
CN110427286A (en) * 2019-08-09 2019-11-08 成都千立网络科技有限公司 Gateway server main preparation system restoration methods

Families Citing this family (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102023908B (en) * 2010-12-03 2015-06-03 中兴通讯股份有限公司 Method and device for backing up boot program
CN102169445B (en) * 2011-05-13 2013-12-04 合肥华云通信技术有限公司 Security upgrading method for BootRom
CN103136005A (en) * 2011-11-28 2013-06-05 英业达科技有限公司 Method of updating firmware
CN102916776B (en) * 2012-10-15 2015-09-09 青岛海信宽带多媒体技术有限公司 optical module parameter transmission method and device
CN103092662A (en) * 2013-02-04 2013-05-08 烽火通信科技股份有限公司 Software module upgrading method for terminal device based on embedded operating system
JP6364983B2 (en) * 2014-06-10 2018-08-01 富士ゼロックス株式会社 Electronic device and program
CN105320529A (en) * 2014-07-08 2016-02-10 中兴通讯股份有限公司 Boot method and device based on NAND-Flash double-boot guidance
CN105279042A (en) * 2014-07-15 2016-01-27 华耀(中国)科技有限公司 Redundant backup system and method for BSD system
CN104281479B (en) * 2014-10-31 2019-01-08 深圳市大疆创新科技有限公司 A kind of firmware upgrade method and device
CN105279046A (en) * 2015-11-04 2016-01-27 研华科技(中国)有限公司 Method for improving reliability of embedded system
CN106095619A (en) * 2016-06-08 2016-11-09 杭州华三通信技术有限公司 A kind of virtual machine backup method and device
CN106293822A (en) * 2016-08-04 2017-01-04 青岛海信电器股份有限公司 A kind of from the method and device processing chip upgrade
CN106952425B (en) * 2017-02-15 2019-05-14 深圳市新国都支付技术有限公司 A kind of terminal remote upgrade method and POS terminal
CN109375941B (en) * 2018-09-29 2022-01-07 延锋伟世通电子科技(南京)有限公司 Novel master-slave flash boot loader software upgrading method applied to combination instrument
CN109656602A (en) * 2019-01-09 2019-04-19 合肥联宝信息技术有限公司 A kind of code upgrade method and electronic equipment
CN110007971A (en) * 2019-03-25 2019-07-12 联想(北京)有限公司 A kind of information processing method and device, equipment, storage medium
CN110532014B (en) * 2019-08-20 2023-06-30 海信(广东)空调有限公司 Program upgrading method, device, terminal equipment and computer readable storage medium
CN110688135A (en) * 2019-09-20 2020-01-14 浙江吉利汽车研究院有限公司 Program flashing method, device and medium for controller
CN111061514A (en) * 2019-10-30 2020-04-24 翱捷智能科技(上海)有限公司 Flash device, integrated circuit and Flash device starting method
CN111352798A (en) * 2020-01-19 2020-06-30 湖北三江航天红峰控制有限公司 DSP chip-based multi-boot program execution method and device
CN112130914A (en) * 2020-09-04 2020-12-25 山东云海国创云计算装备产业创新中心有限公司 Uboot starting method, device, equipment and medium
CN112612642A (en) * 2020-12-17 2021-04-06 上海芯安信息科技有限公司 Software starting and upgrading failure backspacing method and device and terminal equipment
WO2022133873A1 (en) * 2020-12-24 2022-06-30 Intel Corporation Configurable fault tolerant mechanism
CN112650513B (en) * 2020-12-28 2024-01-16 深圳市亚辉龙生物科技股份有限公司 Program upgrading method, device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1293904A1 (en) * 2001-09-14 2003-03-19 Hewlett-Packard Company Method of initiating a backup procedure
CN101158907A (en) * 2007-10-26 2008-04-09 中兴通讯股份有限公司 Bootstrap on-line upgrading method
CN101169728A (en) * 2007-11-22 2008-04-30 中兴通讯股份有限公司 Dualboot starting device and method
CN101256527A (en) * 2008-03-12 2008-09-03 中兴通讯股份有限公司 Backup method and apparatus for bootstrap
CN102023908A (en) * 2010-12-03 2011-04-20 中兴通讯股份有限公司 Method and device for backing up boot program

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100343807C (en) * 2004-09-14 2007-10-17 华为技术有限公司 Upgrading method for Boot software and recovering method for Boot software

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1293904A1 (en) * 2001-09-14 2003-03-19 Hewlett-Packard Company Method of initiating a backup procedure
CN101158907A (en) * 2007-10-26 2008-04-09 中兴通讯股份有限公司 Bootstrap on-line upgrading method
CN101169728A (en) * 2007-11-22 2008-04-30 中兴通讯股份有限公司 Dualboot starting device and method
CN101256527A (en) * 2008-03-12 2008-09-03 中兴通讯股份有限公司 Backup method and apparatus for bootstrap
CN102023908A (en) * 2010-12-03 2011-04-20 中兴通讯股份有限公司 Method and device for backing up boot program

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104915226A (en) * 2015-05-21 2015-09-16 北京星网锐捷网络技术有限公司 Network device software starting method, device and network device
CN110427286A (en) * 2019-08-09 2019-11-08 成都千立网络科技有限公司 Gateway server main preparation system restoration methods
CN110427286B (en) * 2019-08-09 2022-11-11 成都千立网络科技有限公司 Gateway server main and standby system recovery method

Also Published As

Publication number Publication date
CN102023908B (en) 2015-06-03
CN102023908A (en) 2011-04-20

Similar Documents

Publication Publication Date Title
WO2012071945A1 (en) Method and device for backing up and upgrading bootstrap
JP5607863B2 (en) Secure recovery apparatus and method
JP5575338B2 (en) Information processing apparatus, information processing method, and computer program
JP5431111B2 (en) Information processing apparatus and system setting method
CN108304282B (en) Control method of double BIOS and related device
WO2012079400A1 (en) Method and apparatus for upgrading embedded system bootrom
TW201222554A (en) Handling errors during device bootup from a non-volatile memory
JP2008084291A (en) Storage apparatus, control method, and control device
WO2008104117A1 (en) An electronic equipment, a starting method thereof and a method and device for upgrading bios
WO2014161339A1 (en) Firmware upgrade method and device
US10223217B2 (en) Information processing device, method for booting information processing device, and non-transitory recording medium
TW200847021A (en) Automatic backup, restore and update BIOS computer system
JP2009514042A (en) Network device and method for monitoring startup of such devices
TWI441081B (en) Method for flashing firmware and booting method and electronic apparatus using the method thereof
CN113254048B (en) Method, device and equipment for updating boot program and computer readable medium
JP4620430B2 (en) Apparatus, system, method, recording medium, and program for high-speed loading of adapter
CN106775674B (en) Equipment based on universal boot loader and starting method thereof
JP2007058699A (en) Information processor, information processor control program and information processor control method
JP6482211B2 (en) Information processing apparatus, control method thereof, and program
WO2012097570A1 (en) Method and device for implementing software version synchronization
JPH10307726A (en) System for firmware recovery at time of start error
TW202223655A (en) Computer system and method capable of self-monitoring and restoring an operation of operating system
JP5418348B2 (en) Information processing apparatus and karaoke apparatus
TW200925890A (en) Computer system and starting method thereof
JP2018156230A (en) Information processor

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11844457

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11844457

Country of ref document: EP

Kind code of ref document: A1