Firmware refreshing method and device, electronic equipment and storage medium

By dynamically determining the target management mode and the communication connection with the baseboard management controller, the adaptability problem of BIOS firmware updates is solved, enabling flexible and reliable firmware update operations, adapting to diverse device environments and hardware platforms, and improving operation and maintenance efficiency and security.

CN121785626APending Publication Date: 2026-04-03NINGCHANG INFORMATION TECH (HANGZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-17
Publication Date
2026-04-03

Smart Images

  • Figure CN121785626A_ABST
    Figure CN121785626A_ABST
Patent Text Reader

Abstract

The invention provides a firmware refreshing method and device, electronic equipment and a storage medium. The method comprises the steps that connection parameters are acquired; determining a target management mode of the current firmware refreshing operation environment according to the connection parameters; executing a communication connection process corresponding to the target management mode to establish a session with the substrate management controller and trigger a firmware update task; before the firmware updating task is executed, a control strategy corresponding to the target management mode is called to control the target equipment, so that the target equipment meets an execution condition required by the firmware updating task; and in the process of executing the firmware updating task, if a preset management operation needs to be executed, determining a target management strategy based on the hardware environment of the target equipment, and executing the preset management operation according to the target management strategy so as to complete a specified interaction operation for the hardware of the target equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer system management technology, and in particular to a firmware flashing method, apparatus, electronic device, and storage medium. Background Technology

[0002] The Basic Input / Output System (BIOS) is the core firmware on a computer motherboard, responsible for initializing hardware, performing the Power-On Self-Test (POST), and booting the operating system during startup. With the rapid evolution of computer hardware architecture and the continuous emergence of new peripherals, regular BIOS firmware updates have become a necessary technical means to ensure hardware compatibility, system stability, and to patch security vulnerabilities.

[0003] In the prior art, BIOS firmware updates typically rely on pre-configured dedicated tools. These tools complete firmware image transfer and update operations through a fixed execution process: after identifying the target device, the tool establishes a communication channel according to a preset connection method, and then performs firmware transfer, verification, and update command issuance operations in a predetermined order. During this process, the device status coordination and hardware interaction required are all achieved through a predefined command sequence.

[0004] However, the existing technology, based on a fixed process, lacks the necessary adaptability and flexibility when faced with diverse device environments, connection methods, and hardware platforms. Summary of the Invention

[0005] This application provides a firmware flashing method, apparatus, electronic device, and storage medium to solve the problem that the existing fixed-process execution method lacks the necessary adaptability and flexibility when facing diverse device environments, connection methods, and hardware platforms.

[0006] Firstly, this application provides a firmware flashing method, including: Obtain connection parameters, wherein the connection parameters are parameters related to the baseboard management controller of the target device; Based on the connection parameters, determine the target management mode of the current firmware refresh operation environment; Execute the communication connection process corresponding to the target management mode to establish a session with the baseboard management controller and trigger a firmware update task; Before executing the firmware update task, the control policy corresponding to the target management mode is invoked to control the target device so that the target device meets the execution conditions required by the firmware update task. During the firmware update task, if a preset management operation is required, a target management strategy is determined based on the hardware environment of the target device, and the preset management operation is executed according to the target management strategy to complete the specified interactive operation for the target device hardware.

[0007] This results in a closed-loop control scheme that can be dynamically adjusted according to actual operating conditions. While maintaining a unified architecture, it effectively adapts to diverse device environments, connection methods, and hardware platforms, significantly improving the flexibility and reliability of firmware update operations.

[0008] In one possible implementation, determining the target management mode of the current firmware flashing operation environment based on the connection parameters includes: If the connection parameters do not include the network address information of the baseboard management controller, then the target management mode of the current firmware refresh operation environment is determined to be the in-band management mode. If the connection parameters include the network address information of the baseboard management controller, then the target management mode of the current firmware refresh operation environment is determined to be out-of-band management mode.

[0009] This implementation provides a clear and efficient judgment criterion. It only needs to check whether the parameters contain the network address of the management controller to automatically select the most suitable operation and maintenance management mode, which lays a solid foundation for subsequent differentiated processing and enhances the adaptability of the solution.

[0010] In one possible implementation, the execution of the communication connection process corresponding to the target management mode includes: When the target management mode is in-band management mode, enable and configure the local virtual network interface on the target device; A local communication session with the baseboard management controller is established through the local virtual network interface; The firmware image file is transmitted to the baseboard management controller via the local communication session, and the baseboard management controller is triggered to perform integrity verification on the firmware image file. After successful verification, a firmware update command is sent to the baseboard management controller via the local communication session to trigger the firmware update task.

[0011] This implementation defines a secure local connection and task triggering mechanism for the internal management mode of the system. By automatically configuring virtual network cards to establish communication channels, it ensures that firmware updates can be reliably started and completed even in environments without a dedicated management network, thus expanding the applicable scenarios of the tool.

[0012] In one possible implementation, the execution of the communication connection process corresponding to the target management mode includes: When the target management mode is the out-of-band management mode, a remote network session with the baseboard management controller is established using the network address information; The firmware image file is uploaded to the baseboard management controller via the remote network session, and the baseboard management controller is triggered to perform integrity verification on the firmware image file. After successful verification, a firmware update command is sent to the baseboard management controller via the remote network session to trigger the firmware update task.

[0013] This implementation method clarifies the standard remote management mode process, which interacts directly with the management controller via the network to realize the remote uploading of firmware packages and the issuance of update commands, thus meeting the needs of centralized and remote maintenance of equipment and greatly improving operation and maintenance efficiency.

[0014] In one possible implementation, the step of invoking the control policy corresponding to the target management mode to control the target device includes: If no preset automated operation flag is detected, generate and output a prompt message to confirm the power state switch; Receive confirmation instructions from the user based on the prompt information; Based on the confirmation command, a power control operation is performed on the target device.

[0015] This implementation method introduces a user interaction confirmation mechanism to proactively solicit user opinions before performing critical operations, effectively preventing unexpected system interruptions caused by misjudgments in automated processes, providing an important safety barrier for the operation process, and enhancing controllability.

[0016] In one possible implementation, the step of invoking the control policy corresponding to the target management mode to control the target device includes: When the target management mode is out-of-band management mode and a preset automated operation flag is detected, a power-off command is sent to the target device through the remote management interface of the baseboard management controller so that the target device enters a power-off state that meets the execution conditions of the firmware update task. After the firmware update task is detected to be completed, a power-on command is sent to the target device through the remote management interface to restore the target device to normal operation.

[0017] This implementation method achieves fully automated power management from preparation to recovery in remote management scenarios. It can complete shutdown, refresh and power-on operations without manual intervention, which not only meets the hard requirements for firmware updates, but also greatly improves operation and maintenance efficiency and supports unattended operation.

[0018] In one possible implementation, determining the target management strategy based on the hardware environment of the target device includes: Iterate through multiple candidate strategies in a preset order; During the traversal, for the currently accessed candidate strategy, the test command corresponding to the candidate strategy is executed; If the test command is successfully executed, the traversal process is terminated, and the candidate strategy is determined as the target management strategy.

[0019] This implementation method automatically traverses and tests the preset command set, dynamically identifying the only control command that the current hardware can respond to. This fundamentally solves the problem of incompatibility between commands from different manufacturers' devices, greatly enhancing the success rate and universality of the flashing tool in mixed hardware environments.

[0020] Secondly, this application provides a firmware flashing device, comprising: An acquisition module is used to acquire connection parameters, wherein the connection parameters are parameters related to the baseboard management controller of the target device; The determination module is used to determine the target management mode of the current firmware refresh operation environment based on the connection parameters. The first execution module is used to execute the communication connection process corresponding to the target management mode, so as to establish a session with the baseboard management controller and trigger a firmware update task; The calling module is used to call the control policy corresponding to the target management mode to control the target device before executing the firmware update task, so that the target device meets the execution conditions required by the firmware update task; The second execution module is used to determine a target management strategy based on the hardware environment of the target device if a preset management operation needs to be performed during the execution of the firmware update task, and to execute the preset management operation according to the target management strategy to complete the specified interactive operation for the hardware of the target device.

[0021] In one possible implementation, the determining module is specifically used for: If the connection parameters do not include the network address information of the baseboard management controller, then the target management mode of the current firmware refresh operation environment is determined to be the in-band management mode. If the connection parameters include the network address information of the baseboard management controller, then the target management mode of the current firmware refresh operation environment is determined to be out-of-band management mode.

[0022] In one possible implementation, the first execution module is specifically used for: When the target management mode is in-band management mode, enable and configure the local virtual network interface on the target device; A local communication session with the baseboard management controller is established through the local virtual network interface; The firmware image file is transmitted to the baseboard management controller via the local communication session, and the baseboard management controller is triggered to perform integrity verification on the firmware image file. After successful verification, a firmware update command is sent to the baseboard management controller via the local communication session to trigger the firmware update task.

[0023] In one possible implementation, the first execution module is further configured to: When the target management mode is the out-of-band management mode, a remote network session with the baseboard management controller is established using the network address information; The firmware image file is uploaded to the baseboard management controller via the remote network session, and the baseboard management controller is triggered to perform integrity verification on the firmware image file. After successful verification, a firmware update command is sent to the baseboard management controller via the remote network session to trigger the firmware update task.

[0024] In one possible implementation, the calling module is specifically used for: If no preset automated operation flag is detected, generate and output a prompt message to confirm the power state switch; Receive confirmation instructions from the user based on the prompt information; Based on the confirmation command, a power control operation is performed on the target device.

[0025] In one possible implementation, the calling module is further configured to: When the target management mode is out-of-band management mode and a preset automated operation flag is detected, a power-off command is sent to the target device through the remote management interface of the baseboard management controller so that the target device enters a power-off state that meets the execution conditions of the firmware update task. After the firmware update task is detected to be completed, a power-on command is sent to the target device through the remote management interface to restore the target device to normal operation.

[0026] In one possible implementation, the second execution module is specifically used for: Iterate through multiple candidate strategies in a preset order; During the traversal, for the currently accessed candidate strategy, the test command corresponding to the candidate strategy is executed; If the test command is successfully executed, the traversal process is terminated, and the candidate strategy is determined as the target management strategy.

[0027] Thirdly, this application provides an apparatus comprising: a processor and a memory, the processor being configured to execute a firmware flashing program stored in the memory to implement the firmware flashing method described in any one of the first aspects.

[0028] Fourthly, this application provides a storage medium storing one or more programs that can be executed by one or more processors to implement the firmware flashing method described in any one aspect.

[0029] Compared with the prior art, the technical solution provided in this application has the following advantages: Firstly, based on intelligent parsing of connection parameters, the method automatically identifies and adapts to different operating environments, achieving autonomous selection of connection modes. Secondly, by establishing an adaptive communication connection with the baseboard management controller, the reliability of firmware data transmission is ensured. Thirdly, when the device state is detected as not meeting the execution conditions, the system can invoke the corresponding control strategy according to the identified management mode, enabling the device to reach the state required for firmware updates. Especially when hardware interaction operations are required, the system achieves autonomous compatibility with heterogeneous hardware platforms by dynamically determining the management strategy based on the hardware environment. This forms a closed-loop control scheme that can dynamically adjust according to actual operating conditions, thereby achieving effective adaptation to diverse device environments, connection methods, and hardware platforms while maintaining a unified architecture, significantly improving the flexibility and reliability of firmware update operations. Attached Figure Description

[0030] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0031] 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, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0032] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0033] Figure 1 A flowchart illustrating an embodiment of a firmware flashing method provided in this application; Figure 2 A flowchart illustrating another firmware flashing method provided in this application; Figure 3 A flowchart illustrating another embodiment of the firmware flashing method provided in this application; Figure 4 A flowchart illustrating another embodiment of the firmware flashing method provided in this application; Figure 5 A schematic diagram illustrating the generation process of a lightweight executable program provided in an embodiment of this application; Figure 6 This application provides an overall workflow diagram of a firmware flashing method according to an embodiment of the present application. Figure 7 A schematic diagram of a hierarchical architecture for IPMI instructions provided in an embodiment of this application; Figure 8 A block diagram illustrating an embodiment of a firmware flashing device provided in this application; Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0034] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0035] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0036] To address the technical problem that existing technologies based on fixed processes lack the necessary adaptability and flexibility when facing diverse device environments, connection methods, and hardware platforms, this application provides a firmware update method that can effectively adapt to diverse device environments, connection methods, and hardware platforms while maintaining a unified architecture, significantly improving the flexibility and reliability of firmware update operations.

