WO2017121077A1 - Method and device for switching between two boot files - Google Patents

Method and device for switching between two boot files Download PDF

Info

Publication number
WO2017121077A1
WO2017121077A1 PCT/CN2016/087679 CN2016087679W WO2017121077A1 WO 2017121077 A1 WO2017121077 A1 WO 2017121077A1 CN 2016087679 W CN2016087679 W CN 2016087679W WO 2017121077 A1 WO2017121077 A1 WO 2017121077A1
Authority
WO
WIPO (PCT)
Prior art keywords
boot
flag
register
epld
unit
Prior art date
Application number
PCT/CN2016/087679
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 WO2017121077A1 publication Critical patent/WO2017121077A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping

Definitions

  • the present disclosure relates to computer technology, for example, to a method and apparatus for switching a dual boot file (BOOT).
  • BOOT dual boot file
  • One method is to store the two BOOTs in two storage devices respectively, and the central processing unit (CPU) controls the BOOT of one of the storage devices to boot the operating system in the PC.
  • the peripheral circuit reset control CPU switches to start the BOOT in another storage device.
  • the method requires two storage devices, which increases the hardware cost.
  • Parallel NOR Flash is accessed by parallel bus interface and has multiple address lines, it can be erased and editable logic device (Erasable Programmable Logic). Device, EPLD) controls the high and low address lines for address mapping to implement switching between two BOOTs. But the hardware cost of Parallel NOR Flash is higher.
  • EPLD Erasable Programmable Logic
  • the embodiment of the present invention provides a method and an apparatus for switching a dual boot file, which can reduce hardware costs.
  • the present disclosure provides a method for switching a dual boot file, the method comprising:
  • the dual BOOT boot area flag in the register is switched from the target BOOT boot area flag to the standby BOOT boot area flag, and a reset signal is sent to the processor.
  • the method before the detecting and acquiring the flag bit written in the register by the processor, the method further includes:
  • the detection acquires a flag bit written in the processor, and determines whether the target BOOT is successfully started according to the flag bit, including:
  • the method before the detecting and acquiring the flag bit written in the register by the processor, the method further includes:
  • the dual BOOT boot area flag is read from the serial peripheral interface flash SPI Flash and stored in the register.
  • the present disclosure provides a method for switching a dual boot file, the method further comprising:
  • the method further includes:
  • the second flag bit in the register of the EPLD is written to a second predetermined value.
  • the dual boot file BOOT boot area flag is read, including:
  • the dual BOOT boot sector flag is read from the register of the EPLD.
  • the method further includes:
  • the present disclosure also provides an erasable editable logic device EPLD, comprising:
  • a detection determining unit configured to detect a flag bit in the write processor write register, and determine, according to the flag bit, whether the target boot file BOOT is successfully started;
  • a switching unit configured to: when the detection determining unit determines that the target BOOT fails to start, switch the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag;
  • a sending unit configured to send a reset signal to the processor when the detection determining unit determines that the target BOOT fails to start.
  • the EPLD further includes a timing starting unit
  • the timing starting unit is configured to start a first inversion timer and a second inversion timer in the register to start timing when detecting that the processor writes a timer trigger flag in the register, where
  • the timing of the first inversion timer is a first preset time
  • the timing of the second inversion timer is a second preset time
  • the first preset time is less than the second preset time;
  • the detecting and determining unit is configured to detect, when the first inversion timer initiated by the timing starting unit reaches the first preset time, detecting that the processor writes the first in the register a flag bit; when the first flag bit is not the first predetermined value, determining that the target BOOT fails to start; When the first flag is a first predetermined value, and the second inversion timer initiated by the timing initiation unit reaches the second preset time, detecting that the processor is written into the register a second flag bit; when the second flag bit is not the second predetermined value, determining that the target BOOT fails to start.
  • the EPLD further includes a first reading unit
  • the first reading unit is configured to read the dual BOOT boot area flag from the serial peripheral interface flash SPI Flash and store the same in the register.
  • the present disclosure also provides a processor, the processor comprising:
  • a second reading unit configured to read the dual boot file BOOT boot region flag from a register of the erasable editable logic device EPLD; and read the dual BOOT boot region flag identifier from the serial peripheral interface flash SPI Flash Target BOOT;
  • a running unit configured to run the target BOOT read by the second reading unit
  • a writing unit configured to write to the flag bit in the register of the EPLD to generate a normal identification value of the target BOOT when an abnormality does not occur in the process of running the target BOOT by the running unit;
  • a receiving unit configured to receive a reset signal sent by a register of the EPLD
  • the reset unit is configured to perform a reset operation after the receiving unit receives the reset signal.
  • the second reading unit is further configured to read the secondary loader SPL from the SPI Flash;
  • the operating unit is further configured to run the SPL read by the second reading unit;
  • the writing unit is further configured to write a timer trigger flag to a register of the EPLD when the operating unit starts to run the SPL;
  • the writing unit is configured to, when the running unit runs the target BOOT, write to the first flag bit in the register of the EPLD according to the first handshake information provided in the target BOOT Entering a first predetermined value; after writing the first predetermined value to the first flag bit in the register of the EPLD, before the running unit runs to load the running version of the target BOOT, according to the target BOOT
  • the second handshake information is provided, and a second predetermined value is written to the second flag bit in the register of the EPLD.
  • the second reading unit is configured to read the dual BOOT boot area flag from the register of the EPLD when the running unit runs to the end of the SPL.
  • the processor further includes a startup unit;
  • the running unit is configured to load an running version of the target BOOT, and run an running version of the target BOOT;
  • the startup unit is configured to initiate a watchdog operation when the operation unit starts running the running version of the target BOOT.
  • the embodiment of the invention provides a method and a device for switching a dual boot file.
  • the processor reads a BOOT boot area flag of the dual boot file from the register of the EPLD, that is, a target BOOT boot area flag; according to the dual BOOT boot area flag
  • the processor reads the target BOOT from the SPI Flash and runs the target BOOT; the processor writes to the flag bit in the register of the EPLD when no abnormality occurs during the running of the target BOOT
  • the target BOOT starts a normal identification value; the EPLD detection acquires a flag bit in the processor write register, and determines whether the target BOOT is successfully started according to the flag bit; the EPLD determines that the target BOOT is started.
  • the dual BOOT boot area flag in the register is switched from the target BOOT boot area flag to the standby BOOT boot area flag, and a reset signal is sent to the processor; the processor receives the register of the EPLD After the reset signal is sent, a reset operation is performed; after the processor is reset, the switched dual boot file BOOT boot area is read again from the register of the EPLD. Chi, i.e. spare flag BOOT promoter region; and then read from the SPI Flash promoter in the spare area flag marked BOOT The standby BOOT is recognized and the standby BOOT is operated.
  • the processor utilizes the dual BOOT boot area flag in the EPLD register to implement switching to use the dual BOOT stored in the single-chip SPI Flash, thereby reducing hardware costs.
  • the embodiment of the invention further provides a computer readable storage medium storing computer executable instructions for performing the above method.
  • Embodiments of the present invention also provide an apparatus including one or more processors, a memory, and one or more programs, the one or more programs being stored in a memory when executed by one or more processors , perform the above method.
  • FIG. 1 is a schematic flowchart of a method for switching a dual boot file applied to an EPLD side according to Embodiment 1 of the present disclosure
  • FIG. 2 is a schematic flowchart of a method for switching a dual boot file applied to a processor side according to Embodiment 1 of the present disclosure
  • FIG. 3 is a schematic flowchart of a method for switching a dual boot file according to Embodiment 2 of the present disclosure
  • FIG. 4 is a system architecture diagram of a method for implementing a dual boot file according to Embodiment 2 of the present disclosure
  • FIG. 5 is a structural block diagram of an EPLD according to Embodiment 3 of the present disclosure.
  • FIG. 6 is a structural block diagram of a processor according to Embodiment 3 of the present disclosure.
  • the embodiment of the present disclosure provides a method for switching a dual boot file, which is applied to the EPLD side. As shown in FIG. 1 , the method in this embodiment includes step 101 and step 102.
  • step 101 the flag bit in the acquisition processor write register is detected, and it is determined according to the flag bit whether the target BOOT is successfully started.
  • Serial Peripheral Interface Nor Flash can be used to store dual boot files (ie, dual BOOT): LOW BOOT and HIGH BOOT; EPLD registers (Register) , REG) stores a boot area flag, which is used to control whether the processor uses the LOW BOOT in the SPI Flash or the HIGH BOOT to boot the operating system.
  • the boot area flag may be obtained from an external storage device, such as SPI Flash, or may be initially set in a register of the EPLD.
  • the processor After the processor and the EPLD are powered on or reset, the processor reads the current boot area flag from the register of the EPLD; then reads the corresponding BOOT from the SPI Flash according to the boot area flag, and runs the BOOT.
  • the processor writes a normal identification value to a flag bit in a register of the EPLD when an abnormality does not occur in the process of running the BOOT. For example, the initial value of the flag bit in the register of the EPLD is 0; the processor may write the identification value 1 to the flag bit in the register of the EPLD when no abnormality occurs during the running of the target BOOT.
  • the EPLD detection acquires a flag bit written by the processor into the register, and determines whether the target BOOT is successfully started according to the flag bit.
  • the EPLD detects that the flag bit in the register is the identification value 1, it indicates that the processor does not generate an abnormality during the running of the target BOOT, and the flag bit in the register is written to the target BOOT to start.
  • the normal identification value is 1, the EPLD determines that the target BOOT is successfully started; when the flag bit in the register is the identification value 0, it indicates that the processor has an abnormality in the process of running the target BOOT, not in the register.
  • Flag bit write The target BOOT starts a normal identification value of 1, and the EPLD determines that the target BOOT fails to start.
  • step 102 when it is determined that the target BOOT fails to start, the dual BOOT boot area flag in the register is switched from the target BOOT boot area flag to the standby BOOT boot area flag, and a reset signal is sent to the processor.
  • the EPLD determines that the target BOOT fails to be started, for example, when the identifier value of the flag bit is not 1, the dual BOOT boot area flag in the register of the EPLD is switched by the boot area flag corresponding to the target BOOT. It is a boot area flag corresponding to the standby BOOT, and sends a reset signal to the processor.
  • the dual BOOT boot zone flag is 0, indicating that the LOW BOOT is started; the dual BOOT boot zone flag is 1, indicating that the HIGH BOOT is started. If the processor reads the current boot area flag from the register of the EPLD to be 0, the target BOOT corresponding to the boot area flag read by the processor from the SPI Flash is 0, that is, LOW BOOT According to the above example, the boot area flag corresponding to the target BOOT is 0, and the boot target BOOT: LOW BOOT is identified; the standby BOOT boot area flag is 1, and the identifier starts the standby BOOT: HIGH BOOT.
  • the EPLD determines that the LOW BOOT fails to start, the EPLD switches the boot area flag in the register from the boot area flag 0 corresponding to the target BOOT to the boot area flag 1 corresponding to the standby BOOT, and A reset signal is sent to the processor.
  • the processor performs a reset operation after receiving the reset signal sent by the register of the EPLD.
  • the processor reads, from the register of the EPLD, a boot area identifier that is a switch, that is, a boot area flag 1 corresponding to the standby BOOT, and the processor is configured according to the boot area corresponding to the standby BOOT. Marking, reading the standby BOOT from the SPI Flash, and running the standby BOOT, so that the processor can boot from the target BOOT to the standby BOOT to boot the operating system when the startup target BOOT fails. , to achieve the switching of dual BOOT.
  • the embodiment of the present disclosure further provides a method for switching a dual boot file, which is applied to a processor side. As shown in FIG. 2, the method of this embodiment includes step 201, step 202, step 203 and step 204.
  • step 201 the dual boot file BOOT boot region flag is read from the register of the erasable editable logic device EPLD.
  • the SPI Flash is used in this embodiment to store dual BOOTs: LOW BOOT and HIGH BOOT; the EPLD register stores a dual BOOT boot area flag, and the dual BOOT boot area flag is used to control the processor usage.
  • the LOW BOOT in SPI Flash still uses HIGH BOOT to boot the operating system.
  • the dual BOOT boot area flag may be obtained from an external storage device, such as SPI Flash, or may be initially set in a register of the EPLD.
  • the processor After the processor and the EPLD are powered on or reset, the processor reads the current dual BOOT boot area flag, that is, the target BOOT boot area flag, from the register of the EPLD to determine to enable the LOW BOOT or HIGH BOOT in the dual BOOT. .
  • step 202 the target BOOT of the dual BOOT boot area flag is read from the serial peripheral interface non-volatile flash SPI Flash, and the target BOOT is run.
  • the processor reads the target BOOT of the dual BOOT boot zone flag from the SPI Flash according to the dual BOOT boot zone flag, and runs the target BOOT.
  • the target BOOT is LOW BOOT or HIGH BOOT.
  • the dual BOOT boot zone flag is 0, indicating that the LOW BOOT is started; the dual BOOT boot zone flag is 1, indicating that the HIGH BOOT is started. If the processor reads the current dual BOOT boot area flag from the register of the EPLD to be 0, the dual BOOT boot area flag read by the processor from the SPI Flash is the target corresponding to 0. BOOT is LOW BOOT. According to the above example, the target BOOT boot zone flag is 0, and the boot target BOOT: LOW BOOT is identified; the standby BOOT boot zone flag is 1, and the logo initiates the standby BOOT: HIGH BOOT.
  • step 203 when an abnormality does not occur in the process of running the target BOOT, the flag bit in the register of the EPLD is written to the target BOOT to start a normal identification value.
  • the processor when the processor does not generate an abnormality in the process of running the target BOOT, writing, to the flag bit in the register of the EPLD, the target BOOT starts a normal identification value.
  • the flag bit in the register of the EPLD is initially 0; the processor may write the identifier value to the flag bit in the register of the EPLD when no abnormality occurs during the running of the target BOOT. 1.
  • step 204 after receiving the reset signal transmitted by the register of the EPLD, a reset operation is performed.
  • the EPLD detection acquires a flag bit written by the processor in the register, and when detecting that the flag bit is written by the target BOOT to start a normal identification value, determining that the target BOOT is successfully started; When it is detected that the flag bit is not written by the target BOOT, the target BOOT is determined to fail to start. When determining that the target BOOT fails to start, the EPLD switches the dual BOOT boot area flag in the register from the target BOOT boot area flag 0 to the standby BOOT boot area flag 1, and sends a reset signal to the processor.
  • the processor performs a reset operation after receiving the reset signal sent by the register of the EPLD.
  • the processor After performing the reset operation, the processor performs step 201 to read the switched dual BOOT boot area flag, that is, the standby BOOT boot area flag 1 from the register of the EPLD, according to the standby BOOT.
  • a boot area flag reading the standby BOOT:HIGH BOOT from the SPI Flash, and running the standby BOOT, so that the processor can switch from the target BOOT to the standby BOOT when the startup target BOOT fails To boot the operating system and achieve dual BOOT switching.
  • the embodiment of the present disclosure provides a method for switching a dual boot file, as shown in FIG. 3, this embodiment
  • the method includes steps 301-312.
  • step 301 the EPLD reads the dual BOOT boot area flag from the SPI Flash and stores it in the register.
  • the SPI Flash is used in this embodiment to store dual BOOTs: LOW BOOT and HIGH BOOT;
  • the address space inside the SPI Flash can be divided into: 0 to a address space, a to b address space, b ⁇ c address space, c ⁇ d address space; wherein the 0 ⁇ a address space is used to store a secondary loader (SPL); the a ⁇ b address space for storing LOW BOOT; the b The ⁇ c address space is used to store the HIGH BOOT; the c ⁇ d address space is used to store the dual BOOT boot area flag.
  • the dual BOOT boot area flag is used to identify whether to activate HIGH BOOT or start LOW BOOT.
  • the SPL is used to boot the LOW BOOT or the HIGH BOOT; the contents of the LOW BOOT and the HIGH BOOT are the same; the dual BOOT boot area flag can be represented by one byte, if the byte The highest bit is 0, indicating that the LOW BOOT is enabled; if the highest bit in the byte is 1, it indicates that the HIGH BOOT is started.
  • the user may set some basic configurations of the processor in the SPL according to the needs of the user, and set the basic configuration in the SPL according to the user requirements in the SPL. Better flexibility, smaller storage space and more.
  • the dual BOOT boot area flag can be read from the c-d address space of the SPI Flash and stored in the register of the EPLD.
  • the EPLD can read the dual BOOT boot zone flag in the SPI Flash through the serial peripheral interface (SPI) read timing of the dual BOOT controller and the dual The BOOT boot area flag is stored in the EPLD register.
  • SPI serial peripheral interface
  • step 302 the processor reads the SPL from the SPI Flash and starts running the SPL. At this time, a timer trigger flag is written to the register of the EPLD.
  • the processor After the processor is powered on or reset, the processor reads the SPL from the 0-a address space of the SPI Flash, and stores the read SPL in the memory of the processor, the processor is reading After the SPL is completed, the SPL is started to run.
  • the processor writes a timer trigger flag to a register of the EPLD when the SPL is started to run.
  • the processor has a general purpose input/output (GPIO) interface, and the GPIO interface can serve as a chip select terminal, and a chip select signal in the chip select terminal can control the EPLD.
  • the multiplexer (MUX) in the multiplex chooses to access the register REG of the EPLD or to access the SPI Flash.
  • the chip selection signal may be set by software, and may be set by other methods, which is not specifically limited in this embodiment.
  • the processor further has a synchronous queue serial peripheral interface (Queued SPI, QSPI), and when the processor selects to access the register of the EPLD, the register of the EPLD can be performed by the QSPI. Read and write operations.
  • QSPI synchronous queue serial peripheral interface
  • the processor when the processor needs to access a register of the EPLD, the processor may set a chip select signal in the GPIO interface to 1, and control a MUX in the EPLD to select a register to access the EPLD. And reading and writing the register of the EPLD by using the QSPI; when the processor needs to access the SPI Flash, the processor may set the chip select signal in the GPIO interface to 0, and control The MUX in the EPLD selects to access the SPI Flash, and then reads the content in the SPI Flash through the QSPI.
  • the processor may perform a read/write operation on the register of the EPLD and read the content in the SPI Flash by using the foregoing method.
  • the processor may be an ARM (Advanced RISC Machines). processor.
  • step 303 when the EPLD detects that the processor writes a timer trigger flag in the register, the fast flip timer and the slow flip timer in the register are started to start timing.
  • the fast flip timer and the slow flip timer in the register of the EPLD are started to start timing.
  • the fast rollover timer and the slow rollover timer need to be preset with a preset duration.
  • the timing of the fast rollover timer is less than ten seconds, and the timing of the slow rollover timer is longer.
  • the timing of the fast rollover timer is a first preset time
  • the time duration of the slow rollover timer is a second preset time
  • the first preset time is less than the second preset time.
  • the first preset time may be 5 seconds
  • the second preset time may be 60 seconds.
  • step 304 the processor reads the dual BOOT boot area flag from a register of the EPLD at the end of running the SPL.
  • the processor controls the MUX to select to access the EPLD through a chip select signal in the GPIO interface, and reads the current dual BOOT boot area from the register of the EPLD via the QSPI at the end stage of running the SPL.
  • the flag that is, the target BOOT boot area flag; and the target BOOT boot area flag is stored in the memory of the processor, and the LOW BOOT or the HIGH BOOT is used to boot the operating system according to the target BOOT boot area flag.
  • step 305 the processor reads the target BOOT of the dual BOOT boot area flag identifier from the SPI Flash, and runs the target BOOT.
  • the processor controls the MUX to select to access the SPI Flash through a chip select signal in the GPIO interface; and then according to the dual BOOT boot area flag, that is, the target BOOT boot area.
  • the flag reads the target BOOT from the SPI Flash via the QSPI, stores the target BOOT in the memory of the processor, and runs the target BOOT.
  • the processor when the dual BOOT boot area flag is 0, the processor reads a LOW BOOT whose dual BOOT boot area flag is 0 from the a to b address space of the SPI Flash, and the LOW BOOT is The target BOOT, and the HIGH BOOT of the b ⁇ c address space is the standby BOOT; when the dual BOOT boot area flag is 1, the processor reads the dual BOOT boot area flag from the b ⁇ c address space of the SPI Flash. For the HIGH BOOT identified by 1, the HIGH BOOT is the target BOOT, and the LOW BOOT of the a ⁇ b address space is the standby BOOT.
  • step 306 when the processor runs the target BOOT, the processor writes a useful value to the first flag bit in the register of the EPLD according to the first handshake information provided in the target BOOT.
  • the target BOOT is stored in the memory of the processor, and the target BOOT is provided with first handshake information that interacts with the EPLD.
  • the first handshake information that interacts with the EPLD may be provided by the code board_init_r (Board.c file) that the target BOOT initially runs.
  • the MUX selects to access the EPLD through a chip select signal in the GPIO interface, and the QSPI is used to The first flag bit in the register of the EPLD is written with a useful value.
  • the first flag bit in the register of the EPLD is BDBCR_REG[REV_F]; when the processor runs the target BOOT, according to the target
  • the first handshake information provided in the BOOT writes the useful value 1 to the first flag bit BDBCR_REG[REV_F] in the register of the EPLD; the EPLD acquires the flag bit BDBCR_REG[REV_F], and detects the flag Whether the identifier value of the bit BDBCR_REG[REV_F] is 1; when the identifier value of the flag bit BDBCR_REG[REV_F] is 1, it indicates that the processor can correctly load the target BOOT.
  • the fast flip timer in the register of the EPLD has not reached the first preset time of 5 seconds. Similarly, the fast flip timer continues to count and does not reach the first The preset time is 60 seconds; the fast flip timer does not allow the EPLD to switch the dual BOOT boot zone flag in the register from the target BOOT boot zone flag to the standby BOOT before the first preset time is reached.
  • the boot area flag that is, the EPLD is not allowed to reverse the highest bit of the dual BOOT boot area flag.
  • the chip select signal of the GPIO interface is automatically set to zero.
  • step 307 when the fast flip timer reaches the first preset time, the EPLD detects that the processor writes the first flag bit in the register.
  • the EPLD detects whether the first flag bit written by the processor in the register is acquired. A useful value of 1 was successfully written.
  • step 3081 the EPLD switches the dual BOOT boot zone flag in the register from the target BOOT boot zone flag to the standby BOOT boot zone flag when the first flag bit is not a useful value, and
  • the processor sends a reset signal.
  • the EPLD may determine that the target BOOT is not properly loaded by the processor, and the target BOOT is unavailable. At this time, the EPLD determines that the processor fails to start the target BOOT.
  • the EPLD when determining that the target BOOT fails to start, switches the dual BOOT boot area flag in the register of the EPLD from the target BOOT boot area flag to the standby BOOT boot area flag, and sends the flag to the processor.
  • the reset signal, the processor performs step 312.
  • the EPLD switches the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag, including: the EPLD will be in the register The highest bit of the dual BOOT boot area flag is inverted. That is, the standby BOOT boot area flag is a dual BOOT boot area flag after the highest bit of the target BOOT boot area flag is inverted.
  • the EPLD sets the highest bit of the dual BOOT boot area flag in its register.
  • the bit is inverted from 0 to 1, and a reset signal is sent to the processor, and after the processor resets, the highest bit of the dual BOOT boot area flag is read from the EPLD and read from its register.
  • the HIGH BOOT that is, the standby BOOT, is started according to the dual BOOT boot area flag, and the switching from the LOW BOOT to the HIGH BOOT is realized.
  • step 3082 after the processor writes a useful value to the first flag bit in the register of the EPLD, before running to load the running version of the target BOOT, according to the number provided in the target BOOT
  • the second handshake information writes a valid value to the second flag bit in the register of the EPLD.
  • the EPLD When the first flag bit in the register of the EPLD is set to a useful value of 1, indicating that the processor obtains the first handshake information provided in the target BOOT, to the first of the registers of the EPLD The flag bit is written to a useful value of 1, and the EPLD can determine that the target BOOT has been properly loaded by the processor. At this time, the EPLD does not perform the switching of the dual BOOT boot area flag, nor does it send a reset signal to the processor, and the processor continues to run the target BOOT.
  • the processor controls the MUX selection access by using a chip select signal in the GPIO interface according to the second handshake information provided in the target BOOT to interact with the EPLD.
  • the register of the EPLD writes a valid value to the second flag of the register of the EPLD.
  • the valid value may be 1, and the valid value is used to indicate that the processor has completed the initial execution of the target BOOT. Boot, ready to load the running version of the target BOOT.
  • the processor starts from running the SPL to load the target.
  • the slow rollover timer in the register of the EPLD has not reached the second preset time of 60 seconds; the slow rollover timer before reaching the second preset time
  • the EPLD is not allowed to switch the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag, that is, the EPLD is not allowed to invert the highest bit of the dual BOOT boot area flag. operating.
  • the chip select signal of the GPIO interface is automatically set to zero.
  • the EPLD is a useful value when the first flag bit, and when the slow rollover timer reaches the second preset time, detecting that the processor is written into the register The second flag.
  • the first flag bit in the register of the EPLD is a useful value, and when the slow rollover timer reaches the second preset time of 60 seconds, the EPLD detection acquires the processor write location Whether the second flag bit in the register is successfully written to a valid value.
  • step 3101 when the second flag bit is not a valid value, the EPLD switches the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag, and sends the flag to the processor. Reset signal.
  • the EPLD may determine that the processor does not initialize the target BOOT incorrectly, and the processor does not complete initial booting of the target BOOT. At this time, the EPLD determines that the processor starts the target. BOOT failed.
  • the EPLD switches the dual BOOT boot zone flag in the register of the EPLD from the target BOOT boot zone flag to the standby BOOT boot zone. The flag is sent to the processor and the processor executes step 312.
  • the EPLD switches the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag, including: the EPLD will mark the dual BOOT boot area in the register. The highest bit is inverted. That is, the standby BOOT boot area flag is a dual BOOT boot area flag after the highest bit of the target BOOT boot area flag is inverted.
  • the EPLD sets the highest bit of the dual BOOT boot area flag in its register. The bit is inverted from 0 to 1, and a reset signal is sent to the processor.
  • step 3102 the processor loads the running version of the target BOOT after writing a valid value to the second flag bit in the register of the EPLD.
  • the second flag bit in the register of the EPLD When the second flag bit in the register of the EPLD is set to a valid value of 1, indicating that the processor obtains the second handshake information provided in the target BOOT, and the second in the register of the EPLD The flag bit is written to a valid value of 1, and the EPLD can determine that the processor has completed the initial boot of the target BOOT and prepare to load the running version of the target BOOT.
  • the processor loads an running version of the target BOOT from a storage device that stores an running version of the target BOOT.
  • the storage device storing the running version of the target BOOT is a flash memory or other storage.
  • step 311 the processor starts a watchdog operation when it starts running the running version of the target BOOT.
  • the processor starts a watchdog operation when the target BOOT starts running the running version, and a timer in the watchdog timer starts timing.
  • the processor periodically releases the dog to the watchdog during the running of the running version of the target BOOT; after the watchdog receives the dog feeding signal, Clearing the timer, the timer does not overflow the preset timing, and the reset signal cannot be generated.
  • the watchdog sends a reset signal to the EPLD and the processor, and the EPLD receives After the reset signal sent by the watchdog, the method of this embodiment starts from step 301 again.
  • step 312 the processor performs a reset operation after receiving the reset signal sent by the register of the EPLD.
  • the processor After receiving the reset signal sent by the register of the EPLD, the processor indicates that the processor fails to start the target BOOT, and the processor performs a reset operation, and the method in this embodiment starts from step 302 again.
  • the processor After the processor performs a reset operation and returns to step 302, the processor reads the switched dual BOOT boot area flag, that is, the standby BOOT boot area flag, from the register of the EPLD, the processor according to the The standby BOOT boot area flag reads the standby BOOT from the SPI Flash, and runs the standby BOOT, so that the processor is switched from the target BOOT to the standby BOOT to boot the operating system, thereby realizing the use of the single piece.
  • SPI Flash performs dual BOOT switching.
  • the dual BOOT online upgrade can be performed in two ways, one is to connect a PC through an LPC (Low Pin Count) cable to download a new BOOT, the upgrade method is used to download the BOOT for the first time; the other is The running version is upgraded by the processor, and the upgrade of the running version can only be the running version of the non-target BOOT running.
  • LPC Low Pin Count
  • a single SPI Flash is used as the storage device.
  • the SPI Flash is accessed by a serial peripheral interface. There is only one address line.
  • the EPLD cannot implement address mapping by controlling the high and low address lines to implement two BOOTs. Switch.
  • the single-chip SPI Flash is divided into different areas according to different address spaces to store SPL, LOW BOOT, HIGH BOOT and double.
  • a BOOT boot area flag when the processor does not generate an abnormality in the process of running the target BOOT, writing a flag value of the target BOOT to the flag in the register of the EPLD to start a normal identification value; the EPLD passes the detection Obtaining a flag bit in the processor write register to determine whether to switch a dual BOOT boot area flag in the register; and the processor selects to activate a BOOT according to the dual BOOT boot area flag in the EPLD; thus, The processor utilizes the dual BOOT boot area flag in the EPLD register to implement switching between dual BOOTs stored in a single SPI Flash, thereby reducing hardware costs.
  • the embodiment of the present disclosure further provides an EPLD.
  • the EPLD includes: a detection determining unit 501, a switching unit 502, and a sending unit 503.
  • the detection determining unit 501 is configured to detect a flag bit in the write register of the acquisition processor, and determine, according to the flag bit, whether the target BOOT is successfully started;
  • the switching unit 502 is configured to, when the detection determining unit 501 determines that the target BOOT fails to start, switch the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag.
  • the transmitting unit 503 is configured to transmit a reset signal to the processor when the detection determining unit 501 determines that the target BOOT fails to start.
  • the EPLD further includes a timing starting unit 504.
  • the timing initiation unit 504 is configured to initiate a fast rollover timer and a slow rollover timer in the register to start timing when detecting that the processor writes a timer trigger flag in the register, wherein the fast
  • the timing of the rollover timer is a first preset time
  • the time duration of the slow rollover timer is a second preset time
  • the first preset time is less than the second preset time.
  • the detection determining unit 501 is specifically configured to start the fast when the timing starting unit 504 starts When the rollover timer reaches the first preset time, detecting that the processor writes the first flag bit in the register; when the first flag bit is not a useful value, determining that the target BOOT fails to start; The first flag is a useful value, and when the timing initiation unit 504 starts the slow rollover timer to reach the second preset time, detecting that the processor writes the second in the register Flag bit; when the second flag bit is not a valid value, it is determined that the target BOOT fails to start.
  • the EPLD further includes a first reading unit 505.
  • the first reading unit 505 is configured to read a dual boot file BOOT boot area flag from the serial peripheral interface non-volatile flash SPI Flash and store the same in the register.
  • the embodiment of the present disclosure further provides a processor.
  • the processor includes: a second reading unit 601, an operating unit 602, a writing unit 603, a receiving unit 604, and a reset unit 605.
  • the second reading unit 601 is configured to read the dual boot file BOOT boot area flag from the register of the erasable editable logic device EPLD; read from the serial peripheral interface flash SPI Flash according to the dual BOOT boot area flag Take the target BOOT.
  • the running unit 602 is configured to run the target BOOT read by the second reading unit 601.
  • the writing unit 603 is configured to write to the flag bit in the register of the EPLD to write the flag value of the target BOOT to start normal when an abnormality does not occur in the process of the operation unit 602 running the target BOOT.
  • the receiving unit 604 is configured to receive a reset signal sent by a register of the EPLD.
  • the reset unit 605 is configured to perform a reset operation after the receiving unit 604 receives the reset signal.
  • the second reading unit 601 is further configured to read the secondary loader SPL from the SPI Flash.
  • the running unit 602 is further configured to run the SPL read by the second reading unit 601.
  • the writing unit 603 is further configured to write a timer trigger flag to the register of the EPLD when the operating unit 602 starts to run the SPL.
  • the writing unit 603 is specifically configured to, when the running unit 602 runs the target BOOT, write to the first flag bit in the register of the EPLD according to the first handshake information provided in the target BOOT. a useful value; after writing the useful value to the first flag bit in the register of the EPLD, before the running unit 602 runs to load the running version of the target BOOT, according to the second provided in the target BOOT
  • the handshake information writes a valid value to the second flag bit in the register of the EPLD.
  • the second reading unit 601 is specifically configured to read the dual BOOT boot area flag from the register of the EPLD when the running unit 602 runs to the end of the SPL.
  • the processor further includes a starting unit 606.
  • the running unit 602 is further configured to load an running version of the target BOOT and run a running version of the target BOOT.
  • the startup unit 606 is configured to initiate a watchdog operation when the execution unit 602 starts running the running version of the target BOOT.
  • the detection determining unit 501, the switching unit 502, the sending unit 503, the timing starting unit 504, and the first reading unit 505 described in this embodiment may be implemented by a central processing unit (CPU) on the adjusting device.
  • a central processing unit CPU
  • MCU Microcontroller Unit
  • DSP Digital Signal Processing
  • FPGA Field Programmable Gate Array
  • the second reading unit 601, the running unit 602, the writing unit 603, the receiving unit 604, the reset unit 605, and the starting unit 606 described in this embodiment may be processed by a central processing unit (CPU) on the metadata node.
  • embodiments of the present disclosure can be provided as a method, system, or computer program product. Accordingly, the present disclosure may take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware aspects. Moreover, the present disclosure may 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.) including computer usable program code.
  • 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 blocks of a flow or a flow and/or block diagram of the flowchart.
  • 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 of the flow or in a block or blocks of a flow diagram.
  • the technical solution of the embodiments of the present disclosure may be embodied in the form of a software product stored in a storage medium (such as a ROM/RAM, a magnetic disk, an optical disk), including instructions for making one
  • the terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) performs the method described in the embodiments of the present disclosure.
  • the embodiment of the present disclosure realizes switching between dual BOOTs stored in a single SPI Flash by setting a dual BOOT boot area flag in a register of the EPLD, which does not require too many address lines, has simple control, and reduces hardware cost.

