Method and device for starting embedded Linux main and standby operating systems based on ping-pong mechanism

By adopting the ping-pong mechanism of the main and standby operating system startup method in the embedded Linux system, and utilizing the ROMCODE and flash storage area in the microprocessor chip, the rapid startup and normal operation of the main and standby systems are achieved, solving the problem of long startup time in the existing technology and ensuring that equipment in application scenarios such as the power industry is put online on time.

CN119557009BActive Publication Date: 2025-09-26HANGZHOU VANGO TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411607028.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-09-26
Estimated Expiration
2044-11-12

AI Technical Summary

Technical Problem

The existing embedded Linux main and standby operating system startup method takes too long to start up when the main system cannot start up, resulting in the application program being unable to go online and run on time, especially in application scenarios with requirements for device startup time, such as data collection terminals in the power industry.

Method used

An embedded Linux primary and backup operating system startup method based on the ping-pong mechanism is adopted. By including the ROMCODE of the primary system and the backup system inside the microprocessor chip and setting the primary area and the backup area in the flash storage area, the primary and backup system image files are verified and started, ensuring that the backup system image file is started immediately when the primary system fails to start, avoiding repair taking up startup time.

Benefits of technology

It achieves fast startup of embedded Linux main and standby operating systems, ensuring that the application runtime is not affected when the main system fails to start. The image file is then repaired in the idle state to ensure the normal startup and operation of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557009B_ABST
    Figure CN119557009B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for starting an embedded Linux primary and backup operating system based on a ping-pong mechanism. The embedded system uses an MPU chip whose internal ROM contains ROM codes for the primary and backup systems. The embedded system architecture includes a flash storage area, wherein the flash is provided with a primary area and a backup area. The primary area is configured with a primary system image file, and the backup area is configured with a backup system image file. The startup method includes: executing the ROM code of the primary system and the ROM code of the backup system; verifying the SPL image file in the primary system image file and the SPL image file in the backup system image file; saving the verification result in a verification record; if the SPL image file of the primary system image file is successfully verified, starting the SPL image file of the primary system image file; if the SPL image file of the backup system image file is successfully verified, starting the SPL image file of the backup system image file. This method can achieve rapid startup of the embedded Linux primary and backup operating systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of embedded technology, and specifically relates to a method and device for starting an embedded Linux main and standby operating system based on a ping-pong mechanism. Background Art

[0002] As embedded Linux rapidly develops within the emerging field of embedded operating systems, its applications are becoming increasingly widespread and its functionality is becoming increasingly complex, placing new demands on system stability. To ensure reliable and stable operation, industrial embedded products are typically configured with a dual active / standby system.

[0003] Currently, there are two main methods for booting a dual-system system: the first involves booting the backup system when the primary system fails to boot. For example, Chinese invention patent application number 2014108371866 discloses a method for booting a primary and backup embedded boot program. This method first reads and loads the primary boot program. If the load fails, the device is restarted and the backup boot program is read and loaded. This method takes twice the normal boot time. The second method involves restoring the primary system using files in the backup area when the primary system fails to boot, and then restarting the primary system. For example, Chinese invention patent application number 202211304625.8 discloses a backup boot method for an embedded system architecture. This embedded system architecture employs a method that configures a first system partition, a second system partition, and a mirror area in a storage area. If both the first and second system partitions fail to boot, the system files of the first and second system partitions are restored using the system image files in the mirror area. The system is then booted from the first system partition based on the restored system files. Because writing to the flash memory during repair is slow, this also prolongs the device's boot time.

[0004] Both of the above methods suffer from the problem of long device startup times if the main system fails to boot, preventing applications from launching on time. In some application scenarios, device startup times are critical. For example, if a data collection terminal in the power industry takes too long to boot, the application will fail to connect to the power server. Summary of the Invention

[0005] Purpose of the invention: The technical problem to be solved by the present invention is to address the deficiencies of the existing technology and provide a method and device for starting an embedded Linux primary and standby operating system based on a ping-pong mechanism, which can achieve rapid startup of the embedded Linux primary and standby operating system.

[0006] In order to solve the above technical problems, the present invention discloses a method for starting an embedded Linux main and backup operating system based on a ping-pong mechanism. The embedded system is applied to a microprocessor chip whose internal ROM contains a ROMCODE of a main system and a ROMCODE of a backup system. The architecture of the embedded system includes a flash storage area, wherein the flash storage area is provided with a main area and a backup area. The main area is configured with a main system image file, and the backup area is configured with a backup system image file. The method comprises:

