A method and system for upgrading a dual-slot system

By introducing a fixed Loader program and control plane file into the embedded system, the separation of upgrade preparation and startup decision is achieved, which solves the problems of responsibility coupling and universality in embedded system firmware upgrades, improves the efficiency and reliability of firmware upgrades, and is applicable to scenarios such as IoT devices, embedded devices and server BMCs.

CN122547385BActive Publication Date: 2026-11-10HUNAN BOJIANG INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611020022.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-07-09
Publication Date
2026-11-10
Estimated Expiration
2046-07-09

AI Technical Summary

Technical Problem

Existing embedded system firmware upgrade technologies suffer from problems such as coupled responsibilities, firmware modification dependencies, imperfect rollback mechanisms, and insufficient versatility, resulting in high single-point failure risk, high maintenance costs, and significant compatibility risks.

Method used

A dual-slot system upgrade method based on the separation of runtime and pre-startup states is adopted. By introducing a fixed Loader program and control plane file, the responsibilities of upgrade preparation and startup decision-making are separated. Startup timeout detection, health check and watchdog mechanism are integrated to ensure automatic rollback and system stability.

Benefits of technology

It enables efficient and reliable firmware upgrades, reduces the risk of single points of failure, reduces maintenance costs, and improves the system's automation level and versatility, making it suitable for various hardware platforms and operating systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122547385B_ABST
    Figure CN122547385B_ABST
Patent Text Reader

Abstract

This invention discloses a dual-slot system upgrade method and system, relating to the field of embedded system firmware upgrade technology. The method includes: the running system writing new firmware to a spare slot and updating the boot configuration before resetting; a fixed bootloader reading the configuration, selecting the target slot, verifying integrity, and then starting; a health check determining whether the boot was successful; if it fails, switching slots for retry; and marking the system as unusable after reaching a threshold. This invention achieves separation of responsibilities between the running state and the pre-boot state, with a fixed Loader, eliminating the need to modify the UEFI firmware. It also ensures automatic rollback through a triple mechanism of timeout detection, health checks, and a watchdog timer, preventing device bricking.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of embedded system firmware upgrade technology, specifically relating to a dual-slot system upgrade method and system, applicable to scenarios requiring highly reliable firmware updates such as IoT devices, embedded devices, and server BMCs. Background Technology

[0002] Currently, firmware upgrade technologies for embedded systems mainly include the following solutions: MCUBoot Solution: MCUboot is an open-source bootloader that uses a dual-slot design and supports image verification and rollback mechanisms. Its core process is as follows: the runtime system writes the new firmware to the inactive slot; updates the slot status flag in the bootloader; after rebooting, the bootloader selects the boot slot based on the flag; and after booting, the application confirms the upgrade success. However, this solution's upgrade logic is tightly coupled with the bootloader, making modification complex; the runtime system directly manipulates the bootloader state, posing security risks; and the rollback mechanism relies on application confirmation, resulting in weak handling capabilities for initial boot failure scenarios.

[0003] Android A / B Solution: The Android system adopts an A / B partition design to achieve seamless upgrades. When the system is running on slot A, the new version is upgraded to slot B; the boot slot is switched via the boot_control flag; automatic rollback and multi-version management are supported. However, this solution relies on the Android-specific framework, has poor versatility, requires modification of the bootloader or UEFI firmware, and has high hardware resource requirements.

[0004] UEFI Capsule Update Solution: This is a firmware update mechanism defined by the UEFI standard, which encapsulates update content through Capsule files. The UEFI firmware processes the update during the boot phase and supports security verification and rollback. However, this solution requires the UEFI firmware to support a specific Capsule format; the update logic is fixed in the UEFI, resulting in poor flexibility; and it does not support the separation of responsibilities between the runtime state and the pre-boot state.

[0005] The existing technology has the following defects: (1) Dual responsibility coupling problem: the existing solution couples the upgrade preparation and startup decision in the same stage, and the running system directly determines the startup slot, which poses a single point of failure risk; (2) Firmware modification dependency: most solutions require modification of the Bootloader or UEFI firmware, which increases maintenance costs and compatibility risks; (3) Imperfect rollback mechanism: in the case of first startup failure, the existing solution has limited automatic rollback capability, which may lead to the device becoming bricked; (4) Insufficient universality: the existing solutions are mostly for specific platforms (such as Android, UEFI), which are difficult to deploy universally in heterogeneous embedded systems.