Landscapes

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

Abstract

Disclosed in an embodiment of the present disclosure is a method of switching between two boot files. The method comprises: performing detection to acquire a flag bit written into a register by a processor, and determining, according to the flag bit, whether a target boot file successfully starts the boot; and if it is determined that the target boot file fails to start the boot, switching a dual boot sector flag in the register from a target boot sector flag to a backup boot sector flag, and sending a reset signal to the processor. Also disclosed in an embodiment of the present disclosure is a device for switching between two boot files.

Description

一种双引导文件的切换方法及装置Method and device for switching double boot file 技术领域Technical field
本公开涉及计算机技术,例如涉及一种双引导文件(BOOT)的切换方法及装置。The present disclosure relates to computer technology, for example, to a method and apparatus for switching a dual boot file (BOOT).
背景技术Background technique
目前,在启动个人计算机(Personal Computer,PC)时,通常是由存储于闪存(Flash)中的BOOT来引导启动PC中的操作系统的。如果存储BOOT的闪存出现故障,或者在远程升级BOOT时遇到如断电等的突发情况,导致BOOT丢失时,会造成BOOT启动失败,进而导致PC中的操作系统无法正常启动。为了解决该问题,相关技术中通常都设置两个BOOT,这样在一个BOOT启动失败时,就可以使用切换到使用另一个BOOT来引导启动PC中的操作系统。相关技术中进行双BOOT切换的方法主要有以下两种:Currently, when a personal computer (PC) is started, it is usually booted by a BOOT stored in a flash memory to boot an operating system in the PC. If the flash memory of the storage BOOT fails, or an unexpected situation such as power failure occurs during remote upgrade of the BOOT, the BOOT fails to be booted, causing the BOOT to fail to start, and the operating system in the PC cannot be started normally. In order to solve this problem, two BOOTs are usually set in the related art, so that when a BOOT fails to boot, it is possible to switch to use another BOOT to boot the operating system in the PC. There are two main methods for performing dual BOOT switching in the related art:
一种方法是将这两个BOOT分别存储于两片存储设备中,由外围电路来控制中央处理器(Central Processing Unit,CPU)选择启动其中一个存储设备的BOOT来引导启动PC中的操作系统,当该BOOT启动失败后,所述外围电路复位控制CPU切换启动另一个存储设备中的BOOT,然而,该方法需要两片存储设备,增加了硬件成本。One method is to store the two BOOTs in two storage devices respectively, and the central processing unit (CPU) controls the BOOT of one of the storage devices to boot the operating system in the PC. When the BOOT fails to boot, the peripheral circuit reset control CPU switches to start the BOOT in another storage device. However, the method requires two storage devices, which increases the hardware cost.
另一种方法是在单片并行闪存(Parallel NOR Flash)中划分出两个区域来分别存储这两个BOOT。由于Parallel NOR Flash采用并行总线接口访问,具有多根地址线,故可以由可擦除可编辑逻辑器件(Erasable Programmable Logic  Device,EPLD)控制高低地址线进行地址映射来实现两个BOOT的切换。但是Parallel NOR Flash的硬件成本较高。Another method is to divide two areas in Parallel NOR Flash to store the two BOOTs separately. Because Parallel NOR Flash is accessed by parallel bus interface and has multiple address lines, it can be erased and editable logic device (Erasable Programmable Logic). Device, EPLD) controls the high and low address lines for address mapping to implement switching between two BOOTs. But the hardware cost of Parallel NOR Flash is higher.
发明内容Summary of the invention
有鉴于此,本发明实施例提供一种双引导文件的切换方法及装置,可以降低硬件成本。In view of this, the embodiment of the present invention provides a method and an apparatus for switching a dual boot file, which can reduce hardware costs.
一方面,本公开提供了一种双引导文件的切换方法,所述方法包括:In one aspect, the present disclosure provides a method for switching a dual boot file, the method comprising:
检测获取处理器写入寄存器中的标志位,并根据所述标志位判断目标引导文件BOOT是否启动成功;以及Detecting a flag bit in the processor write register, and determining, according to the flag bit, whether the target boot file BOOT is successfully started;
在确定所述目标BOOT启动失败时,将所述寄存器中的双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,并向所述处理器发送复位信号。When it is determined that the target BOOT fails to start, the dual BOOT boot area flag in the register is switched from the target BOOT boot area flag to the standby BOOT boot area flag, and a reset signal is sent to the processor.
可选的,所述检测获取处理器写入寄存器中的标志位之前,所述方法还包括:Optionally, before the detecting and acquiring the flag bit written in the register by the processor, the method further includes:
检测到所述处理器写入所述寄存器中的定时器触发标志时,启动所述寄存器中的第一翻转定时器和第二翻转定时器开始计时,其中,所述第一翻转定时器的定时时长为第一预设时间,所述第二翻转定时器的定时时长为第二预设时间,所述第一预设时间小于所述第二预设时间;When detecting that the processor writes a timer trigger flag in the register, starting a first flip timer and a second flip timer in the register to start timing, wherein a timing of the first flip timer The duration of the second preset timer is a second preset time, and the first preset time is less than the second preset time;
其中,所述检测获取处理器写入寄存器中的标志位,并根据所述标志位判断目标BOOT是否启动成功,包括:The detection acquires a flag bit written in the processor, and determines whether the target BOOT is successfully started according to the flag bit, including:
当所述第一翻转定时器达到所述第一预设时间时,检测获取所述处理器写入所述寄存器中的第一标志位;在所述第一标志位不是第一预定值时,确定目标BOOT启动失败; When the first flip timer reaches the first preset time, detecting that the processor writes a first flag bit in the register; when the first flag bit is not the first predetermined value, Determine that the target BOOT failed to start;
在所述第一标志位是第一预定值,且所述第二翻转定时器达到所述第二预设时间时,检测获取所述处理器写入所述寄存器中的第二标志位;在所述第二标志位不是第二预定值时,确定目标BOOT启动失败。When the first flag bit is a first predetermined value, and the second rollover timer reaches the second preset time, detecting that the processor writes the second flag bit in the register; When the second flag is not the second predetermined value, it is determined that the target BOOT fails to start.
可选的,所述检测获取处理器写入寄存器中的标志位之前,所述方法还包括:Optionally, before the detecting and acquiring the flag bit written in the register by the processor, the method further includes:
从串行外设接口闪存SPI Flash中读取双BOOT启动区标志并存入所述寄存器中。The dual BOOT boot area flag is read from the serial peripheral interface flash SPI Flash and stored in the register.
本公开提供了一种双引导文件的切换方法,所述方法还包括:The present disclosure provides a method for switching a dual boot file, the method further comprising:
读取双引导文件BOOT启动区标志;Read the BOOT boot area flag of the dual boot file;
读取所述双BOOT启动区标志对应的目标BOOT,并运行所述目标BOOT;Reading the target BOOT corresponding to the dual BOOT boot zone flag, and running the target BOOT;
在运行所述目标BOOT的过程中未出现异常时,向EPLD的寄存器中的标志位写入所述目标BOOT启动正常的标识值;When an abnormality does not occur in the process of running the target BOOT, writing a flag value in the register of the EPLD to the target BOOT to start a normal identification value;
在接收到复位信号后,进行复位操作。After receiving the reset signal, a reset operation is performed.
可选的,在读取双引导文件BOOT启动区标志之前,所述方法还包括:Optionally, before the dual boot file BOOT boot area flag is read, the method further includes:
从SPI Flash中读取二次加载程序SPL,在开始运行所述SPL时,向所述EPLD的寄存器中写入定时器触发标志;Reading the secondary loader SPL from the SPI Flash, and writing a timer trigger flag to the register of the EPLD when the SPL is started to run;
所述在运行所述目标BOOT的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入所述目标BOOT启动正常的标识值,包括:And when the abnormality does not occur in the process of running the target BOOT, writing, to the flag bit in the register of the EPLD, the flag value of the target BOOT to start normal, including:
在运行所述目标BOOT时,根据所述目标BOOT中提供的第一握手信息,向所述EPLD的寄存器中的第一标志位写入第一预定值;Writing the first predetermined value to the first flag bit in the register of the EPLD according to the first handshake information provided in the target BOOT when the target BOOT is run;
在向所述EPLD的寄存器中的第一标志位写入第一预定值后,在运行到加载所述目标BOOT的运行版本之前,根据所述目标BOOT中提供的第二握手信息,向所述EPLD的寄存器中的第二标志位写入第二预定值。 After writing the first predetermined value to the first flag bit in the register of the EPLD, before running to load the running version of the target BOOT, according to the second handshake information provided in the target BOOT, The second flag bit in the register of the EPLD is written to a second predetermined value.
可选的,读取双引导文件BOOT启动区标志,包括:Optionally, the dual boot file BOOT boot area flag is read, including:
在运行所述SPL的末尾阶段,从所述EPLD的寄存器中读取双BOOT启动区标志。At the end of the run of the SPL, the dual BOOT boot sector flag is read from the register of the EPLD.
可选的,所述向所述EPLD的寄存器中的第二标志位写入第二预定值后,所述方法还包括:Optionally, after the writing the second predetermined value in the register of the EPLD, the method further includes:
加载所述目标BOOT的运行版本,并在开始运行所述目标BOOT的运行版本时,启动看门狗操作。Loading the running version of the target BOOT and starting the watchdog operation when starting to run the running version of the target BOOT.
本公开还提供了一种可擦除可编辑逻辑器件EPLD,包括:The present disclosure also provides an erasable editable logic device EPLD, comprising:
检测判断单元,设置为检测获取处理器写入寄存器中的标志位,并根据所述标志位判断目标引导文件BOOT是否启动成功;a detection determining unit, configured to detect a flag bit in the write processor write register, and determine, according to the flag bit, whether the target boot file BOOT is successfully started;
切换单元,设置为在所述检测判断单元确定所述目标BOOT启动失败时,将所述寄存器中的双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志;a switching unit, configured to: when the detection determining unit determines that the target BOOT fails to start, switch the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag;
发送单元,设置为在所述检测判断单元确定所述目标BOOT启动失败时向所述处理器发送复位信号。And a sending unit, configured to send a reset signal to the processor when the detection determining unit determines that the target BOOT fails to start.
可选的,所述EPLD还包括定时启动单元;Optionally, the EPLD further includes a timing starting unit;
所述定时启动单元,设置为在检测到所述处理器写入所述寄存器中的定时器触发标志时,启动所述寄存器中的第一翻转定时器和第二翻转定时器开始计时,其中,所述第一翻转定时器的定时时长为第一预设时间,所述第二翻转定时器的定时时长为第二预设时间,所述第一预设时间小于所述第二预设时间;The timing starting unit is configured to start a first inversion timer and a second inversion timer in the register to start timing when detecting that the processor writes a timer trigger flag in the register, where The timing of the first inversion timer is a first preset time, the timing of the second inversion timer is a second preset time, and the first preset time is less than the second preset time;
其中,所述检测判断单元,设置为当所述定时启动单元启动的所述第一翻转定时器达到所述第一预设时间时,检测获取所述处理器写入所述寄存器中的第一标志位;在所述第一标志位不是第一预定值时,确定目标BOOT启动失败; 在所述第一标志位是第一预定值,且所述定时启动单元启动的所述第二翻转定时器达到所述第二预设时间时,检测获取所述处理器写入所述寄存器中的第二标志位;在所述第二标志位不是第二预定值时,确定目标BOOT启动失败。The detecting and determining unit is configured to detect, when the first inversion timer initiated by the timing starting unit reaches the first preset time, detecting that the processor writes the first in the register a flag bit; when the first flag bit is not the first predetermined value, determining that the target BOOT fails to start; When the first flag is a first predetermined value, and the second inversion timer initiated by the timing initiation unit reaches the second preset time, detecting that the processor is written into the register a second flag bit; when the second flag bit is not the second predetermined value, determining that the target BOOT fails to start.
可选的,所述EPLD还包括第一读取单元;Optionally, the EPLD further includes a first reading unit;
所述第一读取单元,设置为从串行外设接口闪存SPI Flash中读取双BOOT启动区标志并存入所述寄存器中。The first reading unit is configured to read the dual BOOT boot area flag from the serial peripheral interface flash SPI Flash and store the same in the register.
本公开还提供了一种处理器,所述处理器包括:The present disclosure also provides a processor, the processor comprising:
第二读取单元,设置为从可擦除可编辑逻辑器件EPLD的寄存器中读取双引导文件BOOT启动区标志;并从串行外设接口闪存SPI Flash读取所述双BOOT启动区标志标识的目标BOOT;a second reading unit configured to read the dual boot file BOOT boot region flag from a register of the erasable editable logic device EPLD; and read the dual BOOT boot region flag identifier from the serial peripheral interface flash SPI Flash Target BOOT;
运行单元,设置为运行所述第二读取单元读取到的所述目标BOOT;a running unit, configured to run the target BOOT read by the second reading unit;
写入单元,设置为在所述运行单元运行所述目标BOOT的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入所述目标BOOT启动正常的标识值;a writing unit, configured to write to the flag bit in the register of the EPLD to generate a normal identification value of the target BOOT when an abnormality does not occur in the process of running the target BOOT by the running unit;
接收单元,设置为接收所述EPLD的寄存器发送的复位信号;a receiving unit, configured to receive a reset signal sent by a register of the EPLD;
复位单元,设置为在所述接收单元接收到所述复位信号后,进行复位操作。The reset unit is configured to perform a reset operation after the receiving unit receives the reset signal.
可选的,所述第二读取单元,还设置为从所述SPI Flash中读取二次加载程序SPL;Optionally, the second reading unit is further configured to read the secondary loader SPL from the SPI Flash;
所述运行单元,还设置为运行所述第二读取单元读取到的所述SPL;The operating unit is further configured to run the SPL read by the second reading unit;
所述写入单元,还设置为在所述运行单元开始运行所述SPL时,向所述EPLD的寄存器中写入定时器触发标志;The writing unit is further configured to write a timer trigger flag to a register of the EPLD when the operating unit starts to run the SPL;
所述写入单元,设置为在所述运行单元运行所述目标BOOT时,根据所述目标BOOT中提供的第一握手信息,向所述EPLD的寄存器中的第一标志位写 入第一预定值;在向所述EPLD的寄存器中的第一标志位写入第一预定值后,在所述运行单元运行到加载所述目标BOOT的运行版本之前,根据所述目标BOOT中提供的第二握手信息,向所述EPLD的寄存器中的第二标志位写入第二预定值。The writing unit is configured to, when the running unit runs the target BOOT, write to the first flag bit in the register of the EPLD according to the first handshake information provided in the target BOOT Entering a first predetermined value; after writing the first predetermined value to the first flag bit in the register of the EPLD, before the running unit runs to load the running version of the target BOOT, according to the target BOOT The second handshake information is provided, and a second predetermined value is written to the second flag bit in the register of the EPLD.
可选的,所述第二读取单元,设置为在所述运行单元运行到所述SPL的末尾阶段,从所述EPLD的寄存器中读取双BOOT启动区标志。Optionally, the second reading unit is configured to read the dual BOOT boot area flag from the register of the EPLD when the running unit runs to the end of the SPL.
可选的,所述处理器还包括启动单元;Optionally, the processor further includes a startup unit;
所述运行单元,设置为加载所述目标BOOT的运行版本,以及运行所述目标BOOT的运行版本;The running unit is configured to load an running version of the target BOOT, and run an running version of the target BOOT;
所述启动单元,设置为在所述运行单元开始运行所述目标BOOT的运行版本时,启动看门狗操作。The startup unit is configured to initiate a watchdog operation when the operation unit starts running the running version of the target BOOT.
本发明实施例提供了一种双引导文件的切换方法及装置,首先处理器从EPLD的寄存器中读取双引导文件BOOT启动区标志,即目标BOOT启动区标志;根据所述双BOOT启动区标志,所述处理器从SPI Flash读取目标BOOT,并运行所述目标BOOT;所述处理器在运行所述目标BOOT的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入所述目标BOOT启动正常的标识值;所述EPLD检测获取所述处理器写入寄存器中的标志位,并根据所述标志位判断目标BOOT是否启动成功;所述EPLD在确定所述目标BOOT启动失败时,将所述寄存器中的双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,并向所述处理器发送复位信号;所述处理器在接收到所述EPLD的寄存器发送的复位信号后,进行复位操作;所述处理器复位后重新从所述EPLD的寄存器中读取切换后的双引导文件BOOT启动区标志,即备用BOOT启动区标志;然后从所述SPI Flash中读取所述备用BOOT启动区标志标 识的备用BOOT,并运行所述备用BOOT,这样,所述处理器就利用EPLD的寄存器中的双BOOT启动区标志,实现了切换使用单片SPI Flash中存储的双BOOT,降低了硬件成本。The embodiment of the invention provides a method and a device for switching a dual boot file. First, the processor reads a BOOT boot area flag of the dual boot file from the register of the EPLD, that is, a target BOOT boot area flag; according to the dual BOOT boot area flag The processor reads the target BOOT from the SPI Flash and runs the target BOOT; the processor writes to the flag bit in the register of the EPLD when no abnormality occurs during the running of the target BOOT The target BOOT starts a normal identification value; the EPLD detection acquires a flag bit in the processor write register, and determines whether the target BOOT is successfully started according to the flag bit; the EPLD determines that the target BOOT is started. In case of failure, the dual BOOT boot area flag in the register is switched from the target BOOT boot area flag to the standby BOOT boot area flag, and a reset signal is sent to the processor; the processor receives the register of the EPLD After the reset signal is sent, a reset operation is performed; after the processor is reset, the switched dual boot file BOOT boot area is read again from the register of the EPLD. Chi, i.e. spare flag BOOT promoter region; and then read from the SPI Flash promoter in the spare area flag marked BOOT The standby BOOT is recognized and the standby BOOT is operated. Thus, the processor utilizes the dual BOOT boot area flag in the EPLD register to implement switching to use the dual BOOT stored in the single-chip SPI Flash, thereby reducing hardware costs.
本发明实施例还提供一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行上述方法。The embodiment of the invention further provides a computer readable storage medium storing computer executable instructions for performing the above method.
本发明实施例还提供一种设备,该设备包括一个或多个处理器、存储器以及一个或多个程序,所述一个或多个程序存储在存储器中,当被一个或多个处理器执行时,执行上述方法。Embodiments of the present invention also provide an apparatus including one or more processors, a memory, and one or more programs, the one or more programs being stored in a memory when executed by one or more processors , perform the above method.
附图说明DRAWINGS
图1为本公开实施例1提供的一种应用于EPLD一侧的双引导文件的切换方法的流程示意图;1 is a schematic flowchart of a method for switching a dual boot file applied to an EPLD side according to Embodiment 1 of the present disclosure;
图2为本公开实施例1提供的一种应用于处理器一侧的双引导文件的切换方法的流程示意图;2 is a schematic flowchart of a method for switching a dual boot file applied to a processor side according to Embodiment 1 of the present disclosure;
图3为本公开实施例2提供的一种双引导文件的切换方法的流程示意图;3 is a schematic flowchart of a method for switching a dual boot file according to Embodiment 2 of the present disclosure;
图4为本公开实施例2提供的实现一种双引导文件的切换方法的系统架构图;4 is a system architecture diagram of a method for implementing a dual boot file according to Embodiment 2 of the present disclosure;
图5为本公开实施例3提供的一种EPLD的结构框图;以及FIG. 5 is a structural block diagram of an EPLD according to Embodiment 3 of the present disclosure;
图6为本公开实施例3提供的一种处理器的结构框图。FIG. 6 is a structural block diagram of a processor according to Embodiment 3 of the present disclosure.
实施方式Implementation
下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述。 The technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure.
实施例1Example 1
本公开实施例提供了一种双引导文件的切换方法,应用于EPLD一侧,如图1所示,本实施例方法包括步骤101和步骤102。The embodiment of the present disclosure provides a method for switching a dual boot file, which is applied to the EPLD side. As shown in FIG. 1 , the method in this embodiment includes step 101 and step 102.
在步骤101中,检测获取处理器写入寄存器中的标志位,并根据所述标志位判断目标BOOT是否启动成功。In step 101, the flag bit in the acquisition processor write register is detected, and it is determined according to the flag bit whether the target BOOT is successfully started.
为了降低硬件成本,本实施例中可以采用串行外设接口闪存(Serial Peripheral Interface Nor Flash,SPI Flash)来存储双引导文件(即,双BOOT):LOW BOOT和HIGH BOOT;EPLD的寄存器(Register,REG)中存储有启动区标志,该启动区标志用于控制处理器使用所述SPI Flash中的LOW BOOT还是使用HIGH BOOT来引导启动操作系统。其中,所述启动区标志可以从外部存储设备获取,如SPI Flash,也可以在所述EPLD的寄存器中进行初始设置。In order to reduce the hardware cost, in this embodiment, Serial Peripheral Interface Nor Flash (SPI Flash) can be used to store dual boot files (ie, dual BOOT): LOW BOOT and HIGH BOOT; EPLD registers (Register) , REG) stores a boot area flag, which is used to control whether the processor uses the LOW BOOT in the SPI Flash or the HIGH BOOT to boot the operating system. The boot area flag may be obtained from an external storage device, such as SPI Flash, or may be initially set in a register of the EPLD.
处理器和EPLD上电或者复位后,所述处理器从所述EPLD的寄存器中读取当前的启动区标志;然后根据启动区标志,从所述SPI Flash中读取对应的BOOT,并运行该BOOT。所述处理器在运行该BOOT的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入启动正常的标识值。示例的,所述EPLD的寄存器中的标志位初始值为0;所述处理器可以在运行目标BOOT的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入标识值1。After the processor and the EPLD are powered on or reset, the processor reads the current boot area flag from the register of the EPLD; then reads the corresponding BOOT from the SPI Flash according to the boot area flag, and runs the BOOT. The processor writes a normal identification value to a flag bit in a register of the EPLD when an abnormality does not occur in the process of running the BOOT. For example, the initial value of the flag bit in the register of the EPLD is 0; the processor may write the identification value 1 to the flag bit in the register of the EPLD when no abnormality occurs during the running of the target BOOT.
所述EPLD检测获取所述处理器写入所述寄存器中的标志位,并根据所述标志位判断目标BOOT是否启动成功。当所述EPLD检测到所述寄存器中的标志位为标识值1时,表明处理器在运行所述目标BOOT的过程中未出现异常,在所述寄存器中的标志位写入所述目标BOOT启动正常的标识值1,所述EPLD判断目标BOOT启动成功;当所述寄存器中的标志位为标识值0时,表明处理器在运行所述目标BOOT的过程中出现异常,未在所述寄存器中的标志位写入 所述目标BOOT启动正常的标识值1,所述EPLD判断出目标BOOT启动失败。The EPLD detection acquires a flag bit written by the processor into the register, and determines whether the target BOOT is successfully started according to the flag bit. When the EPLD detects that the flag bit in the register is the identification value 1, it indicates that the processor does not generate an abnormality during the running of the target BOOT, and the flag bit in the register is written to the target BOOT to start. The normal identification value is 1, the EPLD determines that the target BOOT is successfully started; when the flag bit in the register is the identification value 0, it indicates that the processor has an abnormality in the process of running the target BOOT, not in the register. Flag bit write The target BOOT starts a normal identification value of 1, and the EPLD determines that the target BOOT fails to start.
在步骤102中,在确定所述目标BOOT启动失败时,将所述寄存器中的双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,并向所述处理器发送复位信号。所述EPLD在确定所述目标BOOT启动失败时,例如,所述标志位的标识值不为1时,则将所述EPLD的寄存器中的双BOOT启动区标志由目标BOOT对应的启动区标志切换为备用BOOT对应的启动区标志,并向所述处理器发送复位信号。In step 102, when it is determined that the target BOOT fails to start, the dual BOOT boot area flag in the register is switched from the target BOOT boot area flag to the standby BOOT boot area flag, and a reset signal is sent to the processor. When the EPLD determines that the target BOOT fails to be started, for example, when the identifier value of the flag bit is not 1, the dual BOOT boot area flag in the register of the EPLD is switched by the boot area flag corresponding to the target BOOT. It is a boot area flag corresponding to the standby BOOT, and sends a reset signal to the processor.
示例的,所述双BOOT启动区标志为0,表示启动所述LOW BOOT;所述双BOOT启动区标志为1,表示启动所述HIGH BOOT。若所述处理器从所述EPLD的寄存器中读取当前的启动区标志为0,则所述处理器从所述SPI Flash中读取的启动区标志为0对应的所述目标BOOT即LOW BOOT,依上述举例,所述目标BOOT对应的启动区标志为0,标识启动目标BOOT:LOW BOOT;所述备用BOOT启动区标志为1,标识启动备用BOOT:HIGH BOOT。For example, the dual BOOT boot zone flag is 0, indicating that the LOW BOOT is started; the dual BOOT boot zone flag is 1, indicating that the HIGH BOOT is started. If the processor reads the current boot area flag from the register of the EPLD to be 0, the target BOOT corresponding to the boot area flag read by the processor from the SPI Flash is 0, that is, LOW BOOT According to the above example, the boot area flag corresponding to the target BOOT is 0, and the boot target BOOT: LOW BOOT is identified; the standby BOOT boot area flag is 1, and the identifier starts the standby BOOT: HIGH BOOT.
当所述EPLD确定所述LOW BOOT启动失败时,所述EPLD将所述寄存器中的启动区标志由所述目标BOOT对应的启动区标志0切换为所述备用BOOT对应的启动区标志1,并向所述处理器发送复位信号。When the EPLD determines that the LOW BOOT fails to start, the EPLD switches the boot area flag in the register from the boot area flag 0 corresponding to the target BOOT to the boot area flag 1 corresponding to the standby BOOT, and A reset signal is sent to the processor.
所述处理器在接收到所述EPLD的寄存器发送的复位信号后,进行复位操作。在进行所述复位操作后,所述处理器从所述EPLD的寄存器中读取切换后的启动区标志即备用BOOT对应的启动区标志1,所述处理器根据所述备用BOOT对应的启动区标志,从所述SPI Flash读取备用BOOT,并运行所述备用BOOT,这样,所述处理器就可以在启动目标BOOT失败时,由所述目标BOOT切换至所述备用BOOT来引导启动操作系统,实现了双BOOT的切换。The processor performs a reset operation after receiving the reset signal sent by the register of the EPLD. After performing the reset operation, the processor reads, from the register of the EPLD, a boot area identifier that is a switch, that is, a boot area flag 1 corresponding to the standby BOOT, and the processor is configured according to the boot area corresponding to the standby BOOT. Marking, reading the standby BOOT from the SPI Flash, and running the standby BOOT, so that the processor can boot from the target BOOT to the standby BOOT to boot the operating system when the startup target BOOT fails. , to achieve the switching of dual BOOT.
本公开实施例还提供了一种双引导文件的切换方法,应用于处理器一侧, 如图2所示,本实施例方法包括步骤201,步骤202,步骤203和步骤204。The embodiment of the present disclosure further provides a method for switching a dual boot file, which is applied to a processor side. As shown in FIG. 2, the method of this embodiment includes step 201, step 202, step 203 and step 204.
在步骤201中,从可擦除可编辑逻辑器件EPLD的寄存器中读取双引导文件BOOT启动区标志。In step 201, the dual boot file BOOT boot region flag is read from the register of the erasable editable logic device EPLD.
为了降低硬件成本,本实施例中采用SPI Flash来存储双BOOT:LOW BOOT和HIGH BOOT;所述EPLD的寄存器中存储有双BOOT启动区标志,该双BOOT启动区标志用于控制处理器使用所述SPI Flash中的LOW BOOT还是使用HIGH BOOT来引导启动操作系统。其中,所述双BOOT启动区标志可以从外部存储设备获取,如SPI Flash,也可以在所述EPLD的寄存器中进行初始设置。In order to reduce the hardware cost, the SPI Flash is used in this embodiment to store dual BOOTs: LOW BOOT and HIGH BOOT; the EPLD register stores a dual BOOT boot area flag, and the dual BOOT boot area flag is used to control the processor usage. The LOW BOOT in SPI Flash still uses HIGH BOOT to boot the operating system. The dual BOOT boot area flag may be obtained from an external storage device, such as SPI Flash, or may be initially set in a register of the EPLD.
处理器和EPLD上电或者复位后,所述处理器从所述EPLD的寄存器中读取当前的双BOOT启动区标志,即目标BOOT启动区标志,来确定启动双BOOT中的LOW BOOT或者HIGH BOOT。After the processor and the EPLD are powered on or reset, the processor reads the current dual BOOT boot area flag, that is, the target BOOT boot area flag, from the register of the EPLD to determine to enable the LOW BOOT or HIGH BOOT in the dual BOOT. .
在步骤202中,从串行外设接口非易失性闪存SPI Flash读取所述双BOOT启动区标志标识的目标BOOT,并运行所述目标BOOT。In step 202, the target BOOT of the dual BOOT boot area flag is read from the serial peripheral interface non-volatile flash SPI Flash, and the target BOOT is run.
所述处理器根据所述双BOOT启动区标志,从所述SPI Flash读取双BOOT启动区标志标识的目标BOOT,并运行所述目标BOOT。其中,所述目标BOOT为LOW BOOT或者HIGH BOOT。The processor reads the target BOOT of the dual BOOT boot zone flag from the SPI Flash according to the dual BOOT boot zone flag, and runs the target BOOT. The target BOOT is LOW BOOT or HIGH BOOT.
示例的,所述双BOOT启动区标志为0,表示启动所述LOW BOOT;所述双BOOT启动区标志为1,表示启动所述HIGH BOOT。若所述处理器从所述EPLD的寄存器中读取当前的双BOOT启动区标志为0,则所述处理器从所述SPI Flash中读取的双BOOT启动区标志为0对应的所述目标BOOT即LOW BOOT,依上述举例,所述目标BOOT启动区标志为0,标识启动目标BOOT:LOW BOOT;所述备用BOOT启动区标志为1,标识启动备用BOOT:HIGH BOOT。 For example, the dual BOOT boot zone flag is 0, indicating that the LOW BOOT is started; the dual BOOT boot zone flag is 1, indicating that the HIGH BOOT is started. If the processor reads the current dual BOOT boot area flag from the register of the EPLD to be 0, the dual BOOT boot area flag read by the processor from the SPI Flash is the target corresponding to 0. BOOT is LOW BOOT. According to the above example, the target BOOT boot zone flag is 0, and the boot target BOOT: LOW BOOT is identified; the standby BOOT boot zone flag is 1, and the logo initiates the standby BOOT: HIGH BOOT.
在步骤203中,在运行所述目标BOOT的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入所述目标BOOT启动正常的标识值。In step 203, when an abnormality does not occur in the process of running the target BOOT, the flag bit in the register of the EPLD is written to the target BOOT to start a normal identification value.
所述处理器在运行所述目标BOOT的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入所述目标BOOT启动正常的标识值。示例的,所述EPLD的寄存器中的标志位初始值为0;所述处理器可以在运行所述目标BOOT的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入标识值1。And when the processor does not generate an abnormality in the process of running the target BOOT, writing, to the flag bit in the register of the EPLD, the target BOOT starts a normal identification value. For example, the flag bit in the register of the EPLD is initially 0; the processor may write the identifier value to the flag bit in the register of the EPLD when no abnormality occurs during the running of the target BOOT. 1.
在步骤204中,在接收到所述EPLD的寄存器发送的复位信号后,进行复位操作。In step 204, after receiving the reset signal transmitted by the register of the EPLD, a reset operation is performed.
所述EPLD检测获取所述处理器写入所述寄存器中的标志位,在检测到所述标志位写入的是所述目标BOOT启动正常的标识值时,判断所述目标BOOT启动成功;在检测到所述标志位写入的不是所述目标BOOT启动正常的标识值时,判断所述目标BOOT启动失败。所述EPLD在确定所述目标BOOT启动失败时,将所述寄存器中的双BOOT启动区标志由目标BOOT启动区标志0切换为备用BOOT启动区标志1,并向所述处理器发送复位信号。The EPLD detection acquires a flag bit written by the processor in the register, and when detecting that the flag bit is written by the target BOOT to start a normal identification value, determining that the target BOOT is successfully started; When it is detected that the flag bit is not written by the target BOOT, the target BOOT is determined to fail to start. When determining that the target BOOT fails to start, the EPLD switches the dual BOOT boot area flag in the register from the target BOOT boot area flag 0 to the standby BOOT boot area flag 1, and sends a reset signal to the processor.
所述处理器在接收到所述EPLD的寄存器发送的复位信号后,进行复位操作。在进行所述复位操作后,所述处理器重新进行步骤201从所述EPLD的寄存器中读取切换后的双BOOT启动区标志即备用BOOT启动区标志1,所述处理器根据所述备用BOOT启动区标志,从所述SPI Flash读取备用BOOT:HIGH BOOT,并运行所述备用BOOT,这样,所述处理器就可以在启动目标BOOT失败时,由所述目标BOOT切换至所述备用BOOT来引导启动操作系统,实现了双BOOT的切换。The processor performs a reset operation after receiving the reset signal sent by the register of the EPLD. After performing the reset operation, the processor performs step 201 to read the switched dual BOOT boot area flag, that is, the standby BOOT boot area flag 1 from the register of the EPLD, according to the standby BOOT. a boot area flag, reading the standby BOOT:HIGH BOOT from the SPI Flash, and running the standby BOOT, so that the processor can switch from the target BOOT to the standby BOOT when the startup target BOOT fails To boot the operating system and achieve dual BOOT switching.
实施例2Example 2
本公开实施例提供了一种双引导文件的切换方法,如图3所示,本实施例 方法包括步骤301-312。The embodiment of the present disclosure provides a method for switching a dual boot file, as shown in FIG. 3, this embodiment The method includes steps 301-312.
在步骤301中,EPLD从SPI Flash中读取双BOOT启动区标志并存入所述寄存器中。In step 301, the EPLD reads the dual BOOT boot area flag from the SPI Flash and stores it in the register.
为了降低硬件成本,本实施例中采用SPI Flash来存储双BOOT:LOW BOOT和HIGH BOOT;可以将所述SPI Flash内部的地址空间划分为:0~a地址空间,a~b地址空间,b~c地址空间,c~d地址空间;其中,所述0~a地址空间用于存放二次加载程序(Second Program Loader,SPL);所述a~b地址空间用于存放LOW BOOT;所述b~c地址空间用于存放HIGH BOOT;所述c~d地址空间用于存放双BOOT启动区标志。所述双BOOT启动区标志用于标识启动HIGH BOOT还是启动LOW BOOT。In order to reduce the hardware cost, the SPI Flash is used in this embodiment to store dual BOOTs: LOW BOOT and HIGH BOOT; the address space inside the SPI Flash can be divided into: 0 to a address space, a to b address space, b~ c address space, c ~ d address space; wherein the 0 ~ a address space is used to store a secondary loader (SPL); the a ~ b address space for storing LOW BOOT; the b The ~c address space is used to store the HIGH BOOT; the c~d address space is used to store the dual BOOT boot area flag. The dual BOOT boot area flag is used to identify whether to activate HIGH BOOT or start LOW BOOT.
所述SPL用于引导所述LOW BOOT或所述HIGH BOOT运行;所述LOW BOOT和所述HIGH BOOT的内容相同;所述双BOOT启动区标志可以用一个字节表示,若该字节中的最高比特位为0,表示启动所述LOW BOOT;若该字节中的最高比特位为1,表示启动所述HIGH BOOT。The SPL is used to boot the LOW BOOT or the HIGH BOOT; the contents of the LOW BOOT and the HIGH BOOT are the same; the dual BOOT boot area flag can be represented by one byte, if the byte The highest bit is 0, indicating that the LOW BOOT is enabled; if the highest bit in the byte is 1, it indicates that the HIGH BOOT is started.
这里,用户可以根据用户的需求在所述SPL中对处理器的某些基础配置进行设置,与相关技术中将这些基础配置固化在BOOT中相比,在所述SPL中根据用户需求进行设置具有更好的灵活性、更小的存储空间等优点。Here, the user may set some basic configurations of the processor in the SPL according to the needs of the user, and set the basic configuration in the SPL according to the user requirements in the SPL. Better flexibility, smaller storage space and more.
在本实施例中,EPLD上电后,可以从SPI Flash的c~d地址空间中读取双BOOT启动区标志并存入所述EPLD的寄存器中。In this embodiment, after the EPLD is powered on, the dual BOOT boot area flag can be read from the c-d address space of the SPI Flash and stored in the register of the EPLD.
可选的,如图4所示,所述EPLD可以通过双BOOT控制器的串行外设接口(Serial Peripheral Interface,SPI)读时序读取SPI Flash中的双BOOT启动区标志并将所述双BOOT启动区标志存入EPLD的寄存器中。Optionally, as shown in FIG. 4, the EPLD can read the dual BOOT boot zone flag in the SPI Flash through the serial peripheral interface (SPI) read timing of the dual BOOT controller and the dual The BOOT boot area flag is stored in the EPLD register.
在步骤302中,处理器从所述SPI Flash中读取SPL,在开始运行所述SPL 时,向所述EPLD的寄存器中写入定时器触发标志。In step 302, the processor reads the SPL from the SPI Flash and starts running the SPL. At this time, a timer trigger flag is written to the register of the EPLD.
处理器上电或者复位后,所述处理器从所述SPI Flash的0~a地址空间中读取SPL,并将读取的SPL存入所述处理器的内存中,所述处理器在读取完成所述SPL后,开始运行所述SPL。所述处理器在开始运行所述SPL时,向所述EPLD的寄存器写入定时器触发标志。After the processor is powered on or reset, the processor reads the SPL from the 0-a address space of the SPI Flash, and stores the read SPL in the memory of the processor, the processor is reading After the SPL is completed, the SPL is started to run. The processor writes a timer trigger flag to a register of the EPLD when the SPL is started to run.
如图4所示,所述处理器具有一通用输入/输出(General Purpose Input Output,GPIO)接口,所述GPIO接口可以作为片选端,所述片选端中的片选信号可以控制所述EPLD中的多路复用器(Multiplexer,MUX)选择访问所述EPLD的寄存器REG或者选择访问所述SPI Flash。As shown in FIG. 4, the processor has a general purpose input/output (GPIO) interface, and the GPIO interface can serve as a chip select terminal, and a chip select signal in the chip select terminal can control the EPLD. The multiplexer (MUX) in the multiplex chooses to access the register REG of the EPLD or to access the SPI Flash.
这里,所述片选信号可以通过软件方式进行设置,当然,也可以通过其他方式进行设置,本实施例中不做具体限定。Here, the chip selection signal may be set by software, and may be set by other methods, which is not specifically limited in this embodiment.
除此以外,所述处理器还具有同步队列串行外设接口(Queued SPI,QSPI),当所述处理器选择访问所述EPLD的寄存器时,可以通过所述QSPI对所述EPLD的寄存器进行读写操作。In addition, the processor further has a synchronous queue serial peripheral interface (Queued SPI, QSPI), and when the processor selects to access the register of the EPLD, the register of the EPLD can be performed by the QSPI. Read and write operations.
示例的,当所述处理器需要访问所述EPLD的寄存器时,所述处理器可以将所述GPIO接口中的片选信号置为1,控制所述EPLD中的MUX选择访问所述EPLD的寄存器,再通过所述QSPI对所述EPLD的寄存器进行读写操作;当所述处理器需要访问所述SPI Flash时,所述处理器可以将所述GPIO接口中的片选信号置为0,控制所述EPLD中的MUX选择访问所述SPI Flash,再通过所述QSPI读取所述SPI Flash中的内容。For example, when the processor needs to access a register of the EPLD, the processor may set a chip select signal in the GPIO interface to 1, and control a MUX in the EPLD to select a register to access the EPLD. And reading and writing the register of the EPLD by using the QSPI; when the processor needs to access the SPI Flash, the processor may set the chip select signal in the GPIO interface to 0, and control The MUX in the EPLD selects to access the SPI Flash, and then reads the content in the SPI Flash through the QSPI.
本实施例方法中,所述处理器可通过上述方法来对所述EPLD的寄存器进行读写操作,以及读取所述SPI Flash中的内容。In the method of this embodiment, the processor may perform a read/write operation on the register of the EPLD and read the content in the SPI Flash by using the foregoing method.
可选的,在本实施例中所述处理器可以是ARM(Advanced RISC Machines) 处理器。Optionally, in the embodiment, the processor may be an ARM (Advanced RISC Machines). processor.
在步骤303中,所述EPLD检测到所述处理器写入所述寄存器中的定时器触发标志时,启动所述寄存器中的快速翻转定时器和慢速翻转定时器开始计时。In step 303, when the EPLD detects that the processor writes a timer trigger flag in the register, the fast flip timer and the slow flip timer in the register are started to start timing.
所述EPLD检测到所述处理器写入所述寄存器中的定时器触发标志时,启动所述EPLD的寄存器中的快速翻转定时器和慢速翻转定时器开始计时。其中,所述快速翻转定时器和慢速翻转定时器需要预先设定定时时长,所述快速翻转定时器的定时时长在十秒以内,而所述慢速翻转定时器的定时时长较长,这里,所述快速翻转定时器的定时时长为第一预设时间,所述慢速翻转定时器的定时时长为第二预设时间,并且所述第一预设时间小于所述第二预设时间,示例的,所述第一预设时间可以为5秒,所述第二预设时间可以为60秒。When the EPLD detects that the processor writes a timer trigger flag in the register, the fast flip timer and the slow flip timer in the register of the EPLD are started to start timing. The fast rollover timer and the slow rollover timer need to be preset with a preset duration. The timing of the fast rollover timer is less than ten seconds, and the timing of the slow rollover timer is longer. The timing of the fast rollover timer is a first preset time, the time duration of the slow rollover timer is a second preset time, and the first preset time is less than the second preset time. For example, the first preset time may be 5 seconds, and the second preset time may be 60 seconds.
在步骤304中,所述处理器在运行所述SPL的末尾阶段,从所述EPLD的寄存器中读取所述双BOOT启动区标志。In step 304, the processor reads the dual BOOT boot area flag from a register of the EPLD at the end of running the SPL.
所述处理器在运行所述SPL的末尾阶段,通过所述GPIO接口中的片选信号控制MUX选择访问所述EPLD,经所述QSPI从所述EPLD的寄存器中读取当前的双BOOT启动区标志,即目标BOOT启动区标志;并将所述目标BOOT启动区标志存入所述处理器的内存中,根据所述目标BOOT启动区标志来决定使用LOW BOOT还是HIGH BOOT来引导启动操作系统。The processor controls the MUX to select to access the EPLD through a chip select signal in the GPIO interface, and reads the current dual BOOT boot area from the register of the EPLD via the QSPI at the end stage of running the SPL. The flag, that is, the target BOOT boot area flag; and the target BOOT boot area flag is stored in the memory of the processor, and the LOW BOOT or the HIGH BOOT is used to boot the operating system according to the target BOOT boot area flag.
在步骤305中,所述处理器从所述SPI Flash读取所述双BOOT启动区标志标识的目标BOOT,并运行所述目标BOOT。In step 305, the processor reads the target BOOT of the dual BOOT boot area flag identifier from the SPI Flash, and runs the target BOOT.
所述处理器在读取所述双BOOT启动区标志后,通过所述GPIO接口中的片选信号控制MUX选择访问所述SPI Flash;然后根据所述双BOOT启动区标志,即目标BOOT启动区标志,经所述QSPI从所述SPI Flash中读取目标BOOT,将所述目标BOOT存入所述处理器的内存中,并运行所述目标BOOT。 After reading the dual BOOT boot area flag, the processor controls the MUX to select to access the SPI Flash through a chip select signal in the GPIO interface; and then according to the dual BOOT boot area flag, that is, the target BOOT boot area. The flag reads the target BOOT from the SPI Flash via the QSPI, stores the target BOOT in the memory of the processor, and runs the target BOOT.
示例的,当所述双BOOT启动区标志为0时,所述处理器从所述SPI Flash的a~b地址空间读取双BOOT启动区标志为0标识的LOW BOOT,所述LOW BOOT即为目标BOOT,而b~c地址空间的HIGH BOOT为备用BOOT;当所述双BOOT启动区标志为1时,所述处理器从所述SPI Flash的b~c地址空间读取双BOOT启动区标志为1标识的HIGH BOOT,所述HIGH BOOT即为目标BOOT,而a~b地址空间的LOW BOOT为备用BOOT。For example, when the dual BOOT boot area flag is 0, the processor reads a LOW BOOT whose dual BOOT boot area flag is 0 from the a to b address space of the SPI Flash, and the LOW BOOT is The target BOOT, and the HIGH BOOT of the b~c address space is the standby BOOT; when the dual BOOT boot area flag is 1, the processor reads the dual BOOT boot area flag from the b~c address space of the SPI Flash. For the HIGH BOOT identified by 1, the HIGH BOOT is the target BOOT, and the LOW BOOT of the a~b address space is the standby BOOT.
在步骤306中,所述处理器在运行所述目标BOOT时,根据所述目标BOOT中提供的第一握手信息,向所述EPLD的寄存器中的第一标志位写入有用值。In step 306, when the processor runs the target BOOT, the processor writes a useful value to the first flag bit in the register of the EPLD according to the first handshake information provided in the target BOOT.
所述处理器的内存中存储有所述目标BOOT,所述目标BOOT中提供有与所述EPLD交互的第一握手信息。这里,与所述EPLD交互的第一握手信息可由所述目标BOOT最开始运行的代码board_init_r(Board.c文件)提供。The target BOOT is stored in the memory of the processor, and the target BOOT is provided with first handshake information that interacts with the EPLD. Here, the first handshake information that interacts with the EPLD may be provided by the code board_init_r (Board.c file) that the target BOOT initially runs.
所述处理器在运行所述目标BOOT时,根据所述目标BOOT中提供的第一握手信息,通过所述GPIO接口中的片选信号控制MUX选择访问所述EPLD,经所述QSPI向所述EPLD的寄存器中的第一标志位写入有用值,示例的,所述EPLD的寄存器中的第一标志位为BDBCR_REG[REV_F];所述处理器在运行所述目标BOOT时,根据所述目标BOOT中提供的第一握手信息,向所述EPLD的寄存器中的第一标志位BDBCR_REG[REV_F]写入所述有用值1;所述EPLD获取所述标志位BDBCR_REG[REV_F],检测所述标志位BDBCR_REG[REV_F]的标识值是否为1;当所述标志位BDBCR_REG[REV_F]的标识值为1时,表明所述处理器已经可以正确加载所述目标BOOT。When the processor runs the target BOOT, according to the first handshake information provided in the target BOOT, the MUX selects to access the EPLD through a chip select signal in the GPIO interface, and the QSPI is used to The first flag bit in the register of the EPLD is written with a useful value. For example, the first flag bit in the register of the EPLD is BDBCR_REG[REV_F]; when the processor runs the target BOOT, according to the target The first handshake information provided in the BOOT writes the useful value 1 to the first flag bit BDBCR_REG[REV_F] in the register of the EPLD; the EPLD acquires the flag bit BDBCR_REG[REV_F], and detects the flag Whether the identifier value of the bit BDBCR_REG[REV_F] is 1; when the identifier value of the flag bit BDBCR_REG[REV_F] is 1, it indicates that the processor can correctly load the target BOOT.
在这里需要说明的是,所述处理器从开始运行所述SPL到运行所述目标BOOT时,所述EPLD的寄存器中的所述快速翻转定时器还没有达到所述第一预设时间5秒,同样,所述快速翻转定时器仍在继续计时,也没有达到所述第 二预设时间60秒;所述快速翻转定时器在达到所述第一预设时间之前,不允许所述EPLD将所述寄存器中的双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,即不允许所述EPLD对双BOOT启动区标志的最高比特位进行取反操作。It should be noted that, when the processor starts running the SPL to run the target BOOT, the fast flip timer in the register of the EPLD has not reached the first preset time of 5 seconds. Similarly, the fast flip timer continues to count and does not reach the first The preset time is 60 seconds; the fast flip timer does not allow the EPLD to switch the dual BOOT boot zone flag in the register from the target BOOT boot zone flag to the standby BOOT before the first preset time is reached. The boot area flag, that is, the EPLD is not allowed to reverse the highest bit of the dual BOOT boot area flag.
所述处理器向所述EPLD的寄存器中的第一标志位写入有用值后,自动将所述GPIO接口的片选信号设置为0。After the processor writes a useful value to the first flag bit in the register of the EPLD, the chip select signal of the GPIO interface is automatically set to zero.
在步骤307中,当所述快速翻转定时器达到所述第一预设时间时,所述EPLD检测获取所述处理器写入所述寄存器中的所述第一标志位。In step 307, when the fast flip timer reaches the first preset time, the EPLD detects that the processor writes the first flag bit in the register.
当所述EPLD的寄存器中的所述快速翻转定时器达到所述第一预设时间5秒时,所述EPLD检测获取所述处理器写入所述寄存器中的所述第一标志位是否被成功写入有用值1。When the fast flip timer in the register of the EPLD reaches the first preset time of 5 seconds, the EPLD detects whether the first flag bit written by the processor in the register is acquired. A useful value of 1 was successfully written.
在步骤3081中,所述EPLD在所述第一标志位不是有用值时,将所述寄存器中的所述双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,并向所述处理器发送复位信号。In step 3081, the EPLD switches the dual BOOT boot zone flag in the register from the target BOOT boot zone flag to the standby BOOT boot zone flag when the first flag bit is not a useful value, and The processor sends a reset signal.
当所述第一标志位不是有用值时,表明所述处理器没有获得所述目标BOOT中提供的第一握手信息,未向所述EPLD的寄存器中的第一标志位写入有用值1,所述EPLD可以判断出所述处理器没有正确加载所述目标BOOT,所述目标BOOT不可用,这时,所述EPLD判断出所述处理器启动所述目标BOOT失败。When the first flag is not a useful value, indicating that the processor does not obtain the first handshake information provided in the target BOOT, and does not write a useful value of 1 to the first flag in the register of the EPLD, The EPLD may determine that the target BOOT is not properly loaded by the processor, and the target BOOT is unavailable. At this time, the EPLD determines that the processor fails to start the target BOOT.
所述EPLD在确定所述目标BOOT启动失败时,会将所述EPLD的寄存器中的所述双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,并向所述处理器发送复位信号,处理器执行步骤312。The EPLD, when determining that the target BOOT fails to start, switches the dual BOOT boot area flag in the register of the EPLD from the target BOOT boot area flag to the standby BOOT boot area flag, and sends the flag to the processor. The reset signal, the processor performs step 312.
这里,所述EPLD将所述寄存器中的所述双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,包括:所述EPLD将所述寄存器中 的所述双BOOT启动区标志的最高比特位取反。即所述备用BOOT启动区标志为所述目标BOOT启动区标志的最高比特位取反后的双BOOT启动区标志。Here, the EPLD switches the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag, including: the EPLD will be in the register The highest bit of the dual BOOT boot area flag is inverted. That is, the standby BOOT boot area flag is a dual BOOT boot area flag after the highest bit of the target BOOT boot area flag is inverted.
示例的,若双BOOT启动区标志的最高比特为0,则LOW BOOT即为目标BOOT,当所述LOW BOOT启动失败时,所述EPLD将其寄存器中的所述双BOOT启动区标志的最高比特位由0取反变为1,并向所述处理器发送复位信号,所述处理器复位后重新从所述EPLD将其寄存器中读取到所述双BOOT启动区标志为的最高比特位为1,就会按照该双BOOT启动区标志启动HIGH BOOT,即备用BOOT,实现了由所述LOW BOOT到所述HIGH BOOT的切换。For example, if the highest bit of the dual BOOT boot area flag is 0, the LOW BOOT is the target BOOT, and when the LOW BOOT fails to start, the EPLD sets the highest bit of the dual BOOT boot area flag in its register. The bit is inverted from 0 to 1, and a reset signal is sent to the processor, and after the processor resets, the highest bit of the dual BOOT boot area flag is read from the EPLD and read from its register. 1, the HIGH BOOT, that is, the standby BOOT, is started according to the dual BOOT boot area flag, and the switching from the LOW BOOT to the HIGH BOOT is realized.
在步骤3082中,所述处理器在向所述EPLD的寄存器中的第一标志位写入有用值后,在运行到加载所述目标BOOT的运行版本之前,根据所述目标BOOT中提供的第二握手信息,向所述EPLD的寄存器中的第二标志位写入有效值。In step 3082, after the processor writes a useful value to the first flag bit in the register of the EPLD, before running to load the running version of the target BOOT, according to the number provided in the target BOOT The second handshake information writes a valid value to the second flag bit in the register of the EPLD.
当所述EPLD的寄存器中的所述第一标志位被置为有用值1时,表明所述处理器获得所述目标BOOT中提供的第一握手信息,向所述EPLD的寄存器中的第一标志位写入有用值1,所述EPLD可以判断出所述处理器已经正确加载所述目标BOOT。这时,所述EPLD并不进行双BOOT启动区标志的切换,也不会给处理器发送复位信号,所述处理器继续运行所述目标BOOT。When the first flag bit in the register of the EPLD is set to a useful value of 1, indicating that the processor obtains the first handshake information provided in the target BOOT, to the first of the registers of the EPLD The flag bit is written to a useful value of 1, and the EPLD can determine that the target BOOT has been properly loaded by the processor. At this time, the EPLD does not perform the switching of the dual BOOT boot area flag, nor does it send a reset signal to the processor, and the processor continues to run the target BOOT.
在所述目标BOOT运行到加载运行版本之前,所述处理器根据所述目标BOOT中提供的与所述EPLD交互的第二握手信息,通过所述GPIO接口中的片选信号控制MUX选择访问所述EPLD的寄存器,向所述EPLD的寄存器的第二标志位写入有效值,示例的,所述有效值可以为1,该有效值用于表明所述处理器已经完成所述目标BOOT的最初引导,准备加载所述目标BOOT的运行版本。Before the target BOOT runs to load the running version, the processor controls the MUX selection access by using a chip select signal in the GPIO interface according to the second handshake information provided in the target BOOT to interact with the EPLD. The register of the EPLD writes a valid value to the second flag of the register of the EPLD. For example, the valid value may be 1, and the valid value is used to indicate that the processor has completed the initial execution of the target BOOT. Boot, ready to load the running version of the target BOOT.
在这里需要说明的是,所述处理器从开始运行所述SPL到加载所述目标 BOOT的运行版本之前,所述EPLD的寄存器中的所述慢速翻转定时器还没有达到所述第二预设时间60秒;所述慢速翻转定时器在达到所述第二预设时间之前,不允许所述EPLD将所述寄存器中的双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,即不允许所述EPLD对双BOOT启动区标志的最高比特位进行取反操作。It should be noted here that the processor starts from running the SPL to load the target. Before the running version of the BOOT, the slow rollover timer in the register of the EPLD has not reached the second preset time of 60 seconds; the slow rollover timer before reaching the second preset time The EPLD is not allowed to switch the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag, that is, the EPLD is not allowed to invert the highest bit of the dual BOOT boot area flag. operating.
所述处理器向所述EPLD的寄存器的第二标志位写入有效值后,自动将所述GPIO接口的片选信号设置为0。After the processor writes a valid value to the second flag of the EPLD register, the chip select signal of the GPIO interface is automatically set to zero.
在步骤309中,所述EPLD在所述第一标志位是有用值,且所述慢速翻转定时器达到所述第二预设时间时,检测获取所述处理器写入所述寄存器中的第二标志位。In step 309, the EPLD is a useful value when the first flag bit, and when the slow rollover timer reaches the second preset time, detecting that the processor is written into the register The second flag.
在所述EPLD的寄存器中的所述第一标志位是有用值,且所述慢速翻转定时器达到所述第二预设时间60秒时,所述EPLD检测获取所述处理器写入所述寄存器中的所述第二标志位是否被成功写入有效值。The first flag bit in the register of the EPLD is a useful value, and when the slow rollover timer reaches the second preset time of 60 seconds, the EPLD detection acquires the processor write location Whether the second flag bit in the register is successfully written to a valid value.
在步骤3101中,所述EPLD在所述第二标志位不是有效值时,将所述寄存器中的双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,并向处理器发送复位信号。In step 3101, when the second flag bit is not a valid value, the EPLD switches the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag, and sends the flag to the processor. Reset signal.
当所述第二标志位不是有效值时,表明所述处理器没有获得所述目标BOOT中提供的第二握手信息,未向所述EPLD的寄存器中的第二标志位写入有用值1,所述EPLD可以判断出所述处理器没有对所述目标BOOT初始化不正确,所述处理器未完成所述目标BOOT的最初引导,这时,所述EPLD判断出所述处理器启动所述目标BOOT失败。When the second flag is not a valid value, indicating that the processor does not obtain the second handshake information provided in the target BOOT, and does not write a useful value of 1 to the second flag in the register of the EPLD, The EPLD may determine that the processor does not initialize the target BOOT incorrectly, and the processor does not complete initial booting of the target BOOT. At this time, the EPLD determines that the processor starts the target. BOOT failed.
在确定所述目标BOOT启动失败时,所述EPLD将所述EPLD的寄存器中的所述双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区 标志,并向所述处理器发送复位信号,处理器执行步骤312。When it is determined that the target BOOT fails to be started, the EPLD switches the dual BOOT boot zone flag in the register of the EPLD from the target BOOT boot zone flag to the standby BOOT boot zone. The flag is sent to the processor and the processor executes step 312.
这里,所述EPLD将所述寄存器中的所述双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,包括:述EPLD将所述寄存器中的所述双BOOT启动区标志的最高比特位取反。即所述备用BOOT启动区标志为所述目标BOOT启动区标志的最高比特位取反后的双BOOT启动区标志。Here, the EPLD switches the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag, including: the EPLD will mark the dual BOOT boot area in the register. The highest bit is inverted. That is, the standby BOOT boot area flag is a dual BOOT boot area flag after the highest bit of the target BOOT boot area flag is inverted.
示例的,若双BOOT启动区标志的最高比特为0,则LOW BOOT即为目标BOOT,当所述LOW BOOT启动失败时,所述EPLD将其寄存器中的所述双BOOT启动区标志的最高比特位由0取反变为1,并向所述处理器发送复位信号。For example, if the highest bit of the dual BOOT boot area flag is 0, the LOW BOOT is the target BOOT, and when the LOW BOOT fails to start, the EPLD sets the highest bit of the dual BOOT boot area flag in its register. The bit is inverted from 0 to 1, and a reset signal is sent to the processor.
在步骤3102中,所述处理器在向所述EPLD的寄存器中的所述第二标志位写入有效值后,加载所述目标BOOT的运行版本。In step 3102, the processor loads the running version of the target BOOT after writing a valid value to the second flag bit in the register of the EPLD.
当所述EPLD的寄存器中的所述第二标志位被置为有效值1时,表明所述处理器获得所述目标BOOT中提供的第二握手信息,向所述EPLD的寄存器中的第二标志位写入有效值1,所述EPLD可以判断出所述处理器已经完成所述目标BOOT的最初引导,准备加载所述目标BOOT的运行版本。所述处理器从存放所述目标BOOT的运行版本的存储设备上加载所述目标BOOT的运行版本。这里,所述存放所述目标BOOT的运行版本的存储设备为闪存或其他存储器。When the second flag bit in the register of the EPLD is set to a valid value of 1, indicating that the processor obtains the second handshake information provided in the target BOOT, and the second in the register of the EPLD The flag bit is written to a valid value of 1, and the EPLD can determine that the processor has completed the initial boot of the target BOOT and prepare to load the running version of the target BOOT. The processor loads an running version of the target BOOT from a storage device that stores an running version of the target BOOT. Here, the storage device storing the running version of the target BOOT is a flash memory or other storage.
在步骤311中,所述处理器在开始运行所述目标BOOT的运行版本时,启动看门狗操作。In step 311, the processor starts a watchdog operation when it starts running the running version of the target BOOT.
所述处理器在所述目标BOOT开始运行所述运行版本时,启动看门狗操作,所述看门狗(watchdog timer)中的定时器开始计时。The processor starts a watchdog operation when the target BOOT starts running the running version, and a timer in the watchdog timer starts timing.
所述处理器在运行所述目标BOOT的运行版本的过程中,周期性的释放喂狗信号(kicking the dog)给所述看门狗;所述看门狗接收到所述喂狗信号后,将所述定时器清零,所述定时器不会溢出预设定时时长,就不能产生复位信号, 表明所述处理器可以正常运行所述目标BOOT的运行版本;若所述处理器在运行所述目标BOOT的运行版本的过程中出现异常时,所述看门狗不能在所述预设定时时长内接收到所述喂狗信号,所述定时器不能清零,所述定时器溢出,这时,所述看门狗就会向所述EPLD和所述处理器发送复位信号,所述EPLD接收所述看门狗发送的复位信号后,本实施例方法重新从步骤301开始执行。The processor periodically releases the dog to the watchdog during the running of the running version of the target BOOT; after the watchdog receives the dog feeding signal, Clearing the timer, the timer does not overflow the preset timing, and the reset signal cannot be generated. Indicates that the processor can normally run the running version of the target BOOT; if the processor is abnormal during the running of the running version of the target BOOT, the watchdog cannot be at the preset timing Receiving the dog feed signal, the timer cannot be cleared, and the timer overflows. At this time, the watchdog sends a reset signal to the EPLD and the processor, and the EPLD receives After the reset signal sent by the watchdog, the method of this embodiment starts from step 301 again.
在步骤312中,所述处理器在接收到所述EPLD的寄存器发送的复位信号后,进行复位操作。In step 312, the processor performs a reset operation after receiving the reset signal sent by the register of the EPLD.
所述处理器在接收到所述EPLD的寄存器发送的复位信号后,表明所述处理器启动所述目标BOOT失败,所述处理器进行复位操作,本实施例方法重新从步骤302开始执行。After receiving the reset signal sent by the register of the EPLD, the processor indicates that the processor fails to start the target BOOT, and the processor performs a reset operation, and the method in this embodiment starts from step 302 again.
在所述处理器进行复位操作,返回执行步骤302后,所述处理器从所述EPLD的寄存器中读取切换后的双BOOT启动区标志即备用BOOT启动区标志,所述处理器根据所述备用BOOT启动区标志,从所述SPI Flash读取备用BOOT,并运行所述备用BOOT,从而所述处理器由所述目标BOOT切换至所述备用BOOT来引导启动操作系统,实现了利用单片SPI Flash进行双BOOT的切换。After the processor performs a reset operation and returns to step 302, the processor reads the switched dual BOOT boot area flag, that is, the standby BOOT boot area flag, from the register of the EPLD, the processor according to the The standby BOOT boot area flag reads the standby BOOT from the SPI Flash, and runs the standby BOOT, so that the processor is switched from the target BOOT to the standby BOOT to boot the operating system, thereby realizing the use of the single piece. SPI Flash performs dual BOOT switching.
在本实施例中,双BOOT在线升级可以通过两种方式,一种为通过LPC(Low Pin Count)电缆连接PC来下载新的BOOT,该升级方法用于第一次下载BOOT;另一种为通过处理器升级运行版本,而运行版本的升级只能是非目标BOOT运行的运行版本。In this embodiment, the dual BOOT online upgrade can be performed in two ways, one is to connect a PC through an LPC (Low Pin Count) cable to download a new BOOT, the upgrade method is used to download the BOOT for the first time; the other is The running version is upgraded by the processor, and the upgrade of the running version can only be the running version of the non-target BOOT running.
为了降低硬件成本,采用单片SPI Flash作为存储设备,然而,所述SPI Flash采用串行外设接口访问,只有一根地址线,EPLD无法通过控制高低地址线进行地址映射来实现两个BOOT的切换。本实施例方法中,将单片SPI Flash按照不同的地址空间划分出不同区域分别存储SPL、LOW BOOT、HIGH BOOT和双 BOOT启动区标志,所述处理器在运行所述目标BOOT的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入所述目标BOOT启动正常的标识值;所述EPLD通过检测获取所述处理器写入寄存器中的标志位来确定是否切换所述寄存器中的双BOOT启动区标志;而所述处理器根据所述EPLD中的双BOOT启动区标志来选择启动BOOT;这样,所述处理器就利用EPLD的寄存器中的双BOOT启动区标志,实现了切换使用单片SPI Flash中存储的双BOOT,降低了硬件成本。In order to reduce the hardware cost, a single SPI Flash is used as the storage device. However, the SPI Flash is accessed by a serial peripheral interface. There is only one address line. The EPLD cannot implement address mapping by controlling the high and low address lines to implement two BOOTs. Switch. In the method of the embodiment, the single-chip SPI Flash is divided into different areas according to different address spaces to store SPL, LOW BOOT, HIGH BOOT and double. a BOOT boot area flag, when the processor does not generate an abnormality in the process of running the target BOOT, writing a flag value of the target BOOT to the flag in the register of the EPLD to start a normal identification value; the EPLD passes the detection Obtaining a flag bit in the processor write register to determine whether to switch a dual BOOT boot area flag in the register; and the processor selects to activate a BOOT according to the dual BOOT boot area flag in the EPLD; thus, The processor utilizes the dual BOOT boot area flag in the EPLD register to implement switching between dual BOOTs stored in a single SPI Flash, thereby reducing hardware costs.
实施例3Example 3
本公开实施例还提供一种EPLD,如图5所示,所述EPLD包括:检测判断单元501,切换单元502和发送单元503。The embodiment of the present disclosure further provides an EPLD. As shown in FIG. 5, the EPLD includes: a detection determining unit 501, a switching unit 502, and a sending unit 503.
检测判断单元501设置为检测获取处理器写入寄存器中的标志位,并根据所述标志位判断目标BOOT是否启动成功;The detection determining unit 501 is configured to detect a flag bit in the write register of the acquisition processor, and determine, according to the flag bit, whether the target BOOT is successfully started;
切换单元502设置为在所述检测判断单元501确定所述目标BOOT启动失败时,将所述寄存器中的双BOOT启动区标志由目标BOOT启动区标志切换为备用BOOT启动区标志,The switching unit 502 is configured to, when the detection determining unit 501 determines that the target BOOT fails to start, switch the dual BOOT boot area flag in the register from the target BOOT boot area flag to the standby BOOT boot area flag.
发送单元503设置为在所述检测判断单元501确定所述目标BOOT启动失败时向所述处理器发送复位信号。The transmitting unit 503 is configured to transmit a reset signal to the processor when the detection determining unit 501 determines that the target BOOT fails to start.
可选的,如图5所示,所述EPLD还包括定时启动单元504。Optionally, as shown in FIG. 5, the EPLD further includes a timing starting unit 504.
定时启动单元504设置为在检测到所述处理器写入所述寄存器中的定时器触发标志时,启动所述寄存器中的快速翻转定时器和慢速翻转定时器开始计时,其中,所述快速翻转定时器的定时时长为第一预设时间,所述慢速翻转定时器的定时时长为第二预设时间,所述第一预设时间小于所述第二预设时间。The timing initiation unit 504 is configured to initiate a fast rollover timer and a slow rollover timer in the register to start timing when detecting that the processor writes a timer trigger flag in the register, wherein the fast The timing of the rollover timer is a first preset time, and the time duration of the slow rollover timer is a second preset time, and the first preset time is less than the second preset time.
所述检测判断单元501,具体设置为当所述定时启动单元504启动所述快速 翻转定时器达到所述第一预设时间时,检测获取所述处理器写入所述寄存器中的第一标志位;在所述第一标志位不是有用值时,确定目标BOOT启动失败;在所述第一标志位是有用值,且所述定时启动单元504启动所述慢速翻转定时器达到所述第二预设时间时,检测获取所述处理器写入所述寄存器中的第二标志位;在所述第二标志位不是有效值时,确定目标BOOT启动失败。The detection determining unit 501 is specifically configured to start the fast when the timing starting unit 504 starts When the rollover timer reaches the first preset time, detecting that the processor writes the first flag bit in the register; when the first flag bit is not a useful value, determining that the target BOOT fails to start; The first flag is a useful value, and when the timing initiation unit 504 starts the slow rollover timer to reach the second preset time, detecting that the processor writes the second in the register Flag bit; when the second flag bit is not a valid value, it is determined that the target BOOT fails to start.
可选的,所述EPLD还包括第一读取单元505。Optionally, the EPLD further includes a first reading unit 505.
所述第一读取单元505,用于从串行外设接口非易失性闪存SPI Flash中读取双引导文件BOOT启动区标志并存入所述寄存器中。The first reading unit 505 is configured to read a dual boot file BOOT boot area flag from the serial peripheral interface non-volatile flash SPI Flash and store the same in the register.
本公开实施例还提供一种处理器,如图6所示,所述处理器包括:第二读取单元601,运行单元602,写入单元603,接收单元604和复位单元605。The embodiment of the present disclosure further provides a processor. As shown in FIG. 6, the processor includes: a second reading unit 601, an operating unit 602, a writing unit 603, a receiving unit 604, and a reset unit 605.
第二读取单元601,设置为从可擦除可编辑逻辑器件EPLD的寄存器中读取双引导文件BOOT启动区标志;根据所述双BOOT启动区标志,从串行外设接口闪存SPI Flash读取目标BOOT。The second reading unit 601 is configured to read the dual boot file BOOT boot area flag from the register of the erasable editable logic device EPLD; read from the serial peripheral interface flash SPI Flash according to the dual BOOT boot area flag Take the target BOOT.
运行单元602,设置为运行所述第二读取单元601读取到的所述目标BOOT。The running unit 602 is configured to run the target BOOT read by the second reading unit 601.
写入单元603,设置为在所述运行单元602运行所述目标BOOT的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入所述目标BOOT启动正常的标识值。The writing unit 603 is configured to write to the flag bit in the register of the EPLD to write the flag value of the target BOOT to start normal when an abnormality does not occur in the process of the operation unit 602 running the target BOOT.
接收单元604,设置为接收所述EPLD的寄存器发送的复位信号。The receiving unit 604 is configured to receive a reset signal sent by a register of the EPLD.
复位单元605,设置为在所述接收单元604接收到所述复位信号后,进行复位操作。The reset unit 605 is configured to perform a reset operation after the receiving unit 604 receives the reset signal.
可选的,所述第二读取单元601,还设置为从所述SPI Flash中读取二次加载程序SPL。Optionally, the second reading unit 601 is further configured to read the secondary loader SPL from the SPI Flash.
所述运行单元602,还设置为运行所述第二读取单元601读取到的所述SPL。 The running unit 602 is further configured to run the SPL read by the second reading unit 601.
所述写入单元603,还设置为在所述运行单元602开始运行所述SPL时,向所述EPLD的寄存器中写入定时器触发标志。The writing unit 603 is further configured to write a timer trigger flag to the register of the EPLD when the operating unit 602 starts to run the SPL.
所述写入单元603,具体设置为在所述运行单元602运行所述目标BOOT时,根据所述目标BOOT中提供的第一握手信息,向所述EPLD的寄存器中的第一标志位写入有用值;在向所述EPLD的寄存器中的第一标志位写入有用值后,在所述运行单元602运行到加载所述目标BOOT的运行版本之前,根据所述目标BOOT中提供的第二握手信息,向所述EPLD的寄存器中的第二标志位写入有效值。The writing unit 603 is specifically configured to, when the running unit 602 runs the target BOOT, write to the first flag bit in the register of the EPLD according to the first handshake information provided in the target BOOT. a useful value; after writing the useful value to the first flag bit in the register of the EPLD, before the running unit 602 runs to load the running version of the target BOOT, according to the second provided in the target BOOT The handshake information writes a valid value to the second flag bit in the register of the EPLD.
可选的,所述第二读取单元601,具体设置为在所述运行单元602运行到所述SPL的末尾阶段,从所述EPLD的寄存器中读取双BOOT启动区标志。Optionally, the second reading unit 601 is specifically configured to read the dual BOOT boot area flag from the register of the EPLD when the running unit 602 runs to the end of the SPL.
可选的,所述处理器还包括启动单元606。Optionally, the processor further includes a starting unit 606.
所述运行单元602,还设置为加载所述目标BOOT的运行版本,以及运行所述目标BOOT的运行版本。The running unit 602 is further configured to load an running version of the target BOOT and run a running version of the target BOOT.
所述启动单元606,设置为在所述运行单元602开始运行所述目标BOOT的运行版本时,启动看门狗操作。The startup unit 606 is configured to initiate a watchdog operation when the execution unit 602 starts running the running version of the target BOOT.
在实际应用中,本实施例中所述的检测判断单元501、切换单元502、发送单元503、定时启动单元504、第一读取单元505可以由调整装置上的中央处理器(CPU),微处理器(Microcontroller Unit,MCU)、数字信号处理器(Digital Signal Processing,DSP)或现场可编程门阵列(FPGA)、调制解调器等器件实现。本实施例中所述的第二读取单元601、运行单元602、写入单元603、接收单元604、复位单元605、启动单元606可以由元数据节点上的中央处理器(CPU)、微处理器(MPU)、数字信号处理器(DSP)或现场可编程门阵列(FPGA)、调制解调器等器件实现。 In a practical application, the detection determining unit 501, the switching unit 502, the sending unit 503, the timing starting unit 504, and the first reading unit 505 described in this embodiment may be implemented by a central processing unit (CPU) on the adjusting device. Implemented by a Microcontroller Unit (MCU), a Digital Signal Processing (DSP), or a Field Programmable Gate Array (FPGA), a modem, or the like. The second reading unit 601, the running unit 602, the writing unit 603, the receiving unit 604, the reset unit 605, and the starting unit 606 described in this embodiment may be processed by a central processing unit (CPU) on the metadata node. Device (MPU), digital signal processor (DSP) or field programmable gate array (FPGA), modem and other device implementation.
本领域内的技术人员应明白,本公开的实施例可提供为方法、系统、或计算机程序产品。因此,本公开可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本公开可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present disclosure can be provided as a method, system, or computer program product. Accordingly, the present disclosure may take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware aspects. Moreover, the present disclosure may 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.) including computer usable program code.
本公开是参照根据本公开实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的ARM处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的ARM处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present disclosure is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to an ARM processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that instructions are executed by an ARM processor of a computer or other programmable data processing device Means are provided for implementing the functions specified in one or more of the flow or in one or more blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。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 blocks of a flow or a flow and/or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。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 of the flow or in a block or blocks of a flow diagram.
以上所述,仅为本公开的实施例而已,并非用于限定本公开的保护范围。The above description is only for the embodiments of the present disclosure, and is not intended to limit the scope of the disclosure.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬 件。基于这样的理解,本公开实施例的技术方案可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本公开实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be hard. Pieces. Based on such understanding, the technical solution of the embodiments of the present disclosure may be embodied in the form of a software product stored in a storage medium (such as a ROM/RAM, a magnetic disk, an optical disk), including instructions for making one The terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) performs the method described in the embodiments of the present disclosure.
需要说明的是,本发明公开的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。It should be noted that the terms "first", "second" and the like in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or order. .
工业实用性Industrial applicability
本公开实施例通过在EPLD的寄存器中设置双BOOT启动区标志,实现了切换使用单片SPI Flash中存储的双BOOT,不需要过多的地址线,控制简单,同时降低了硬件成本。 The embodiment of the present disclosure realizes switching between dual BOOTs stored in a single SPI Flash by setting a dual BOOT boot area flag in a register of the EPLD, which does not require too many address lines, has simple control, and reduces hardware cost.