[0007] Execute the ROMCODE of the main system and the ROMCODE of the backup system;

[0008] Verify the secondary boot program image file in the main system image file and the secondary boot program image file in the backup system image file; save the verification result to the verification record; the verification result includes: system identification, image file name and verification success or failure identification;

[0009] If the secondary boot program image file in the main system image file is verified successfully, the secondary boot program image file in the main system image file is started;

[0010] If the secondary boot program image file in the backup system image file is verified successfully, the secondary boot program image file in the backup system image file is started.

[0011] Furthermore, the method further comprises:

[0012] Verify the Uboot image file in the main system image file and the Uboot image file in the backup system image file; save the verification results to the verification record;

[0013] If the Uboot image file in the main system image file is verified successfully, start the Uboot image file in the main system image file;

[0014] If the Uboot image file in the backup system image file is verified successfully, start the Uboot image file in the backup system image file.

[0015] Furthermore, the method further comprises:

[0016] Verify the kernel image file in the main system image file and the kernel image file in the backup system image file; save the verification result to the verification record;

[0017] If the kernel image file in the main system image file is verified successfully, the kernel image file in the main system image file is booted into the memory for execution, the root file system is mounted, and the startup process ends;

[0018] If the kernel image file in the main system image file fails to be verified, and the kernel image file in the backup system image file passes the verification, the kernel image file in the backup system image file is booted into the memory for execution, the root file system is mounted, and the startup process ends.

[0019] Furthermore, the method further comprises:

[0020] After the system is started, the calibration record is obtained in the idle state;

[0021] If the verification record includes a verification result of a verification failure, obtaining a location of the image file that failed the verification in the flash storage area according to the system identifier and the image file name in the verification result;

[0022] Repair the image file that failed verification.

[0023] Furthermore, the method uses the fdisk tool to repair the image file that fails verification.

[0024] On the other hand, the present invention also discloses an embedded Linux main-backup operating system startup device based on a ping-pong mechanism, wherein the internal ROM of a microprocessor chip of the embedded system contains a ROMCODE of a main system and a ROMCODE of a backup system; the architecture of the embedded system includes a flash storage area, the flash storage area is provided with a main area and a backup area, the main area is configured with a main system image file, and the backup area is configured with a backup system image file; the device comprises:

[0025] ROMCODE startup module, used to execute the ROMCODE of the main system and the ROMCODE of the backup system;

[0026] A first verification module is used to verify the secondary boot program image file in the main system image file and the secondary boot program image file in the backup system image file; save the verification result to the verification record; the verification result includes: system identification, image file name and verification success or failure mark;

[0027] The first startup module is used to start the secondary boot program image file in the main system image file if the secondary boot program image file in the main system image file is verified successfully; if the secondary boot program image file in the backup system image file is verified successfully, start the secondary boot program image file in the backup system image file.

[0028] Furthermore, the device further comprises:

[0029] The second verification module is used to verify the Uboot image file in the main system image file and the Uboot image file in the backup system image file; and save the verification result to the verification record;

[0030] The second startup module is used to start the Uboot image file in the main system image file if the Uboot image file in the main system image file is successfully verified; if the Uboot image file in the backup system image file is successfully verified, start the Uboot image file in the backup system image file.

[0031] Furthermore, the device further comprises:

[0032] A third verification module is used to verify the kernel image file in the main system image file and the kernel image file in the backup system image file; and save the verification result to the verification record;

[0033] The third startup module is used to guide the kernel image file in the main system image file to the memory for execution, mount the root file system, and end the startup process if the kernel image file in the main system image file is successfully verified; if the kernel image file in the main system image file fails to be verified and the kernel image file in the backup system image file is successfully verified, guide the kernel image file in the backup system image file to the memory for execution, mount the root file system, and end the startup process.

[0034] Furthermore, the device further comprises:

[0035] A repair module is configured to obtain a verification record in an idle state after the system is started; if the verification record contains a verification result of a verification failure, obtain the location of the image file that failed the verification in the flash storage area based on the system identifier and the image file name in the verification result;

[0036] Furthermore, the repair module uses the fdisk tool to repair the image file that fails verification.

[0037] Beneficial effect: Compared with the prior art, the method and device for starting an embedded Linux main-backup operating system based on a ping-pong mechanism disclosed in the present invention starts the main system and the backup system at the same time during the startup process. If the main system fails at a certain stage during the startup process, the corresponding image file of the backup system is also started, and the startup does not stop, nor does it repair the image file of the main system in the flash. Instead, it only records the verification result, and the repair of the flash is placed in an idle state after the system is started, which does not take up the startup time, thereby ensuring smooth startup and unaffected application running time. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments, and the above and / or other advantages of the present invention will become more apparent.