[0006] Therefore, providing a method and system for upgrading a dual-slot system to solve the above problems is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0007] To address the aforementioned technical problems, this invention provides a dual-slot system upgrade method and system based on the separation of the running state and the pre-boot state, thereby overcoming the technical defects of existing technologies such as coupled responsibilities, firmware modification dependencies, imperfect rollback mechanisms, and insufficient versatility.

[0008] This invention achieves efficient, reliable, and universal firmware upgrades by constructing a dual-core system architecture of "fixed loader program" and "control plane file".

[0009] The system adopts a modular architecture, consisting of an upgrade management module, a bootloader module, and a health detection module. These modules work together to form a complete closed-loop system.

[0010] Specifically, this invention introduces an intelligent, fixed Loader program between the system's UEFI Bootloader and the operating system kernel. All upgrade decisions and boot logic are completed at this layer, which then drives the underlying UEFI firmware to complete the actual boot. By setting up two independent slots for each system and a control plane storage area independent of the slots, and storing manifest.xml and boot_config.xml in the control plane storage area respectively, the responsibilities of upgrade preparation and boot decision-making are separated. Simultaneously, by integrating boot timeout detection, health checks, and watchdog mechanisms, automatic detection and rollback of boot failures are achieved. Finally, the system generates a complete upgrade record, providing a data foundation for operation and maintenance.

[0011] Thus, this invention achieves a complete closed loop from upgrade preparation to startup decision and failure recovery, significantly improving the efficiency, reliability and automation level of firmware upgrades.

[0012] According to one aspect of the present invention, a dual-slot system upgrade method based on separation of the running state and the pre-startup state is provided, which includes the following steps: The running system writes the new firmware image to the spare slot in the two slots, updates the boot configuration information, updates the status of the spare slot to the pending boot state and sets the boot priority to be higher than the running slot in the two slots, and then triggers a system reset. After the system is reset, the bootloader reads the boot configuration information and selects the target boot slot according to the boot priority; The bootloader performs integrity verification on the firmware image in the target boot slot, and starts the firmware image after the verification is successful. The system uses a pre-defined health check mechanism to determine if the startup was successful. If successful, update the startup configuration information and change the status flag of the target startup slot to running status; If it fails, update the boot configuration information, update the status flag of the target boot slot to the failed state and increase the boot failure count of the target boot slot, then trigger the system reset, and the boot program will reread the updated boot configuration information and restart the firmware image with the other slot of the two slots as the target boot slot. Specifically, when the number of startup failures in the same slot reaches a preset threshold, the status flag of the same slot is updated to unavailable, and the slot that is not marked as unavailable among the two slots is used as the target startup slot.

[0013] Another aspect of the present invention provides a dual-slot system upgrade system based on the separation of the running state and the pre-startup state, comprising: Two slots are used to store firmware images; The control plane storage area, independent of the two slots, is used to store startup configuration information. The startup configuration information includes at least the status identifier and startup priority of each slot. The bootloader module is fixed and does not update with system upgrades. It is used to read the boot configuration information after system reset, select the target boot slot according to the boot priority, verify the integrity of the firmware image in the target boot slot, and start the firmware image after the verification is successful. The upgrade management module runs in the system of the currently running slot. It is used to write the new version firmware image to the backup slot, update the boot configuration information, update the status of the backup slot to the pending boot state and set the boot priority to be higher than the running slot among the two slots, and then trigger the system reset. The health detection module is used to determine whether the boot process was successful after the firmware image is started by using a preset health detection mechanism. Upon successful startup, the upgrade management module updates the startup configuration information and changes the status flag of the target startup slot to running status. When the bootloader module fails to boot, it updates the boot configuration information, updates the status flag of the target boot slot to the failed state and increments the boot failure count of the target boot slot, then triggers a system reset, rereads the updated boot configuration information, and restarts the firmware image with the other of the two slots as the target boot slot. Specifically, when the number of startup failures in the same slot reaches a preset threshold, the bootloader module updates the status flag of the same slot to unavailable and selects the slot that is not marked as unavailable as the target startup slot.