Claims (15)

  1. 一种双引导文件的切换方法,所述双引导文件存储在串行外设接口闪存(SPI Flash)中,包括:A method for switching a dual boot file, the dual boot file being stored in a serial peripheral interface flash memory (SPI Flash), comprising:
    检测获取处理器写入寄存器中的标志位,并根据所述标志位判断第一引导文件是否启动失败;以及Detecting a flag bit in the processor write register, and determining, according to the flag bit, whether the first boot file fails to be started;
    在所述第一引导文件启动失败时,将所述寄存器中的启动区标志由第一启动区标志切换为第二引导文件对应的第二启动区标志,并向所述处理器发送复位信号。When the first boot file fails to be started, the boot area flag in the register is switched from the first boot area flag to the second boot area flag corresponding to the second boot file, and a reset signal is sent to the processor.
  2. 根据权利要求1所述的方法,所述检测获取处理器写入寄存器中的标志位之前,所述方法还包括:The method of claim 1, before the detecting the processor writes the flag bit in the register, the method further comprising:
    检测到所述处理器写入所述寄存器中的定时器触发标志时,启动所述寄存器中的第一翻转定时器和第二翻转定时器开始计时,其中,所述第一翻转定时器的定时时长为第一预设时间,所述第二翻转定时器的定时时长为第二预设时间,所述第一预设时间小于所述第二预设时间;When detecting that the processor writes a timer trigger flag in the register, starting a first flip timer and a second flip timer in the register to start timing, wherein a timing of the first flip timer The duration of the second preset timer is a second preset time, and the first preset time is less than the second preset time;
    其中,所述检测获取处理器写入寄存器中的标志位,并根据所述标志位判断第一引导文件是否启动失败,包括:The detecting acquires a flag bit written in the register by the processor, and determines, according to the flag bit, whether the first boot file fails to be started, including:
    当所述第一翻转定时器达到所述第一预设时间时,检测获取所述处理器写入所述寄存器中的第一标志位;在所述第一标志位不是第一预定值时,确定第一引导文件启动失败;When the first flip timer reaches the first preset time, detecting that the processor writes a first flag bit in the register; when the first flag bit is not the first predetermined value, Determining that the first boot file failed to start;
    在所述第一标志位是第一预定值,且所述第二翻转定时器达到所述第二预设时间时,检测获取所述处理器写入所述寄存器中的第二标志位;在所述第二标志位不是第二预定值时,确定第一引导文件启动失败。When the first flag bit is a first predetermined value, and the second rollover timer reaches the second preset time, detecting that the processor writes the second flag bit in the register; When the second flag is not the second predetermined value, it is determined that the first boot file fails to be started.
  3. 根据权利要求1所述的方法,所述检测获取处理器写入寄存器中的标志位之前,所述方法还包括: The method of claim 1, before the detecting the processor writes the flag bit in the register, the method further comprising:
    从串行外设接口闪存(SPI Flash)中读取启动区标志并存入所述寄存器中。The boot area flag is read from the serial peripheral interface flash (SPI Flash) and stored in the register.
  4. 一种双引导文件的切换方法,包括:A method for switching a dual boot file includes:
    读取启动区标志;Read the boot area flag;
    从串行外设接口闪存(SPI Flash)读取启动区标志对应的引导文件,并运行所述启动区标志对应的引导文件;Reading a boot file corresponding to the boot area flag from the serial peripheral interface flash memory (SPI Flash), and running a boot file corresponding to the boot area flag;
    在成功运行启动区标志对应的引导文件时,向可擦除可编辑逻辑器件(EPLD)的寄存器中的标志位写入第一标识值;以及Writing a first identification value to a flag bit in a register of an erasable editable logic device (EPLD) when the boot file corresponding to the boot area flag is successfully run;
    在接收到所述EPLD发送的复位信号后,进行复位操作。After receiving the reset signal sent by the EPLD, a reset operation is performed.
  5. 根据权利要求4所述的切换方法,所述读取启动区标志之前,还包括:The switching method according to claim 4, before the reading of the startup area flag, further comprising:
    从所述SPI Flash中读取二次加载程序SPL,在开始运行所述SPL时,向所述EPLD的寄存器中写入定时器触发标志;Reading a secondary loader SPL from the SPI Flash, and writing a timer trigger flag to a register of the EPLD when starting to run the SPL;
    其中,所述在成功运行启动区标志对应的引导文件时,向所述EPLD的寄存器中的标志位写入第一标识值,包括:The first identification value is written to the flag bit in the register of the EPLD when the boot file corresponding to the boot area flag is successfully run, including:
    在运行启动区标志对应的引导文件时,根据启动区标志对应的引导文件中提供的第一握手信息,向所述EPLD的寄存器中的第一标志位写入第一预定值;When the boot file corresponding to the boot area flag is run, the first predetermined value in the register of the EPLD is written according to the first handshake information provided in the boot file corresponding to the boot area flag;
    在向所述EPLD的寄存器中的第一标志位写入第一预定值后,在运行到加载启动区标志对应的引导文件的运行版本之前,根据所述启动区标志对应的引导文件中提供的第二握手信息,向所述EPLD的寄存器中的第二标志位写入第二预定值。After writing the first predetermined value to the first flag bit in the register of the EPLD, before running to the running version of the boot file corresponding to the loading boot area flag, according to the boot file corresponding to the boot area flag The second handshake information writes a second predetermined value to the second flag bit in the register of the EPLD.
  6. 根据权利要求5所述的方法,其中,所述读取启动区标志,包括:The method of claim 5 wherein said reading a boot zone flag comprises:
    在运行所述SPL的末尾阶段,从所述EPLD的寄存器中读取双BOOT启动区标志。At the end of the run of the SPL, the dual BOOT boot sector flag is read from the register of the EPLD.
  7. 根据权利要求5所述的方法,其中,所述向所述EPLD的寄存器中的第 二标志位写入第二预定值后,所述方法还包括:The method of claim 5 wherein said number in said register of said EPLD After the second flag is written to the second predetermined value, the method further includes:
    加载所述启动区标志对应的引导文件的运行版本,并在开始运行所述启动区标志对应的引导文件的运行版本时,启动看门狗操作。Loading a running version of the boot file corresponding to the boot area flag, and starting a watchdog operation when starting to run a running version of the boot file corresponding to the boot area flag.
  8. 一种可擦除可编辑逻辑器件EPLD,包括:An erasable editable logic device EPLD, comprising:
    寄存器;register;
    检测判断单元,设置为检测获取处理器写入寄存器中的标志位,并根据所述标志位判断第一引导文件是否启动成功;The detection determining unit is configured to detect a flag bit in the write register of the acquisition processor, and determine, according to the flag bit, whether the first boot file is successfully started;
    切换单元,设置为在所述检测判断单元确定所述第一引导文件启动失败时,将所述寄存器中的启动区标志由第一启动区标志切换为第二启动区标志;以及a switching unit configured to switch the boot area flag in the register from the first boot area flag to the second boot area flag when the detection determining unit determines that the first boot file fails to start;
    发送单元,设置为在所述检测判断单元确定第一引导文件启动失败时向所述处理器发送复位信号。The transmitting unit is configured to send a reset signal to the processor when the detection determining unit determines that the first boot file fails to start.
  9. 根据权利要求8所述的EPLD,还包括定时启动单元;The EPLD of claim 8 further comprising a timing activation unit;
    所述定时启动单元,设置为在检测到所述处理器写入所述寄存器中的定时器触发标志时,启动所述寄存器中的第一翻转定时器和第二翻转定时器开始计时,其中,所述第一翻转定时器的定时时长为第一预设时间,所述第二翻转定时器的定时时长为第二预设时间,所述第一预设时间小于所述第二预设时间;The timing starting unit is configured to start a first inversion timer and a second inversion timer in the register to start timing when detecting that the processor writes a timer trigger flag in the register, where The timing of the first inversion timer is a first preset time, the timing of the second inversion timer is a second preset time, and the first preset time is less than the second preset time;
    其中,所述检测判断单元,还设置为当所述定时启动单元启动的所述第一翻转定时器达到所述第一预设时间时,检测获取所述处理器写入所述寄存器中的第一标志位;在所述第一标志位不是第一预定值时,确定第一引导文件启动失败;在所述第一标志位是第一预定值,且所述定时启动单元启动的所述第二翻转定时器达到所述第二预设时间时,检测获取所述处理器写入所述寄存器中的第二标志位;在所述第二标志位不是第二预定值时,确定第一引导文件失败。The detecting and determining unit is further configured to: when the first inversion timer started by the timing starting unit reaches the first preset time, detect that the processor writes into the register a flag bit; determining that the first boot file fails to start when the first flag bit is not the first predetermined value; wherein the first flag bit is a first predetermined value, and the timing start unit is activated When the second flip timer reaches the second preset time, detecting that the processor writes the second flag bit in the register; when the second flag bit is not the second predetermined value, determining the first boot The file failed.
  10. 根据权利要求8所述的EPLD,还包括第一读取单元; The EPLD of claim 8 further comprising a first reading unit;
    所述第一读取单元设置为从串行外设接口非易失性闪存SPI Flash中读取启动区标志并存入所述寄存器中。The first read unit is configured to read a boot area flag from the serial peripheral interface non-volatile flash SPI Flash and store the register.
  11. 一种处理器,包括:A processor comprising:
    第二读取单元,设置为从可擦除可编辑逻辑器件EPLD的寄存器中读取启动区标志;并从串行外设接口非易失性闪存SPI Flash读取所述启动区标志对应的引导文件;a second reading unit configured to read a boot area flag from a register of the erasable editable logic device EPLD; and read a boot corresponding to the boot area flag from the serial peripheral interface non-volatile flash SPI Flash file;
    运行单元,设置为运行所述启动区标志对应的引导文件;a running unit, configured to run a boot file corresponding to the boot area flag;
    写入单元,设置为在所述运行单元运行启动区标志对应的引导文件的过程中未出现异常时,向所述EPLD的寄存器中的标志位写入第一标识值;a writing unit configured to write a first identification value to a flag bit in a register of the EPLD when an abnormality does not occur in a process in which the running unit runs a boot file corresponding to the boot area flag;
    接收单元,设置为接收所述EPLD的寄存器发送的复位信号;以及a receiving unit configured to receive a reset signal sent by a register of the EPLD;
    复位单元,设置为在所述接收单元接收到所述复位信号后,进行复位操作。The reset unit is configured to perform a reset operation after the receiving unit receives the reset signal.
  12. 根据权利要求11所述的处理器,其中,The processor of claim 11 wherein
    所述第二读取单元还设置为从所述SPI Flash中读取二次加载程序SPL;The second reading unit is further configured to read the secondary loader SPL from the SPI Flash;
    所述运行单元还设置为运行所述第二读取单元读取到的所述SPL;The operating unit is further configured to run the SPL read by the second reading unit;
    所述写入单元还设置为在所述运行单元开始运行所述SPL时,向所述EPLD的寄存器中写入定时器触发标志;The writing unit is further configured to write a timer trigger flag to a register of the EPLD when the operating unit starts to run the SPL;
    其中,在所述运行单元运行启动区标志对应的引导文件时,所述写入单元根据所述启动区标志对应的引导文件中提供的第一握手信息,向所述EPLD的寄存器中的第一标志位写入第一预定值;在向所述EPLD的寄存器中的第一标志位写入第一预定值后,在所述运行单元运行到加载所述启动区标志对应的引导文件的运行版本之前,所述写入单元根据所述目标BOOT中提供的第二握手信息,向所述EPLD的寄存器中的第二标志位写入第二预定值。Wherein, when the running unit runs the boot file corresponding to the boot area flag, the writing unit is first to the EPLD register according to the first handshake information provided in the boot file corresponding to the boot area flag Writing a flag to the first predetermined value; after writing the first predetermined value to the first flag in the register of the EPLD, running the running unit to the running version of the boot file corresponding to the boot area flag Previously, the writing unit writes a second predetermined value to the second flag bit in the register of the EPLD according to the second handshake information provided in the target BOOT.
  13. 根据权利要求12所述的处理器,其中, The processor of claim 12, wherein
    所述第二读取单元设置为在所述运行单元运行到所述SPL的末尾阶段,从所述EPLD的寄存器中读取启动区标志。The second read unit is configured to read a boot area flag from a register of the EPLD at a stage in which the run unit runs to the SPL.
  14. 根据权利要求12所述的处理器,还包括启动单元;The processor of claim 12 further comprising a boot unit;
    所述运行单元还设置为加载并运行所述启动区标志对应的引导文件的运行版本;The running unit is further configured to load and run an running version of the boot file corresponding to the boot area flag;
    所述启动单元设置为在所述运行单元开始运行所述启动区标志对应的引导文件的运行版本时,启动看门狗操作。The startup unit is configured to initiate a watchdog operation when the running unit starts running an running version of the boot file corresponding to the boot area flag.
  15. 一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行权利要求1-7任一项的方法。 A computer readable storage medium storing computer executable instructions for performing the method of any of claims 1-7.