[0039] Figure 1 It is a flowchart of a method for starting an embedded Linux main and standby operating system based on a ping-pong mechanism;

[0040] Figure 2 This is a block diagram of the composition of the embedded Linux main and standby operating system startup device based on the ping-pong mechanism. DETAILED DESCRIPTION

[0041] This embodiment discloses a method for starting an embedded Linux main and standby operating system based on a ping-pong mechanism. Figure 1 As shown. The internal ROM of the microprocessor chip used in this embedded system contains the ROMCODE of the main system and the ROMCODE of the backup system. The ROMCODE is a piece of code fixed to the internal ROM of the microprocessor chip. This code cannot be modified and serves as the first boot program of the system. In this embodiment, the ROMCODE of the main system starts at address 0 of the internal ROM of the chip, and the ROMCODE of the backup system starts at an offset address of the internal ROM of the chip.

[0042] The architecture of the embedded system includes a flash storage area, wherein the flash storage area is provided with a main area and a backup area, wherein the main area is configured with a main system image file, and the backup area is configured with a backup system image file; in this embodiment, the image files used for startup include a secondary boot program image file, a Uboot image file, and a kernel image file. Among them, the secondary boot program SPL (Secondary program loader) is used to initialize the necessary components of the embedded board such as clock, memory, and flash, in preparation for loading UBoot; UBoot (Universal Boot Loader) turns on the necessary hardware of the system, provides a debugging interface to initialize the environment variables, and prepares for loading the kernel; the kernel is the core of the system, providing memory management, process management, device drivers, system call interfaces, etc. After the kernel runs in the memory, the root file system rootfs is mounted. Rootfs is a logical storage and recovery system for naming files and placing files; then the user application can be started and run.

[0043] The embedded Linux primary and standby operating system startup method disclosed in this embodiment includes:

[0044] S101, executing the ROMCODE of the main system and the ROMCODE of the backup system;

[0045] ROMCODE is the firmware of the MPU. Based on the constraints of the MPU, the ROMCODE data will be verified. The verification method may be different for each MPU. If the verification fails, the chip will not be able to start normally.

[0046] S102, verifying the secondary boot program image file in the main system image file and the secondary boot program image file in the backup system image file; saving the verification result to a verification record; the verification result includes: system identification, image file name and verification success or failure identification;

[0047] If the verification result of a certain time is that the secondary boot program image file in the main system image file is verified successfully, but the secondary boot program image file in the backup system image file fails to be verified, it can be recorded as:

[0048] Primary system SPL 1; backup system SPL 0

[0049] Here, "1" indicates successful verification, and "0" indicates failed verification.

[0050] S103, if the secondary boot program image file in the main system image file is successfully verified, start the secondary boot program image file in the main system image file;

[0051] If the secondary boot program image file in the backup system image file is verified successfully, the secondary boot program image file in the backup system image file is started.

[0052] If the SPL image file in the main system image file and the SPL image file in the backup system image file are both verified successfully, after this step is completed, the SPL in the main system and the backup system are both started.

[0053] S201, verify the Uboot image file in the main system image file and the Uboot image file in the backup system image file; save the verification result to the verification record;

[0054] S202: If the Uboot image file in the main system image file is successfully verified, start the Uboot image file in the main system image file;

[0055] If the Uboot image file in the backup system image file is verified successfully, start the Uboot image file in the backup system image file.

[0056] S301, verify the kernel image file in the main system image file and the kernel image file in the backup system image file; save the verification result to the verification record;

[0057] S302: If the kernel image file in the main system image file is successfully verified, the kernel image file in the main system image file is booted into the memory for execution, the root file system is mounted, and the boot process ends;

[0058] If the kernel image file in the main system image file fails to be verified, and the kernel image file in the backup system image file passes the verification, the kernel image file in the backup system image file is booted into the memory for execution, the root file system is mounted, and the startup process ends.

[0059] During the above startup process, the main system and the backup system are started at the same time. If the main system fails at a certain stage during the startup process, since the corresponding image file of the backup system is also started, the startup does not stop, nor does it repair the image file of the main system in the flash. Instead, it only records the verification result, which is equivalent to switching the startup to the corresponding position of the backup system. This action is equivalent to playing ping-pong once. If there is another failure in the subsequent startup process, the ping-pong action will be triggered, causing the system startup to switch back and forth between the main and backup systems, ensuring smooth startup and unaffected application running time.