[0014] Compared with the prior art, the present invention has the following beneficial effects: Separation of duties and enhanced security: The separation of duties between the runtime state and the pre-startup stage is achieved. The runtime system is only responsible for preparing for the upgrade, and the pre-startup stage is only responsible for executing the startup. The runtime system does not directly determine the startup slot, thus eliminating the risk of single point of failure.

[0015] Firmware independence: The Loader program remains unchanged and is not modified during upgrades. All upgrade decisions are based on information in the control plane file, eliminating the need to modify the UEFI firmware and significantly reducing maintenance costs and compatibility risks.

[0016] High reliability: A robust startup failure detection and handling mechanism, with triple protection through startup timeout detection, health check and watchdog mechanism, enables automatic rollback after the first startup failure, and marks the device as invalid after consecutive failures reach a threshold, effectively preventing the device from becoming bricked.

[0017] Control information fault tolerance: Back up the critical boot_config.xml file to ensure the reliability of boot decision information and prevent the loss of boot decisions due to single point of failure.

[0018] State consistency guarantee: After rollback, the slot status flag is updated in a timely manner to ensure that the bootloader can always accurately identify the currently running slot and avoid startup decision errors caused by the lag in status flags.

[0019] High versatility: It does not depend on a specific platform framework, can be adapted to a variety of hardware platforms and operating systems, and is suitable for a variety of scenarios such as IoT devices, embedded devices, and server BMC. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This is a schematic diagram of the overall architecture of a dual-slot system upgrade system based on the separation of running state and pre-startup state provided in an embodiment of the present invention; Figure 2 This is a complete upgrade flowchart of a dual-slot system upgrade method based on separation of running state and pre-startup provided in an embodiment of the present invention, showing the complete process from upgrade package preparation, running state processing, pre-startup stage to running state confirmation; Figure 3 The flowchart for startup failure detection and processing provided in this embodiment of the invention details the complete processing flow from selecting the slot for Loader startup to rolling back after the first startup failure and marking consecutive failures as invalid. Detailed Implementation

[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0023] The embodiments of this invention are written in a progressive manner.

[0024] Terminology Explanation To facilitate understanding of the technical solution of this invention, some technical terms appearing in the specification are explained as follows: Slot: In embedded systems, a "slot" refers to an independent storage area for storing firmware images. A dual-slot design means that the system has two completely independent firmware storage areas, typically labeled Slot A and Slot B. At any given time, only one slot is the "running slot" (the slot where the currently running system resides), and the other is the "spare slot" (stored for newer versions that can be upgraded).

[0025] Control plane: The control plane is a separate storage area that stores upgrade-related metadata and status information, but does not contain the actual firmware code. The role of the control plane is to tell the system "which slot should be started" and "what the status of each slot is," etc.

[0026] Loader: The Loader is a small, unchanging program that runs in the early stages of system startup. It is responsible for reading control plane information, verifying firmware integrity, determining which slot to boot from, and performing the actual boot operations. The Loader itself is neither modified nor updated; its logic is fixed.

[0027] Runtime system: The runtime system refers to the operating system or firmware program that is currently running. It is responsible for performing the preparatory work for firmware upgrade, including downloading the upgrade package, writing the firmware image, and updating the control plane file.

[0028] UEFI (Unified Extensible Firmware Interface) is a standard specification that defines the interface between the operating system and platform firmware, used to replace the traditional BIOS, providing richer boot services and a more secure boot process. In this invention, UEFI serves as the underlying firmware, and the Loader runs on top of the UEFI environment.

[0029] BMC (Baseboard Management Controller): This refers to a dedicated microcontroller embedded on a server motherboard for remote monitoring and management of server hardware status, supporting out-of-band management functions. This invention is applicable to reliable upgrades of BMC firmware.

[0030] The terms used above are only for explaining specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Those skilled in the art will understand that other existing technologies with the same or similar functions can be employed without departing from the concept of the present invention.