PCT/CN2016/087679 2016-01-15 2016-06-29 Method and device for switching between two boot files WO2017121077A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610032109.2 2016-01-15
CN201610032109.2A CN106980513A (en) 2016-01-15 2016-01-15 A kind of switching method and device of dual boot file

Publications (1)

Publication Number Publication Date
WO2017121077A1 true WO2017121077A1 (en) 2017-07-20

Family

ID=59310703

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/087679 WO2017121077A1 (en) 2016-01-15 2016-06-29 Method and device for switching between two boot files

Country Status (2)

Country Link
CN (1) CN106980513A (en)
WO (1) WO2017121077A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108304282B (en) * 2018-03-07 2021-04-20 郑州云海信息技术有限公司 Control method of double BIOS and related device
CN113986383A (en) * 2021-10-28 2022-01-28 山东云海国创云计算装备产业创新中心有限公司 Boot loader starting method and related device
CN116266167A (en) * 2021-12-17 2023-06-20 华为技术有限公司 Data processing system and method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101329632A (en) * 2008-04-30 2008-12-24 中兴通讯股份有限公司 Method and apparatus for starting CPU by BOOT
CN102200933A (en) * 2010-03-23 2011-09-28 深圳华北工控股份有限公司 System BIOS (Basic Input/Output System) automatic restoring method based on dual SPI (Serial Peripheral interface) Flashes
CN103135995A (en) * 2011-11-22 2013-06-05 中兴通讯股份有限公司 BootLoader backup management method and device
CN103678030A (en) * 2012-09-04 2014-03-26 杭州海康威视数字技术股份有限公司 Multi-system equipment start system and method thereof

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101329632A (en) * 2008-04-30 2008-12-24 中兴通讯股份有限公司 Method and apparatus for starting CPU by BOOT
CN102200933A (en) * 2010-03-23 2011-09-28 深圳华北工控股份有限公司 System BIOS (Basic Input/Output System) automatic restoring method based on dual SPI (Serial Peripheral interface) Flashes
CN103135995A (en) * 2011-11-22 2013-06-05 中兴通讯股份有限公司 BootLoader backup management method and device
CN103678030A (en) * 2012-09-04 2014-03-26 杭州海康威视数字技术股份有限公司 Multi-system equipment start system and method thereof