[0037] In some preferred embodiments, the firmware flashing method provided in this application is implemented by a lightweight executable program. The program is generated by: compiling Python source code into a platform-specific dynamic link library (.so file on Linux, .pyd file on Windows) using the Cython tool to improve execution efficiency and protect the source code; and then integrating the compiled dynamic library, Python interpreter, third-party tools (such as ipmitool), and configuration files into a single executable file (ELF file on Linux / macOS, .exe file on Windows) using the PyInstaller packaging tool, thereby enabling direct deployment and execution on the target machine without pre-installing a Python environment.

[0038] Figure 1 This is a flowchart illustrating an embodiment of a firmware flashing method provided in this application. Figure 1 As shown, the method includes the following steps: Step 101: Obtain connection parameters, wherein the connection parameters are parameters related to the baseboard management controller of the target device.

[0039] The target device refers to the computing device that needs a firmware update. It includes the BMC (Baseboard Management Controller) and the firmware storage unit to be updated, such as servers, workstations and other embedded computing devices.

[0040] Connection parameters: These refer to the set of configuration information required to establish a communication session with the baseboard management controller of the target device, including network address, authentication credentials, and communication protocol parameters. Authentication credentials may include username, password, key, or digital certificate; communication protocol parameters may specify the specific protocol version, encryption algorithm, port number, and timeout settings.