[0031] Example 1: System Architecture like Figure 1 As shown, this invention provides a dual-slot system upgrade system based on the separation of runtime and pre-boot states. Its core lies in establishing an intelligent, fixed Loader program between the UEFI Bootloader and the operating system kernel. All upgrade decisions and boot logic are completed at this layer, which then drives the underlying UEFI firmware to complete the actual boot process. The system adopts a modular architecture, composed of multiple core components that work collaboratively to achieve a complete closed loop from upgrade preparation to boot decision-making and failure recovery.

[0032] "UEFI → Loader → Image" is the most mainstream and standard boot solution at present. Loader is a small program that runs in the UEFI environment and acts as a "bridge" between firmware and operating system kernel.

[0033] The overall system storage layout is as follows Figure 1 As shown, it includes: Bootloader (UEFI): The underlying firmware responsible for initializing the hardware and loading the Loader program after the system is powered on.

[0034] Loader (fixed): A small, fixed program that does not update with system upgrades. It is responsible for reading control plane information, verifying firmware integrity, determining the boot slot, and performing the boot operation.

[0035] System storage area: contains two slots (Slot A and Slot B) and control plane storage area.

[0036] System storage layout as follows Figure 1 As shown, it includes: Slot A: Used to store firmware images, either the currently running system or a new version.

[0037] Slot B: Used to store firmware images, either the currently running system or a new version.

[0038] Control plane storage area: Separate from the two slots, used to store control plane files, including the manifest.xml series of files and boot_config.xml.

[0039] Control plane file structure as follows Figure 1 As shown, it includes: The manifest.xml series (firmware description files) includes manifest_A.xml (Slot A firmware description) and manifest_B.xml (Slot B firmware description), used to describe the static metadata and verification information (derived from the upgrade package) of the firmware image. It includes firmware version, build time, component information, SHA256 checksum information, and upgrade strategy parameters (rollback count, timeout, etc.). It does not include slot selection or boot decision information.

[0040] boot_config.xml (boot configuration file): This file must be backed up. It records slot status and boot configuration information and is maintained by the runtime environment. It includes information such as the status of each slot (active / ready / inactive / invalid), boot priority, boot count, number of boot failures, and whether the last boot was successful. Determining which slot to boot from is crucial for boot decisions.

[0041] In this invention, the Loader remains fixed and is not modified during upgrades; the runtime state is separated from the pre-boot stage; the responsibilities of the control plane files are separated (manifest.xml and boot_config.xml are separated); and it has a complete startup failure detection and handling mechanism.

[0042] All components communicate through well-defined data interfaces, ensuring the system's scalability and stability.

[0043] Example 2: General Process like Figure 2 As shown, this invention provides a dual-slot system upgrade method based on the separation of the running state and the pre-startup state, including the following steps: S1: Upgrade preparation.

[0044] Firmware developers create an upgrade package (update.zip), which includes image.bin (upgrade image) and manifest.xml (firmware description and verification information). manifest.xml contains basic information such as firmware version and build time, SHA256 checksums of each component, overall image verification information, and upgrade strategy parameters (rollback count, timeout, etc.), but does not include boot slot decision information. The upgrade package is sent to the target device via OTA or other distribution methods.

[0045] The running system downloads and verifies the upgrade package, writes image.bin to the spare slot (Slot B), calculates the SHA256 of the image after writing and compares it with the verification information in manifest.xml. If they do not match, the upgrade is aborted.

[0046] The running system copies manifest.xml to manifest_B.xml and stores it in the control plane storage area, and updates boot_config.xml: sets the status of the standby slot (Slot B) to "ready", sets the startup priority to be higher than the currently running slot (Slot A), sets the maximum number of rollbacks, updates the backup file first and then the main file, and verifies the consistency between the main and standby files.

[0047] The running system triggers a system reset.

[0048] S2: Initiation decision and verification.

[0049] After the system is reset, the Loader reads boot_config.xml and selects the target boot slot (Slot B) based on the boot priority.

[0050] The loader reads manifest_B.xml, calculates the SHA256 of the actual image of Slot B, and compares it with the verification information in manifest_B.xml. If they do not match, it rolls back to Slot A; if they match, it loads the kernel and root file system of Slot B and starts the Slot B system.