Also Published As

Publication number Publication date
CN106980513A (en) 2017-07-25

Similar Documents

Publication Publication Date Title
US10353779B2 (en) Systems and methods for detection of firmware image corruption and initiation of recovery
US9471435B2 (en) Information processing device, information processing method, and computer program
US10146627B2 (en) Mobile flash storage boot partition and/or logical unit shadowing
US7739487B2 (en) Method for booting a host device from an MMC/SD device, a host device bootable from an MMC/SD device and an MMC/SD device method a host device may booted from
US7870378B2 (en) Electronic system with NAND flash memory storing boot code and highly reliable boot up method
US20080010446A1 (en) Portable apparatus supporting multiple operating systems and supporting method therefor
US9983791B2 (en) System management controller and method of configuration file backup and recovery
US20170168849A1 (en) Computer Device and Memory Startup Method of Computer Device
US9715267B2 (en) Method for switching operating systems and electronic apparatus
CN109960523B (en) Firmware upgrading method and device for embedded equipment
TW201624273A (en) Firmware variable update method
KR20070077463A (en) Method of system booting with a direct memory access in a new memory architecture
CN102945173A (en) User program on-line upgrading system and method
TW201409238A (en) Mode switch method of electronic device and associated electronic device
US11704198B2 (en) Method and apparatus for providing recovery from a computing device boot up error
WO2015154538A1 (en) Memory booting method and device
WO2017121077A1 (en) Method and device for switching between two boot files
US20120060023A1 (en) Methods for booting an operating system using non-volatile memory
US10491736B2 (en) Computer system and method thereof for bluetooth data sharing between UEFI firmware and OS
US7849300B2 (en) Method for changing booting sources of a computer system and a related backup/restore method thereof
US20200015296A1 (en) Computer system and method thereof for sharing of wireless connection information between uefi firmware and os
KR102116096B1 (en) Multisystem, and method of booting the same
JP2013182577A (en) Information processing apparatus, image forming apparatus, and program
CN108196869B (en) EMMC firmware starting method and device
CN106611124A (en) Computer device and boot method thereof

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: 16884635

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: 16884635

Country of ref document: EP

Kind code of ref document: A1