[0060] To ensure the correct data in the active and standby systems, the flash data needs to be repaired. This repair is performed after the system is started. That is, after the above steps are completed, the following steps are also included:

[0061] After the system is started, obtain the calibration record in the idle state;

[0062] If the verification record includes a verification result of a verification failure, obtaining a location of the image file that failed the verification in the flash storage area according to the system identifier and the image file name in the verification result;

[0063] Repair the image file that failed verification.

[0064] The amount of verification record data is extremely small, and saving it takes almost no time, does not affect the startup process time, and can facilitate flash repair.

[0065] Repairing flash data does not consume boot time, so the active and standby system startup is streamlined. Even in abnormal situations, startup can be completed on time, just as in normal situations, ensuring the normal operation of the system and online procedures. Flash repair can be performed by calling disk repair tools such as the Linux fdisk tool to repair image files that failed verification.

[0066] This embodiment also discloses a device for implementing the above-mentioned method for starting the embedded Linux main and standby operating system based on the ping-pong mechanism, such as Figure 2As shown. The internal ROM of the microprocessor chip of the embedded system includes the ROMCODE of the main system and the ROMCODE of the backup system; the architecture of the embedded system includes a flash storage area, the flash storage area is provided with a main area and a backup area, the main area is configured with a main system image file, and the backup area is configured with a backup system image file; the device includes:

[0067] ROMCODE startup module, used to execute the ROMCODE of the main system and the ROMCODE of the backup system;

[0068] A first verification module is used to verify the secondary boot program image file in the main system image file and the secondary boot program image file in the backup system image file; save the verification result to the verification record; the verification result includes: system identification, image file name and verification success or failure mark;

[0069] The first startup module is used to start the secondary boot program image file in the main system image file if the secondary boot program image file in the main system image file is verified successfully; if the secondary boot program image file in the backup system image file is verified successfully, start the secondary boot program image file in the backup system image file.

[0070] The second verification module is used to verify the Uboot image file in the main system image file and the Uboot image file in the backup system image file; and save the verification result to the verification record;

[0071] The second startup module is used to start the Uboot image file in the main system image file if the Uboot image file in the main system image file is successfully verified; if the Uboot image file in the backup system image file is successfully verified, start the Uboot image file in the backup system image file.

[0072] A third verification module is used to verify the kernel image file in the main system image file and the kernel image file in the backup system image file; and save the verification result to the verification record;

[0073] The third startup module is used to guide the kernel image file in the main system image file to the memory for execution, mount the root file system, and end the startup process if the kernel image file in the main system image file is successfully verified; if the kernel image file in the main system image file fails to be verified and the kernel image file in the backup system image file is successfully verified, guide the kernel image file in the backup system image file to the memory for execution, mount the root file system, and end the startup process.

[0074] To ensure the correctness of the data in the primary and backup systems, the flash data needs to be repaired. The above device also includes:

[0075] A repair module is configured to obtain a verification record in an idle state after the system is started; if the verification record contains a verification result of a verification failure, obtain the location of the image file that failed the verification in the flash storage area based on the system identifier and the image file name in the verification result;

[0076] In this embodiment, the repair module uses the fdisk tool to repair the image file that fails verification.

[0077] The present invention provides a concept and method for booting an embedded Linux primary and standby operating system based on a ping-pong mechanism. There are many methods and approaches for implementing this technical solution. The above is only a preferred embodiment of the present invention. It should be noted that those skilled in the art may make various improvements and modifications without departing from the principles of the present invention, and such improvements and modifications are also within the scope of protection of the present invention. Any components not specified in this embodiment may be implemented using existing technologies.

Claims

1. A method for starting an embedded Linux master / slave operating system based on a ping-pong mechanism, characterized in that: The internal ROM of the microprocessor chip of the application embedded system contains the ROMCODE of the main system and the ROMCODE of the backup system; The architecture of the embedded system includes a flash storage area, wherein the flash storage area is provided with a main area and a backup area, the main area is configured with a main system image file, and the backup area is configured with a backup system image file; The method comprises: Execute the ROMCODE of the main system and the ROMCODE of the backup system; Verify the secondary boot program image file in the main system image file and the secondary boot program image file in the backup system image file; save the verification result to the verification record; the verification result includes: system identification, image file name and verification success or failure identification; If the secondary boot program image file in the main system image file is verified successfully, the secondary boot program image file in the main system image file is started; If the secondary boot program image file in the backup system image file is verified successfully, the secondary boot program image file in the backup system image file is started.