[0051] S3: Startup successful.

[0052] After the system starts in Slot B, a health check is performed. If the check passes, the boot_config.xml file is updated: the status of Slot B is set to "active", the status of Slot A is set to "inactive", active_slot="B" is updated, the startup count is incremented, a successful startup is recorded, the backup file is updated first, and then the main file is updated.

[0053] Upgrade complete, new version system is running normally.

[0054] S4: Startup failure detection and handling.

[0055] After the Loader starts Slot B, it simultaneously starts a timeout timer (30 seconds) and a hardware watchdog (timeout period of 5 seconds), and executes a health check script to verify critical services.

[0056] If startup fails to complete within 30 seconds, the watchdog timeout occurs, or the health check fails, the startup is considered a failure. Update boot_config.xml: Set the Slot B status to "failed", increase the startup failure count for Slot B, and record the reason for failure and timestamp.

[0057] If the number of boot failures in Slot B does not reach the preset threshold, then next_boot_slot is set to the rollback slot (Slot A), triggering a system reset and returning to S2 to re-execute.

[0058] S5: Slot disabling.

[0059] When the number of startup failures in the same slot reaches a preset threshold, the status flag of that slot will be updated to "invalid" (unavailable).

[0060] The slot that is not marked as unavailable is selected as the target startup slot, triggering a system reset and returning to S2 to re-execute. If both slots are unavailable, the startup process is stopped and an error is reported.

[0061] Example 3: Startup Failure Detection and Handling Combination Figure 3 As shown, this invention provides a detailed description of the startup failure detection and handling process: After the loader selects a slot (e.g., Slot B), the system enters the startup monitoring state. The system loads the kernel and root file system, performs system initialization, and starts critical services. Simultaneously, a timeout timer (30 seconds) and a hardware watchdog (timeout period of 5 seconds) are started.

[0062] The startup result can be divided into the following two cases: Scenario A: System boots normally. The system completes boot within 30 seconds, executes and passes the health check script, performs periodic dog feeding (once per second), and runs normally. Solution: Update boot_config.xml, set last_boot_success=true, increase boot_count, and the upgrade process is complete.

[0063] Situation B: An exception occurred during startup. This includes the following three situations: (1) Startup timeout: If startup is not completed within 30 seconds, the timeout timer is triggered, which is considered a startup failure; (2) Watchdog timeout: If the watchdog is not fed in time, the watchdog is triggered to reset, which is considered a startup failure; (3) Health check failure: If a critical service is abnormal, the health check script returns a failure, which is considered a startup failure.

[0064] If startup fails, the following processing procedure will be executed: The system detects the cause of boot failure, reads `boot_config.xml`, and checks the number of boot failures in Slot B. It updates the boot failure count by incrementing `Slot B.boot_failure_count` and recording the reason for the failure and its timestamp. It then determines whether a rollback is needed: if `boot_failure_count >= max_rollback_attempts`, it sets `Slot B.status = "invalid"` to mark it as a permanent failure to prevent further attempts; otherwise, it sets `Slot B.status = "failed"`, sets `next_boot_slot = get_fallback_slot()`, and rolls back to a safe slot. Finally, it updates `boot_config.xml` (updating the backup first, then the main file), triggering a system reboot. The Loader then boots from the safe slot based on the new `next_boot_slot`.

[0065] The specific process for rolling back to a secure slot is as follows: The Loader reads boot_config.xml and obtains next_boot_slot = "A" (rolling back to Slot A); verifies the integrity of the Slot A firmware (reads manifest_A.xml and verifies the integrity of the Slot A image); starts the Slot A system (loads the Slot A kernel and root file system, performs system initialization, and the system runs normally); updates boot_config.xml (sets Slot A.status = "active", sets Slot A.last_boot_success = true, and increments Slot A.boot_count). The system successfully rolls back to the old version, the device resumes normal operation, and detailed rollback logs are recorded.

[0066] The startup failure handling strategies are summarized as follows: First launch failed (failed to launch the new version on the first attempt): Roll back to the old version; record the reason for failure; allow another upgrade attempt.

[0067] Consecutive failures (2-3 consecutive failures to launch the new version): Roll back to the old version; increase the failure count; limit the number of retry attempts.