[0041] In this embodiment, a parameter acquisition module receives and parses the input configuration data to obtain the connection parameters required for communication with the target device's BMC. This parameter acquisition module supports extracting parameter information from structured configuration files or program call interfaces, including network addresses, authentication credentials, and communication protocol parameters. These parameters provide the necessary input basis for subsequent operation mode determination and communication connection establishment.

[0042] The parameter acquisition module supports multiple configuration sources, including but not limited to: JSON / YAML configuration files, environment variables, command-line arguments, key management systems, or configuration services. The module has built-in parameter validation logic to ensure that the acquired parameters are in the correct format and have valid values.

[0043] Step 102: Determine the target management mode of the current firmware refresh operation environment based on the connection parameters.

[0044] Firmware update operating environment refers to the combination of software and hardware environment in which the firmware update task is performed, including elements such as operating system type, system architecture, available communication interfaces and network configuration.

[0045] Target management mode refers to the firmware refresh operation environment type dynamically selected based on connection parameters, including in-band management mode and out-of-band management mode.

[0046] In this embodiment of the application, the connection parameters are analyzed by the mode judgment module. Based on whether the parameters contain specific network address information required for remote management, the applicable target management mode is automatically distinguished and determined.

[0047] Specifically, step 102 may include the following steps: if the connection parameters do not contain the network address information of the baseboard management controller, then the target management mode of the current firmware refresh operation environment is determined to be in-band management mode; if the connection parameters contain the network address information of the baseboard management controller, then the target management mode of the current firmware refresh operation environment is determined to be out-of-band management mode.

[0048] Network address information: refers to the logical address that can uniquely identify the BMC through network protocols, including but not limited to IPv4 addresses, IPv6 addresses, or Fully Qualified Domain Names (FQDNs). In-band management mode: refers to the management method that establishes a communication connection with the BMC through a local interface provided by the target device's main operating system. Out-of-band management mode: refers to the management method that establishes a communication connection with the BMC through a remote network path independent of the target device's main operating system.

[0049] This solution parses the connection parameters through a mode judgment module. Specifically, it first checks whether a valid BMC network address exists in the connection parameter set. If the parameters do not contain such network address information, the current environment is determined to meet the characteristics of in-band management mode. In this case, the system will prepare to communicate with the BMC through the local interface provided by the operating system kernel (such as the USB (Universal Serial Bus) virtual network card driver or PCIe (Peripheral Component Interconnect Express) configuration space). Conversely, if the parameters contain valid BMC network address information, the current environment is determined to meet the characteristics of out-of-band management mode. The system will prepare to establish a communication session with the BMC through a remote network protocol stack (such as the TCP / IP (Transmission Control Protocol / Internet Protocol) stack).

[0050] This judgment process is implemented through a parameter validation submodule and conditional branching logic. The parameter validation submodule is responsible for performing compliance checks on the network address format to ensure the validity of the address information. Specifically, the parameter validation submodule uses regular expressions to match the IP address format and can query and verify the FQDN (Fully Qualified Domain Name) via optional DNS (Domain Name System). After determining the in-band mode, the module will further attempt to load necessary kernel modules (such as usbnet, igb) or check the existence of specific device files (such as / dev / ipmi0) to confirm that the in-band path is actually available.

[0051] In addition, the pattern judgment module's parsing process also includes in-depth verification of network address validity, such as performing Ping tests, DNS resolution verification, or port connectivity checks (e.g., checking whether IPMI port 623 is open), to avoid misjudgments caused by network configuration errors or BMC unreachability.

[0052] Through this automatic identification mechanism, the system can autonomously adapt to different device connection environments without requiring users to manually specify the operating mode. This avoids connection failures caused by incorrect mode selection and significantly reduces the complexity of user operations, laying an accurate environmental awareness foundation for subsequent differentiated communication connection processes.

[0053] Step 103: Execute the communication connection process corresponding to the target management mode to establish a session with the baseboard management controller and trigger a firmware update task.

[0054] The communication connection process refers to the process of establishing differentiated communication with the BMC based on the determined target management model.

[0055] A firmware update task refers to an independent execution unit created by the baseboard management controller. This task carries the firmware image data to be updated, update configuration parameters, and execution status information, and is queued within the controller for scheduling and execution. A firmware update task typically includes attributes such as task ID, firmware image storage path, update target (e.g., BIOS (Basic Input / Output System), BMC itself), refresh strategy (e.g., forced update, update after verification), and task priority.

[0056] In this embodiment, the connection execution module selects the corresponding communication establishment method according to the determined target management mode. In the local system interface-based management mode, a local virtual network interface is configured and a local communication session is established to connect to the BMC; in the remote network protocol-based management mode, a remote management session is established directly through the network protocol stack. After successfully establishing a session with the BMC, the complete firmware image file is transferred to the BMC's temporary storage area via the firmware transfer module, and a formatted update command is sent to the BMC through the session. Upon receiving the command, the BMC does not immediately perform a flashing operation, but first creates a corresponding firmware update task in its internal task manager. Once created, this task is in a "triggered" or "pending execution" state, and the BMC manages its lifecycle (e.g., queuing, scheduling, execution status updates, etc.). The program can asynchronously monitor the update process by polling the task's status.