2. The method for starting an embedded Linux master / slave operating system based on the ping-pong mechanism according to claim 1, characterized in that: Also includes: Verify the Uboot image file in the main system image file and the Uboot image file in the backup system image file; Save the calibration results to the calibration record; If the Uboot image file in the main system image file is verified successfully, start the Uboot image file in the main system image file; If the Uboot image file in the backup system image file is verified successfully, start the Uboot image file in the backup system image file.

3. The method for starting an embedded Linux master / slave operating system based on the ping-pong mechanism according to claim 2, characterized in that: Also includes: Verify the kernel image file in the main system image file and the kernel image file in the backup system image file; Save the calibration results to the calibration record; If the kernel image file in the main system image file is verified successfully, the kernel image file in the main system image file is booted into the memory for execution, the root file system is mounted, and the startup process ends; If the kernel image file in the main system image file fails to be verified, and the kernel image file in the backup system image file passes the verification, the kernel image file in the backup system image file is booted into the memory for execution, the root file system is mounted, and the startup process ends.

4. The method for starting an embedded Linux master / slave operating system based on a ping-pong mechanism according to any one of claims 1 to 3, characterized in that: Also includes: After the system is started, the calibration record is obtained in the idle state; If the verification record includes a verification result of a verification failure, obtaining a location of the image file that failed the verification in the flash storage area according to the system identifier and the image file name in the verification result; Repair the image file that failed verification.

5. The method for starting an embedded Linux master / slave operating system based on the ping-pong mechanism according to claim 4, characterized in that: Use the fdisk tool to repair the image file that failed verification.

6. An embedded Linux master / slave operating system startup device based on ping-pong mechanism, characterized in that: The internal ROM of the microprocessor chip of the application embedded system contains the ROMCODE of the main system and the ROMCODE of the backup system; The architecture of the embedded system includes a flash storage area, wherein the flash storage area is provided with a main area and a backup area, the main area is configured with a main system image file, and the backup area is configured with a backup system image file; The device comprises: ROMCODE startup module, used to execute the ROMCODE of the main system and the ROMCODE of the backup system; A first verification module is used to verify the secondary boot program image file in the main system image file and the secondary boot program image file in the backup system image file; save the verification result to the verification record; the verification result includes: system identification, image file name and verification success or failure mark; The first startup module is used to start the secondary boot program image file in the main system image file if the secondary boot program image file in the main system image file is verified successfully; if the secondary boot program image file in the backup system image file is verified successfully, start the secondary boot program image file in the backup system image file.

7. The embedded Linux master / slave operating system startup device based on ping-pong mechanism according to claim 6, characterized in that: Also includes: The second verification module is used to verify the Uboot image file in the main system image file and the Uboot image file in the backup system image file; Save the calibration results to the calibration record; The second startup module is used to start the Uboot image file in the main system image file if the Uboot image file in the main system image file is successfully verified; If the Uboot image file in the backup system image file is verified successfully, start the Uboot image file in the backup system image file.

8. The embedded Linux master / slave operating system startup device based on ping-pong mechanism according to claim 7, characterized in that: Also includes: A third verification module is used to verify the kernel image file in the main system image file and the kernel image file in the backup system image file; Save the calibration results to the calibration record; The third startup module is used to guide the kernel image file in the main system image file to the memory for execution if the kernel image file in the main system image file is verified successfully, mount the root file system, and end the startup process; If the kernel image file in the main system image file fails to be verified, and the kernel image file in the backup system image file passes the verification, the kernel image file in the backup system image file is booted into the memory for execution, the root file system is mounted, and the startup process ends.

9. The embedded Linux master / slave operating system startup device based on the ping-pong mechanism according to any one of claims 6 to 8, characterized in that: Also includes: Repair module, used to obtain the calibration record in the idle state after the system is started; If the verification record includes a verification result of a verification failure, the location of the image file that failed the verification in the flash storage area is obtained according to the system identifier and the image file name in the verification result.

10. The embedded Linux master / slave operating system startup device based on ping-pong mechanism according to claim 9, characterized in that: The repair module uses the fdisk tool to repair the image file that fails verification.

Citation Information

Patent Citations

  • Backup starting method and device of embedded system architecture, equipment and chip

    CN115373906A

  • Linux system startup method, device and equipment

    CN108647119A

  • Virtual machine providing system

    JP2013186692A