[0068] Permanent failure (continuous failures reaching a threshold, such as 3 times): Mark the slot as invalid; prevent further attempts to the slot; manual intervention or re-upgrade is required.

[0069] Example 4: Exception Handling Process This invention provides a complete exception handling process, specifically including: Error type 1: Control plane file corrupted (boot_config.xml corrupted).

[0070] Detection: The Loader attempts to read boot_config.xml. If the reading or verification fails, an error log is logged.

[0071] Processing flow: (1) Try to restore from backup: Read boot_config.xml.bak, verify the validity of the backup file, and if valid, copy it as boot_config.xml; (2) If the backup is also corrupted: Rebuild boot_config.xml using the default template, with the default strategy being to start the last successfully booted slot and record a warning log; (3) Continue the boot process: Start the system according to the restored boot_config.xml and record a detailed recovery log.

[0072] Result: The system was able to start normally, preventing the device from becoming unusable, and detailed recovery logs were available to facilitate troubleshooting.

[0073] Error type 2: manifest.xml is corrupt (manifest_B.xml is corrupt).

[0074] Detection: The Loader attempts to read manifest_B.xml. If the reading or verification fails, a warning log is logged.

[0075] Processing flow: (1) Skip firmware integrity verification: Record the warning "manifest.xml is corrupt, skip integrity verification", which does not affect the boot decision; (2) Still boot the system according to boot_config.xml: boot_config.xml determines which slot to boot, and manifest.xml is only used for verification and is not a necessary condition for boot; (3) Post-boot processing: If the upgrade package cache exists, extract manifest.xml again; if it does not exist, record the error and wait for the next upgrade.

[0076] Result: The system was able to boot normally, firmware integrity verification was skipped (risky, but acceptable), and detailed warning logs were available to facilitate troubleshooting.

[0077] Anomaly type 3: Firmware image corrupted (Slot B image integrity verification failed).

[0078] Detection: The Loader reads manifest_B.xml, calculates the SHA256 of the actual image of Slot B, compares it with the verification information in manifest_B.xml, and records an error log if a mismatch is found.

[0079] Processing flow: (1) Mark Slot B as corrupted: Set Slot B.status = "corrupted"; (2) Roll back to a safe slot: Set next_boot_slot = get_fallback_slot(), usually Slot A; (3) Update boot_config.xml: Update the backup first, then update the main file, and record detailed error information; (4) Trigger system restart: The system restarts automatically, and the Loader starts the safe slot.

[0080] Result: To prevent booting from corrupted firmware, the system was rolled back to a secure version, and detailed error logs were provided to facilitate troubleshooting.

[0081] Anomaly type 4: Power failure.

[0082] Scenario A: Power outage during upgrade.

[0083] Detection: After the system restarts, the Loader reads boot_config.xml and finds that the upgrade status is inconsistent (e.g., Slot B.status="ready" but manifest_B.xml does not exist).

[0084] Processing flow: (1) Check upgrade progress: Check if the Slot B image is complete and check if manifest_B.xml exists; (2) Determine the processing strategy: If the Slot B image is complete and manifest_B.xml exists, set next_boot_slot = "B" (the upgrade is basically complete and you can try to start); otherwise, set next_boot_slot = get_fallback_slot() and set Slot B.status = "invalid" (the upgrade is not complete, roll back to the safe slot and mark it as invalid); (3) Update boot_config.xml and restart.

[0085] Scenario B: Power failure during startup.

[0086] Detection: After the system restarts, the Loader reads boot_config.xml and checks the last boot status (e.g., next_boot_slot="B" but Slot B.last_boot_success=false).

[0087] Processing flow: (1) Increase the boot failure count: Increase Slot B.boot_failure_count; (2) Determine if rollback is needed: If boot_failure_count>= max_rollback_attempts, set Slot B.status ="invalid" and set next_boot_slot = get_fallback_slot(); otherwise, set next_boot_slot = get_fallback_slot(); (3) Update boot_config.xml and restart.

[0088] Results: The system can automatically recover after a power failure. It decides whether to continue or roll back based on the upgrade progress. There are detailed recovery logs to facilitate troubleshooting.