[0057] In applications, the firmware transfer module employs a block-based transfer (splitting the firmware file into fixed-size data blocks and sending them sequentially) and a verification and retransmission mechanism for large file transfer scenarios (attaching verification information to each data block, triggering retransmission when the receiver fails verification). Through block-level reliability assurance, it avoids overall transfer failures due to network fluctuations or data corruption, ensuring the integrity and stability of large file transfers. During transmission, the module calculates and visualizes the transmission progress in real time (e.g., percentage, estimated remaining time), allowing users to intuitively understand the transmission status and judge the operation pace, and promptly detect anomalies such as transmission stalls, reducing erroneous operations caused by information opacity (e.g., repeated transmission triggers), thus improving the user experience and operational efficiency. When an update command is triggered, a checksum (e.g., MD5 or SHA256 hash value) generated in the BMC temporary storage area is simultaneously carried, allowing the BMC to perform secondary verification of the image file before executing the update. This mechanism effectively avoids firmware file inconsistencies caused by data tampering, corruption, or storage area anomalies during transmission, ensuring the integrity and reliability of the update file from the underlying layer.

[0058] Step 104: Before executing the firmware update task, invoke the control policy corresponding to the target management mode to control the target device so that the target device meets the execution conditions required by the firmware update task.

[0059] Execution conditions typically refer to the target device being in a power-off state.

[0060] Control strategy refers to a set of equipment state coordination methods corresponding to the target management model.

[0061] In this embodiment, a status detection module determines whether the current state of the target device meets the firmware update execution conditions. Accordingly, the process is divided into two branches: if the device state meets the execution conditions (e.g., it is in a powered-off state), no power control is required, and the firmware update task can be directly prepared for execution. If the device state does not meet the requirements (e.g., it is in a powered-on state), the strategy execution module is invoked to select the corresponding control strategy based on the determined target management mode. This strategy execution module supports sending status control commands to the target device through the device management interface, enabling the device to enter a ready state that meets the firmware update requirements. Specific implementations include, but are not limited to, performing a device shutdown operation through a remote management interface (in out-of-band mode) or local system tools (in in-band mode).

[0062] In applications, the status detection module can determine the status by querying the BMC's power status sensors (such as the IPMI (Intelligent Platform Management Interface) Chassis Status command) or by attempting to communicate with the host operating system. In in-band mode, it can also assist in determining whether the host is active by checking / proc / mounts or using commands such as systemctl is-active.

[0063] Step 105: During the execution of the firmware update task, if a preset management operation needs to be performed, a target management strategy is determined based on the hardware environment of the target device, and the preset management operation is executed according to the target management strategy to complete the specified interactive operation for the hardware of the target device.

[0064] Preset management operations refer to hardware interaction operations that require execution via IPMI's vendor-defined instructions (OEM Instructions). For example, before flashing the microcode of a specific CPU (Central Processing Unit), the CPU SKU (Stock Keeping Unit) information must be read and compatibility verification completed; when configuring a USB virtual network interface, its MAC (Media Access Control) address and VLAN (Virtual Local Area Network) ID parameters must be specified; before flashing the BMC firmware, specific entries in the SEL (System Event Log) may need to be cleared to avoid conflicts during the update process.

[0065] Specified interactive operations refer to the specific hardware access behaviors necessary to complete preset management operations, including but not limited to: performing deep verification on a specific CPU model, configuring parameters of a USB virtual network interface (such as a USB0 network card), and reading or clearing vendor-specific event logs.

[0066] In this embodiment, an operation judgment module detects whether the aforementioned preset management operation needs to be performed during the firmware update process. When it is required, the startup policy adaptation module determines the applicable target management policy from multiple preset candidate management policies based on the hardware environment characteristics of the target device (such as device manufacturer, model, and BMC firmware version). This policy adaptation module verifies the policy by executing test commands to select management policies compatible with the current hardware environment. After determining the target management policy, the operation execution module calls the corresponding IPMI OEM instructions to complete the specified interactive operation for the target device hardware.

[0067] The technical solution provided in this application firstly automatically identifies and adapts to different operating environments based on intelligent parsing of connection parameters, realizing autonomous selection of connection modes; then, by establishing an adaptive communication connection with the baseboard management controller, the reliability of firmware data transmission is ensured; when the device state is detected as not meeting the execution conditions, the system can invoke the corresponding control strategy according to the identified management mode, enabling the device to reach the state required for firmware update; especially when hardware interaction operations are required, autonomous compatibility with heterogeneous hardware platforms is achieved by dynamically determining the management strategy based on the hardware environment. This forms a closed-loop control scheme that can dynamically adjust according to actual operating conditions, thereby achieving effective adaptation to diverse device environments, connection methods, and hardware platforms while maintaining a unified architecture, significantly improving the flexibility and reliability of firmware update operations.

[0068] Figure 2 A flowchart illustrating an embodiment of another firmware flashing method provided in this application. Figure 2 The process shown is in Figure 1 Based on the illustrated process, the following steps are included: Step 201: When the target management mode is in-band management mode, enable and configure the local virtual network interface on the target device.

[0069] The local virtual network interface refers to a logical network device implemented through virtualization technology provided by the host operating system. This device establishes a data link layer connection with the baseboard management controller through a physical bus.

[0070] In this embodiment, this step is performed by the interface management module. This module first activates the dormant virtual network device using operating system commands (such as `ip link set dev usb0 up`) or system calls (such as `ioctl`). Then, it assigns a suitable network address to the interface based on a predefined configuration or a dynamic address allocation protocol (such as DHCP). Crucially, the configured IP address must be in the same IP subnet as the BMC's local management address to ensure link-layer reachability. If the BMC's default gateway differs from the host network, the interface management module will also add necessary static host routes. Step 202: Establish a local communication session with the baseboard management controller through the local virtual network interface.

[0071] Local communication sessions refer to transport layer communication connections established with the baseboard management controller via socket programming interfaces, supported by the operating system kernel, and are typically based on the TCP protocol.

[0072] In this embodiment, this step is performed by the session management module. This module uses the configured local virtual network interface as the source to initiate a TCP connection request to the BMC's management port (e.g., port 623 commonly used in the IPMI protocol). After the TCP three-way handshake is completed, the session management module completes the session activation and authentication process (e.g., RMCP+ handshake) according to the specifications of the selected management protocol (e.g., IPMI), and logs in using the authentication credentials obtained in step 101. This process is entirely performed through the host's internal data bus, without traversing the external physical network, thus providing higher security and isolation.

[0073] Step 203: Transmit the firmware image file to the baseboard management controller through the local communication session, and trigger the baseboard management controller to perform integrity verification on the firmware image file.

[0074] A firmware image file is a data file that contains complete firmware code and corresponding metadata. It follows a specific format specification and typically includes components such as a file header, firmware body data, checksum, and digital signature.

[0075] Integrity verification refers to the cryptographic verification process performed by the baseboard management controller on the received firmware image file, including but not limited to calculating the hash value using the SHA-256 algorithm and comparing it with the baseline value embedded in the file or pre-stored on the server, and may also include verification of the file's digital signature.

[0076] In this embodiment, this step is performed by the firmware transfer module. This module, through an established local communication session, uses IPMI's OEM file transfer commands or other standard interfaces supported by the BMC to transfer the firmware image file in blocks and in an orderly manner to the BMC's temporary storage area (such as a temporary Flash buffer). The transfer process employs a verification and retransmission mechanism to ensure data integrity. After the file transfer is complete, the firmware transfer module sends a specific "verification" command to the BMC, triggering the BMC to start its built-in firmware verification program. The program calculates the cryptographic hash value of the received file and compares it with a preset benchmark value to determine whether the firmware image is complete and trustworthy.

[0077] Step 204: After successful verification, a firmware update command is sent to the baseboard management controller through the local communication session to trigger the firmware update task.

[0078] Firmware update commands are control commands that conform to the baseboard management controller command interface specification and are used to trigger the firmware refresh process.

[0079] In this embodiment, this step is performed by a task triggering module. Upon receiving a status code indicating successful integrity verification from the BMC, the task triggering module sends a correctly formatted firmware update command to the BMC through a maintained local communication session. This command typically includes key parameters, such as the specific location of the firmware image in the temporary storage area, the target components to be updated (e.g., BIOS, BMC, CPLD, etc.), and update options (e.g., whether to force an update). Upon receiving this command, the BMC creates and queues a firmware update task in its internal task manager, and this task enters the "triggered" state.

[0080] Figure 2 The process shown establishes a stable and reliable local communication mechanism in the in-band environment through a standardized operating system network stack and device management interface. This ensures the data integrity of the firmware transmission process and avoids tedious manual operations through automated network configuration, significantly improving the efficiency and reliability of firmware flashing operations while reducing the risk of flashing failure due to network configuration errors.

[0081] Figure 3 A flowchart illustrating another embodiment of the firmware flashing method provided in this application. Figure 3 The process shown is in Figure 1 Based on the illustrated process, the following steps are included: Step 301: When the target management mode is the out-of-band management mode, establish a remote network session with the baseboard management controller using the network address information; Step 302: Upload the firmware image file to the baseboard management controller via the remote network session, and trigger the baseboard management controller to perform integrity verification on the firmware image file; Step 303: After successful verification, a firmware update command is sent to the baseboard management controller via the remote network session to trigger the firmware update task.

[0082] For ease of understanding, steps 301 to 303 are explained uniformly below: Remote network session refers to the network layer connection established between the target device and the baseboard management controller based on the TCP / IP protocol stack through the out-of-band management port of the target device.

[0083] Firmware update commands are control commands that conform to the baseboard management controller command interface specification and are used to trigger the firmware refresh process.

[0084] In this embodiment of the application, after determining that the target management mode is out-of-band management mode, the following specific operations are performed: First, a remote network session with the baseboard management controller is established based on the TCP / IP protocol using the network address information (including IP address and port number) in the connection parameters. The session establishment process employs a layered security mechanism: after establishing a basic connection through a TCP three-way handshake at the transport layer, the process proceeds to the security management layer for RMCP+ session negotiation. Authentication is completed using the authentication credentials (username, password, or digital certificate) in the connection parameters, and the session key and encryption algorithm are negotiated according to the security policy. Finally, IPMI session activation is completed at the application layer, establishing an end-to-end encrypted communication channel. This process ensures connection reliability through timeout retries and failover mechanisms.

[0085] Next, through the established remote network session, the firmware image file is uploaded to the designated storage area of ​​the baseboard management controller using a chunked transmission mechanism. Multiple safeguards are implemented during transmission: the firmware file is divided into fixed-size data blocks (typically 4KB-16KB), and a CRC32 checksum is appended to each block. Upon successful verification by the receiver, an acknowledgment signal is returned; otherwise, automatic retransmission is triggered. Simultaneously, the transmission progress is calculated and updated in real time to ensure visibility and interruptible recovery during large file transfers. After file transfer is complete, a specific verification command triggers the baseboard management controller to initiate the firmware verification program. The verification program performs a security-in-depth check: first, a strong cryptographic hash algorithm (such as SHA-256) is used to calculate the file hash value, which is compared with the benchmark value provided by the firmware publisher; second, the firmware's digital signature is verified to ensure the certificate chain is complete and the signature is valid; finally, the firmware version and hardware platform compatibility are checked to prevent incompatible firmware from being flashed.

[0086] Finally, upon receiving a successful verification response, a firmware update command conforming to the instruction format requirements is sent to the baseboard management controller via the maintained remote network session. This command employs a parameterized design, including key parameters such as the firmware image storage path, target component identifier, update strategy (forced update / verified update), power management options, and timeout settings. After parsing the instruction, the baseboard management controller immediately creates a firmware update task in the task scheduler, assigns a task ID, updates the task status to "pending execution," and simultaneously returns a confirmation message indicating successful task creation, thus completing the firmware update task triggering process.

[0087] Figure 3 The process shown establishes a reliable remote update channel in an out-of-band management environment through a standardized network communication protocol. This ensures data integrity during firmware transmission and enables firmware updates that are completely independent of the host operating system. It is particularly suitable for remote batch maintenance scenarios in data center environments, significantly improving the deployment efficiency and ease of maintenance of firmware refresh operations.

[0088] After the firmware update task is triggered, in order to achieve precise control over the target device's status, step 104 provides the following two power control strategies based on different operating modes and user configurations: The first strategy is interactive control, which includes: generating and outputting a prompt message to confirm the power state switch when no preset automation operation flag is detected; receiving a confirmation command from the user based on the prompt message; and performing power control operations on the target device based on the confirmation command.