[0089] One or more embodiments in this application are intended to cover all such substitutions, modifications, and variations that fall within the broad scope of this application. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments in this application should be included within the protection scope of this application.

[0090] If flowcharts are used in this application, they are used to illustrate the operations performed by the system according to embodiments of this application. It should be understood that the preceding or following operations are not necessarily performed in exact order. Instead, the steps can be processed in reverse order or simultaneously. Furthermore, other operations can be added to these flows, or one or more steps can be removed from these flows.

[0091] The above provides a detailed description of a dual-slot system upgrade method and system provided in this application. The above description of the disclosed embodiments enables those skilled in the art to implement or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A dual-slot system upgrade method, applied to a system comprising two slots, a control plane storage area, and a bootloader, wherein the two slots are used to store firmware images, the control plane storage area is independent of the two slots and is used to store boot configuration information, the bootloader is a fixed program module, and the boot configuration information includes at least the status identifier and boot priority of each slot, characterized in that, The running system writes the new firmware image to the spare slot of the two slots, updates the boot configuration information, updates the status flag of the spare slot to the pending boot state, sets the boot priority to be higher than the running slot of the two slots, and then triggers a system reset; the running system updates the backup file and the main file of the boot configuration information, the backup file is a copy of the main file, and verifies the consistency between the backup file and the main file; If they match, the update is complete; if they do not match, the update is re-executed. After the system is reset, the bootloader reads the boot configuration information and selects a target boot slot according to the boot priority. If the bootloader fails to read the boot configuration information, it restores the boot configuration information from the backup file. If the backup file also cannot be read, the boot configuration information is rebuilt using a default template, and the default strategy of the default template is to boot from the last successfully booted slot. The control plane storage area also stores a description file, which records the verification information of the firmware image and upgrade strategy parameters. The description file is obtained by the running system from the upgrade package and stored in the control plane storage area; the description file does not contain slot selection or startup decision information. The bootloader reads the verification information recorded in the description file, calculates the verification value of the firmware image in the target boot slot, and compares the calculated verification value with the verification information recorded in the description file. If the two match, the verification is successful, and the firmware image is started after the verification is successful. When the bootloader cannot read the description file, it skips the integrity verification of the firmware image in the target boot slot, records a warning log, and continues to boot the firmware image. The startup success is determined by a preset health check mechanism, which includes the following methods: Startup timeout detection: the startup time starts from the firmware image started by the boot program, and if the startup fails to complete within the preset time, it is determined to be a startup failure; Service health check: after startup, a health check script is executed to check whether the services and hardware are running normally. If the check fails, it is determined to be a startup failure; Watchdog detection: the hardware watchdog is started and a reset signal is sent to the watchdog periodically. If the watchdog timeout triggers a reset, it is determined to be a startup failure. If successful, update the startup configuration information and change the status identifier of the target startup slot to running status; If it fails, the boot configuration information is updated, the status identifier of the target boot slot is updated to the failed state and the boot failure count of the target boot slot is increased, and then the system is reset. The boot program rereads the updated boot configuration information and restarts the firmware image with the other slot of the two slots as the target boot slot. After restarting the firmware image by using the other of the two slots as the target boot slot, the status flag of the target boot slot is updated to running status; Specifically, when the number of startup failures in the same slot reaches a preset threshold, the status identifier of the same slot is updated to unavailable, and the slot that is not marked as unavailable is used as the target startup slot; when both slots are marked as unavailable, the startup process is stopped and an error is reported. The startup failure handling strategy includes: when the startup fails for the first time, roll back to the original running slot and allow the upgrade to be attempted again; when startup fails continuously but the number of times does not reach a preset threshold, roll back to the original running slot and limit the number of times the upgrade can be attempted again; when startup fails continuously and the number of times reaches a preset threshold, mark the corresponding slot as unavailable and wait for manual intervention. When the system restarts after a power outage during the upgrade process, the bootloader checks whether the firmware image in the spare slot is complete and whether the description file exists. If the firmware image is complete and the description file exists, the spare slot is used as the target boot slot to attempt booting. Otherwise, the system rolls back to the original running slot and updates the status flag of the spare slot to unavailable. When the bootloader performs integrity verification on the firmware image in the target boot slot, and the calculated verification value is inconsistent with the verification information recorded in the description file, the status identifier of the target boot slot is updated to unavailable, and the other slot of the two slots is used as the target boot slot to restart the firmware image.