[0089] Automation operation flags are Boolean variables preset in program configuration or command-line parameters, used to indicate whether a fully automatic execution mode without human intervention is enabled. Typical implementations include the auto_power_switch field in the configuration file or the --auto command-line parameter.

[0090] A prompt message refers to an interactive query presented to the user through a command-line interface or graphical interface to confirm whether to perform a power state switching operation.

[0091] This strategy first checks the status of preset automated operation flags. When it is confirmed that the flag is not set, the system outputs a formatted prompt message to the user through the human-machine interface. Specifically, it displays "[Warning] Firmware update requires powering off the target device. Continue? (Yes / No)" in the command line terminal and starts an input listening thread. After receiving a confirmation command from the user via the keyboard, the system parses the command content. If it is confirmed as a positive response (such as "Yes" or "y"), it selects the corresponding power control interface according to the currently determined target management mode. In out-of-band management mode, the chassis power down command is sent through the BMC's IPMI interface; in in-band management mode, the ipmitoolpower off command is executed locally to complete the power-off operation of the target device. If a negative response is received or no response is received within a timeout period, the power control process is terminated and the program exits.

[0092] This solution effectively prevents unexpected device shutdowns due to misoperation by introducing an interactive confirmation mechanism, providing users with the opportunity to abort critical operations and significantly improving the security and controllability of the firmware flashing process. It is particularly suitable for production environment maintenance scenarios that require manual supervision.

[0093] The second strategy is automated control, which includes: when the target management mode is out-of-band management mode and a preset automated operation flag is detected, sending a power-off command to the target device through the remote management interface of the baseboard management controller to make the target device enter a shutdown state that meets the execution conditions of the firmware update task; after detecting that the firmware update task has been completed, sending a power-on command to the target device through the remote management interface to make the target device return to normal operation.

[0094] The remote management interface refers to the external management channel provided by the baseboard management controller based on network protocols, which supports remote device management operations via IPMI over LAN or Redfish REST API standard protocols.

[0095] The power-down command refers to the device shutdown control command that conforms to the board management controller command specification. In the IPMI protocol, it is specifically implemented as the chassis power down raw command.

[0096] When the target management mode is in out-of-band management mode and the automated operation flag is detected to be activated, this strategy first sends a correctly formatted power-off command to the target device through the BMC's remote management interface (specifically using the IPMI over LAN protocol, using port 623 / TCP). The system then continuously monitors the power status by polling the BMC's device status register until it confirms that the target device has entered a completely powered-off state. At this point, the device meets the execution conditions for the firmware update task. During the firmware update task execution phase, the system monitors the task progress by parsing the BMC firmware refresh status code. When the status code indicates that the refresh is complete, it immediately sends a power-on command (the 'chassis power on' command in the IPMI protocol) to the target device through the same remote management interface, triggering the device to complete the power-on self-test and return to normal operation.

[0097] This strategy achieves autonomous execution of the firmware update process in an unattended environment through a complete automated power control closed loop. It avoids the limitations of traditional solutions that require manual intervention in power operation, and ensures reliable connection of each operation link through a status monitoring mechanism, which significantly improves the execution efficiency and automation level of firmware update operations in large-scale deployment environments.

[0098] Figure 4 A flowchart illustrating another embodiment of the firmware flashing method provided in this application. Figure 4 The process shown is in Figure 1 Based on the illustrated process, the following steps are included: Step 401: Traverse multiple candidate strategies in a preset order; Step 402: During the traversal, for the currently accessed candidate strategy, execute the test command corresponding to the candidate strategy; Step 403: If the test command is successfully executed, the traversal process is terminated, and the candidate strategy is determined as the target management strategy.

[0099] For ease of understanding, steps 401-403 are explained uniformly below: Candidate policies refer to pre-defined sets of IPMI OEM commands corresponding to specific server manufacturers or hardware platforms. Each policy contains complete test commands, configuration commands, and parameter formats.

[0100] Test commands refer to IPMI OEM instructions used to verify whether candidate policies are available in the current hardware environment. They are typically read-only commands that execute quickly.

[0101] In this embodiment, the hardware compatibility adaptive detection process is executed through the policy management module. First, the system initializes a pre-set candidate policy queue. This queue uses an intelligent sorting algorithm to sort policies in descending order, taking into account factors such as server market share, hardware platform compatibility statistical probability, and user-defined priority. This ensures that OEM instruction sets from mainstream manufacturers (such as Dell, HP, Inspur, Huawei, H3C, etc.) are detected first.

[0102] During the execution phase, the system extracts candidate policies from the queue in priority order and invokes the corresponding test commands through a secure command execution channel. Specifically, for Dell PowerEdge series servers, the standard OEM query command `ipmitool raw 0x30 0x01` is executed to obtain system characteristic information; for HP ProLiant series servers, `ipmitool raw 0x32 0x81` is executed for vendor identification verification; other vendor policies use their specific read-only query commands for compatibility testing.

[0103] The system employs a dual-verification mechanism to determine policy compatibility: when a test command returns an IPMI standard success response code (0x00 completion code) within a preset timeout period, and the format, length, and key fields of the returned data conform to the expected specifications of the policy, the system immediately terminates the iteration process and identifies the candidate policy as the target management policy for the current hardware environment. To improve detection efficiency, the system uses a "short-circuit evaluation" mechanism, stopping subsequent detection once a compatible policy is found. If the test command times out, returns an error code, or the response data format is abnormal, the system automatically records the reason for the failure and continues iterating through the next candidate policy until the queue is exhausted or a compatible policy is found.

[0104] This solution effectively addresses the compatibility issues of different server manufacturer OEM instruction sets through a dynamic detection and adaptation mechanism. It avoids the platform limitations caused by hard-coded single instruction sets in traditional solutions, and ensures the rapid selection of the best compatibility strategy through an ordered traversal strategy, significantly improving the success rate and applicability of firmware flashing tools in heterogeneous hardware environments.

[0105] The following is in conjunction with the appendix Figure 5-7 The overall workflow of the firmware flashing method described in this application will be illustrated with a complete embodiment.

[0106] like Figure 5 As shown, this method first generates a lightweight executable program through a two-level packaging strategy: (1) Compiling Cython library files: Compile the Python project source files into platform-specific dynamic link libraries, generating .so files in the Linux environment and .pyd files in the Windows environment. The compiled library files directly execute native machine code, which greatly reduces the runtime overhead of the Python interpreter and protects the source code from being directly exposed.

[0107] (2) PyInstaller Single-File Packaging: This method packages and integrates the compiled dynamic library, Python interpreter, third-party OS tools (such as ipmitool), interface configuration documentation, and other resources into a single executable file. It generates an ELF file in Linux / macOS environments and an .exe file in Windows environments. This packaging method enables lightweight deployment on the target machine without requiring the installation of Python dependencies.

[0108] 2. Firmware flashing execution phase like Figure 6 As shown, the method executes the following complete process through the executable program: (1) Parameter parsing and pattern judgment After the program starts executing, it first parses the refresh parameters and determines the target management mode based on whether a BMC IP address is specified. If no BMC IP is specified, it enters in-band management mode; if a BMC IP is specified, it enters out-of-band management mode.

[0109] (2) Establishment of in-band / out-of-band connections In in-band management mode, the program performs the following operations: records the original state of the USB0 network card; configures the USB0 virtual network card and its IP address; and logs into the BMC using the configured IP address.

[0110] In out-of-band management mode, the program logs in directly through the specified BMC IP address.

[0111] (3) Firmware upload and verification Both modes perform the following operations: upload the BIOS firmware package to the BMC Web interface; perform data verification; and asynchronously initiate the BIOS firmware flashing process.

[0112] (4) Intelligent power management The program checks the target machine's power status and executes the following branch process: a) If the power is off: the BIOS firmware flash will be performed directly, and the subsequent flash monitoring process will begin.

[0113] b) If the power is on: proceed with the following safe power operation procedure: Determine if an automated power operation parameter (-Power flag) has been specified: If not specified, enter interactive operation and prompt the user to confirm whether to perform shutdown; if the user selects "No", reset the existing system changes and interrupt the execution, waiting for the user to manually operate; if the user selects "Yes", continue to perform the shutdown operation.

[0114] Perform the corresponding operation based on the current mode: When running out of band: perform shutdown / reboot operations via BMC Web; when running in-band: perform shutdown / reboot operations via the ipmitool tool.

[0115] After the power-off operation is performed, the BIOS firmware flashing process is triggered.

[0116] (5) Refresh execution monitoring and subsequent processing After the BIOS firmware flashing task is triggered, the program executes the following unified processing flow: a) Update process monitoring: The execution progress of the BIOS firmware update task is monitored asynchronously through polling until the update is completed.

[0117] b) Standardized cleanup operations: In out-of-band mode: Determine if the current operation is automated; if it is interactive, prompt the user to choose to power on or keep the power off; finally, log out of the BMC session.

[0118] In in-band mode: Log out of the BMC session and restore the USB0 network adapter to its original state.

[0119] 3. OEM Instruction Set Adaptation Phase like Figure 7 As shown, it illustrates the hierarchical architecture of IPMI instructions followed by the ipmitool tool, which consists of three main layers: (1) Basic general management layer This level includes basic management functions that are common to servers from all vendors, mainly including: querying device vendor / entity information; and standardized basic management operations.

[0120] (2) Standard high-level instruction set This level defines advanced management functions across vendors, primarily including: Power control: The power / chassis command is used to control the power on, power off, and restart of the device; Hardware monitoring: Obtain hardware status information such as temperature, voltage, and fan speed through the sensor / sdr / fru commands; Log management: Manage system event logs using the sel / event command.

[0121] (3) Manufacturer-specific OEM instruction set This layer contains the extended instruction sets used by each vendor to implement proprietary deep control. The OEM instruction sets of different vendors are independent of each other and mainly include: Customized hardware verification: such as deep testing for specific CPU types; Specific component configurations: such as proprietary settings for the USB0 network adapter; Enhanced event logging: Vendor-specific logging and analysis features.

[0122] Based on this architecture, this method introduces an automatic adaptation mechanism for manufacturer-specific OEM instruction sets during the firmware flashing process: the program has multiple supported manufacturer OEM instruction sets pre-built, and automatically identifies and selects the OEM instruction set available for the current target device through traversal testing, thereby achieving compatibility support for servers from different manufacturers.

[0123] This embodiment achieves end-to-end optimization from program packaging and deployment, environment adaptation to hardware compatibility through the organic combination of the above three stages. Among them, lightweight packaging solves the problem of deployment complexity; in-band / out-of-band dual-mode support solves the problem of connection method adaptability; intelligent power management provides flexible operation mode; and automatic OEM instruction set adaptation completely solves the compatibility problem of different manufacturers' hardware platforms, thereby significantly improving the reliability, security and ease of use of the firmware flashing tool as a whole.

[0124] Figure 8 This is a block diagram illustrating an embodiment of a firmware flashing device provided in this application. Figure 8 As shown, the device includes: The acquisition module 81 is used to acquire connection parameters, wherein the connection parameters are parameters related to the baseboard management controller of the target device; The determination module 82 is used to determine the target management mode of the current firmware refresh operation environment based on the connection parameters. The first execution module 83 is used to execute the communication connection process corresponding to the target management mode, so as to establish a session with the baseboard management controller and trigger a firmware update task; The module 84 is used to invoke the control policy corresponding to the target management mode to control the target device before executing the firmware update task, so that the target device meets the execution conditions required by the firmware update task. The second execution module 85 is used to determine a target management strategy based on the hardware environment of the target device if a preset management operation needs to be performed during the execution of the firmware update task, and to execute the preset management operation according to the target management strategy to complete the specified interactive operation for the hardware of the target device.

[0125] In one possible implementation, the determining module is specifically used for: If the connection parameters do not include the network address information of the baseboard management controller, then the target management mode of the current firmware refresh operation environment is determined to be the in-band management mode. If the connection parameters include the network address information of the baseboard management controller, then the target management mode of the current firmware refresh operation environment is determined to be out-of-band management mode.

[0126] In one possible implementation, the first execution module is specifically used for: When the target management mode is in-band management mode, enable and configure the local virtual network interface on the target device; A local communication session with the baseboard management controller is established through the local virtual network interface; The firmware image file is transmitted to the baseboard management controller via the local communication session, and the baseboard management controller is triggered to perform integrity verification on the firmware image file. After successful verification, a firmware update command is sent to the baseboard management controller via the local communication session to trigger the firmware update task.