2. A dual-slot system upgrade system, characterized in that, include: Two slots are used to store firmware images; The control plane storage area, independent of the two slots, is used to store startup configuration information, which includes at least the status identifier and startup priority of each slot. The control plane storage area also stores a description file, which records the verification information of the firmware image and upgrade strategy parameters. The description file does not contain slot selection or startup decision information. The bootloader module is fixed and does not update with system upgrades. It is used to read the boot configuration information after system reset, select the target boot slot according to the boot priority, read the verification information recorded in the description file, calculate the verification value of the firmware image in the target boot slot, and compare the calculated verification value with the verification information recorded in the description file. If the two are consistent, the verification is successful. After the verification is successful, the firmware image is started. When the bootloader module cannot read the description file, it skips the integrity verification of the firmware image in the target boot slot, records a warning log, and continues to boot the firmware image. The upgrade management module runs in the system of the currently running slot. It is used to write the new version firmware image to the backup slot, obtain the description file from the upgrade package and store it in the control plane storage area, update the startup configuration information, update the status identifier of the backup slot to the pending startup state and set the startup priority to be higher than the running slot of the two slots, and then trigger the system reset. The upgrade management module updates the backup file and the main file of the startup configuration information. The backup file is a copy of the main file, and verifies the consistency between the backup file and the main file. If they match, the update is complete; if they do not match, the update is re-executed. When the bootloader module fails to read the boot configuration information, it restores the boot configuration information from the backup file of the boot configuration information; when the backup file also cannot be read, it rebuilds the boot configuration information using a default template, the default strategy of which is to boot the last successfully booted slot. A health detection module is used to determine whether the firmware image has started successfully or failed through a preset health detection mechanism. The health detection mechanism includes the following methods: Startup timeout detection: starting from the bootloader module starting the firmware image, if the startup fails to complete within a preset time, it is determined to be a startup failure; Service health check: after startup, a health check script is executed to check whether the services and hardware are running normally. If the check fails, it is determined to be a startup failure; Watchdog detection: a hardware watchdog is started and a reset signal is sent to the watchdog periodically. If the watchdog times out and triggers a reset, it is determined to be a startup failure. Upon successful startup, the upgrade management module updates the startup configuration information and changes the status identifier of the target startup slot to the running status. When the bootloader module fails to boot, it updates the boot configuration information, updates the status identifier of the target boot slot to the failed state and increases the boot failure count of the target boot slot, then triggers a system reset, rereads the updated boot configuration information, and restarts the firmware image with the other of the two slots as the target boot slot. After restarting the firmware image by using the other of the two slots as the target boot slot, the status flag of the target boot slot is updated to running status; When the number of startup failures in the same slot reaches a preset threshold, the bootloader module updates the status flag of the same slot to unavailable and uses the slot that is not marked as unavailable as the target startup slot; when both slots are marked as unavailable, the bootloader module stops the startup process and reports an error. The startup failure handling strategy includes: when the startup fails for the first time, roll back to the original running slot and allow the upgrade to be attempted again; when startup fails continuously but the number of times does not reach a preset threshold, roll back to the original running slot and limit the number of times the upgrade can be attempted again; when startup fails continuously and the number of times reaches a preset threshold, mark the corresponding slot as unavailable and wait for manual intervention. When the system restarts after a power outage during the upgrade process, the bootloader module checks whether the firmware image in the spare slot is complete and whether the description file exists. If the firmware image is complete and the description file exists, the spare slot is used as the target boot slot to attempt booting. Otherwise, the system rolls back to the original running slot and updates the status flag of the spare slot to unavailable. When the bootloader module performs integrity verification on the firmware image in the target boot slot, and the calculated verification value is inconsistent with the verification information recorded in the description file, the bootloader module updates the status flag of the target boot slot to an unavailable state, and restarts the firmware image using the other slot of the two slots as the target boot slot.