[0127] In one possible implementation, the first execution module is further configured to: When the target management mode is the out-of-band management mode, a remote network session with the baseboard management controller is established using the network address information; The firmware image file is uploaded to the baseboard management controller via the remote network session, and the baseboard management controller is triggered to perform integrity verification on the firmware image file. After successful verification, a firmware update command is sent to the baseboard management controller via the remote network session to trigger the firmware update task.

[0128] In one possible implementation, the calling module is specifically used for: If no preset automated operation flag is detected, generate and output a prompt message to confirm the power state switch; Receive confirmation instructions from the user based on the prompt information; Based on the confirmation command, a power control operation is performed on the target device.

[0129] In one possible implementation, the calling module is further configured to: When the target management mode is out-of-band management mode and a preset automated operation flag is detected, a power-off command is sent to the target device through the remote management interface of the baseboard management controller so that the target device enters a power-off state that meets the execution conditions of the firmware update task. After the firmware update task is detected to be completed, a power-on command is sent to the target device through the remote management interface to restore the target device to normal operation.

[0130] In one possible implementation, the second execution module is specifically used for: Iterate through multiple candidate strategies in a preset order; During the traversal, for the currently accessed candidate strategy, the test command corresponding to the candidate strategy is executed; If the test command is successfully executed, the traversal process is terminated, and the candidate strategy is determined as the target management strategy.

[0131] like Figure 9 As shown in the figure, this application provides a device including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114. Memory 113 is used to store computer programs; In one embodiment of this application, when the processor 111 executes the program stored in the memory 113, it implements the firmware flashing method provided in any of the foregoing method embodiments, including: Obtain connection parameters, wherein the connection parameters are parameters related to the baseboard management controller of the target device; Based on the connection parameters, determine the target management mode of the current firmware refresh operation environment; Execute the communication connection process corresponding to the target management mode to establish a session with the baseboard management controller and trigger a firmware update task; Before executing the firmware update task, the control policy corresponding to the target management mode is invoked to control the target device so that the target device meets the execution conditions required by the firmware update task. During the firmware update task, if a preset management operation is required, a target management strategy is determined based on the hardware environment of the target device, and the preset management operation is executed according to the target management strategy to complete the specified interactive operation for the target device hardware.

[0132] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the firmware flashing method provided in any of the foregoing method embodiments.

[0133] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0134] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0135] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.

[0136] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement 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 claimed herein.

Claims

1. A firmware flashing method, characterized in that, The method includes: Obtain connection parameters, wherein the connection parameters are parameters related to the baseboard management controller of the target device; Based on the connection parameters, determine the target management mode of the current firmware refresh operation environment; Execute the communication connection process corresponding to the target management mode to establish a session with the baseboard management controller and trigger a firmware update task; Before executing the firmware update task, the control policy corresponding to the target management mode is invoked to control the target device so that the target device meets the execution conditions required by the firmware update task. During the firmware update task, if a preset management operation is required, a target management strategy is determined based on the hardware environment of the target device, and the preset management operation is executed according to the target management strategy to complete the specified interactive operation for the target device hardware.

2. The method according to claim 1, characterized in that, The step of determining the target management mode of the current firmware flashing operation environment based on the connection parameters includes: If the connection parameters do not include the network address information of the baseboard management controller, then the target management mode of the current firmware refresh operation environment is determined to be the in-band management mode. If the connection parameters include the network address information of the baseboard management controller, then the target management mode of the current firmware refresh operation environment is determined to be out-of-band management mode.

3. The method according to claim 2, characterized in that, The execution of the communication connection process corresponding to the target management mode includes: When the target management mode is in-band management mode, enable and configure the local virtual network interface on the target device; A local communication session with the baseboard management controller is established through the local virtual network interface; The firmware image file is transmitted to the baseboard management controller via the local communication session, and the baseboard management controller is triggered to perform integrity verification on the firmware image file. After successful verification, a firmware update command is sent to the baseboard management controller via the local communication session to trigger the firmware update task.

4. The method according to claim 2, characterized in that, The execution of the communication connection process corresponding to the target management mode includes: When the target management mode is the out-of-band management mode, a remote network session with the baseboard management controller is established using the network address information; The firmware image file is uploaded to the baseboard management controller via the remote network session, and the baseboard management controller is triggered to perform integrity verification on the firmware image file. After successful verification, a firmware update command is sent to the baseboard management controller via the remote network session to trigger the firmware update task.

5. The method according to claim 1, characterized in that, The invocation of the control strategy corresponding to the target management mode to control the target device includes: If no preset automated operation flag is detected, generate and output a prompt message to confirm the power state switch; Receive confirmation instructions from the user based on the prompt information; Based on the confirmation command, a power control operation is performed on the target device.

6. The method according to claim 1, characterized in that, The invocation of the control strategy corresponding to the target management mode to control the target device includes: When the target management mode is out-of-band management mode and a preset automated operation flag is detected, a power-off command is sent to the target device through the remote management interface of the baseboard management controller so that the target device enters a power-off state that meets the execution conditions of the firmware update task. After the firmware update task is detected to be completed, a power-on command is sent to the target device through the remote management interface to restore the target device to normal operation.

7. The method according to claim 1, characterized in that, The determination of the target management strategy based on the hardware environment of the target device includes: Iterate through multiple candidate strategies in a preset order; During the traversal, for the currently accessed candidate strategy, the test command corresponding to the candidate strategy is executed; If the test command is successfully executed, the traversal process is terminated, and the candidate strategy is determined as the target management strategy.

8. A firmware flashing device, characterized in that, The device includes: An acquisition module is used to acquire connection parameters, wherein the connection parameters are parameters related to the baseboard management controller of the target device; The determination module is used to determine the target management mode of the current firmware refresh operation environment based on the connection parameters. The first execution module is used to execute the communication connection process corresponding to the target management mode, so as to establish a session with the baseboard management controller and trigger a firmware update task; The calling module is used to call the control policy corresponding to the target management mode to control the target device before executing the firmware update task, so that the target device meets the execution conditions required by the firmware update task; The second execution module is used to determine a target management strategy based on the hardware environment of the target device if a preset management operation needs to be performed during the execution of the firmware update task, and to execute the preset management operation according to the target management strategy to complete the specified interactive operation for the hardware of the target device.

9. An electronic device, characterized in that, include: A processor and a memory, the processor being configured to execute a firmware flashing program stored in the memory to implement the firmware flashing method according to any one of claims 1-7.

10. A storage medium, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement the firmware flashing method according to any one of claims 1-7.