Image file processing method and system, and product
By dividing the memory into sectors to store different versions of image files and using switching and version flags, the problem of cumbersome and time-consuming firmware version switching for edge servers is solved, achieving fast and stable firmware version switching and ensuring the stability and performance of server services.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- INSPUR SUZHOU INTELLIGENT TECH CO LTD
- Filing Date
- 2025-09-16
- Publication Date
- 2026-05-07
AI Technical Summary
In existing technologies, switching firmware versions for edge servers is cumbersome and time-consuming, consumes bandwidth resources, and is easily affected by network or external factors, leading to data loss and affecting the normal operation of services.
Multiple sectors are pre-divided in the memory to store different versions of image files. The firmware version can be quickly switched by switching and reading different sectors through the target processor, including image switching and refresh operations. The operation type and image file management are determined by the switching and version flag bits.
It enables fast and stable firmware version switching, saves bandwidth resources, ensures the stability of server services, simplifies version management processes, and improves the performance and adaptability of edge servers.
Smart Images

Figure CN2025121675_07052026_PF_FP_ABST
Abstract
Description
A method, system, and product for processing image files.
[0001] Cross-references to related applications
[0002] This application claims priority to Chinese Patent Application No. 202411524229.5, filed on October 29, 2024, entitled “A Method, System and Product for Processing Mirror Files”, the entire contents of which are incorporated herein by reference. Technical Field
[0003] This application relates to the field of server technology, and in particular to a method, system and product for processing image files. Background Technology
[0004] Edge servers are widely used in outdoor and mobile environments, bringing computing and storage resources as close to users as possible to reduce data transmission latency and network congestion, providing low-latency, high-efficiency data processing services. With continuous technological innovation, there is a need to upgrade the firmware of server hardware.
[0005] In existing solutions, firmware version switching is achieved by flashing a new image file onto the server's hardware from an external source. However, this method of switching firmware versions has limitations. For users with multiple customization needs, frequent firmware flashing is cumbersome, time-consuming, and consumes bandwidth resources. Especially for edge servers, the firmware flashing process is easily affected by network or external factors, leading to data loss and impacting normal business operations. Summary of the Invention
[0006] In view of this, this application aims to provide a method, system, and product for processing image files to solve the above-mentioned technical problems.
[0007] To achieve the above objectives, the technical solution of this application is as follows:
[0008] The first aspect of this application provides a method for processing image files, which is applied to a target processor and includes:
[0009] Receive the first instruction sent by the central processing unit;
[0010] Execute the mirror switching operation according to the first instruction;
[0011] The image switching operation includes: determining the sector where the currently not-running second image file is located based on the currently running first image file; wherein the first image file and the second image file are image files of the same type that are pre-stored in different sectors of the memory; reading the second image file from the sector and running it;
[0012] Alternatively, it can receive a second instruction sent by the central processing unit;
[0013] According to the second instruction, execute the image refresh operation;
[0014] The image refresh operation includes: determining the sector where the currently non-running second image file is located based on the currently running first image file; writing the third image file to the sector and replacing the second image file; the third image file is of the same type as the first image file.
[0015] In some embodiments of this application, determining the sector where a currently non-running second image file is located based on a currently running first image file includes:
[0016] According to the first instruction, update the switching flag; the switching flag is used to indicate the type of operation performed by the target processor.
[0017] Read the version flag and determine the first sector where the first image file currently in operation is located based on the version flag; the version flag is used to indicate the version of the currently running image file.
[0018] Based on the first sector, determine the second sector where the currently non-running second image file is located.
[0019] In some embodiments of this application, reading and running a second image file from a sector includes:
[0020] Perform a reset operation and update the version flag based on the second sector;
[0021] After reset, based on the updated version flag, the second image file is read from the second sector and loaded into memory for execution.
[0022] In some embodiments of this application, the version flags include: a major version flag and a startup version flag;
[0023] Based on the second sector update version flag, including:
[0024] If the second image file stored in the second sector is the main program file, update the major version flag.
[0025] If the second image file stored in the second sector is a bootloader file, update the boot version flag.
[0026] In some embodiments of this application, determining the sector where a currently non-running second image file is located based on a currently running first image file includes:
[0027] According to the second instruction, update the switching flag; the switching flag is used to indicate the type of operation performed by the target processor.
[0028] Read the version flag and determine the first sector where the first image file currently in operation is located based on the version flag; the version flag is used to indicate the version of the currently running image file.
[0029] Based on the first sector, determine the second sector where the currently non-running second image file is located.
[0030] In some embodiments of this application, writing a third image file to a sector and replacing the second image file includes:
[0031] Receives a third image file sent by the central processing unit;
[0032] Perform integrity verification on the third-party image file;
[0033] If the integrity verification passes, the third image file is written to the second sector and replaces the second image file.
[0034] In some embodiments of this application, after writing the third image file to the second sector and replacing the second image file, the method further includes:
[0035] Perform a reset operation and update the version flags based on the second sector; the version flags include: the major version flag and the startup version flag;
[0036] After reset, based on the updated version flag, the third image file is read from the second sector and loaded into memory for execution.
[0037] In some embodiments of this application, the version flags include: a major version flag and a startup version flag;
[0038] Based on the second sector update version flag, including:
[0039] If the third image file stored in the second sector is the main program file, update the main version flag.
[0040] If the third image file stored in the second sector is a bootloader file, update the boot version flag.
[0041] In some embodiments of this application, after performing a mirror switching operation or a mirror refresh operation, the method further includes:
[0042] Send operation completion information to the central processing unit;
[0043] It receives a viewing request from the central processing unit and sends the version information of the currently running image file to the central processing unit.
[0044] In some embodiments of this application, the memory includes: non-volatile memory in the target processor; the non-volatile memory is pre-divided into multiple sectors and used to store: a first image file of the main program, a second image file of the main program, a third image file of the main program, a first image file of the startup program, a second image file of the startup program, a third image file of the startup program, or at least one of a flag bit;
[0045] The flags include a switching flag and a version flag. The switching flag indicates the type of operation performed by the target processor, and the version flag indicates the version of the currently running image file.
[0046] In some embodiments of this application, the memory further includes: an external memory connected to the target processor; the external memory is used to store at least one of the following when the storage space of the non-volatile memory in the target processor is insufficient: a first image file of the main program, a second image file of the main program, a third image file of the main program, a first image file of the startup program, a second image file of the startup program, a third image file of the startup program, or a flag bit.
[0047] According to a second aspect of the embodiments of this application, a method for processing image files is provided, applied to a central processing unit, the method comprising:
[0048] Obtain the first task, which instructs the target processor to perform a mirror switching operation. The mirror switching operation includes: determining the sector where the currently non-running second mirror file is located based on the currently running first mirror file; wherein the first mirror file and the second mirror file are mirror files of the same type that are pre-stored in different sectors of memory; reading the second mirror file from the sector and running it.
[0049] Alternatively, a second task can be obtained, which instructs the target processor to perform an image refresh operation. The image refresh operation includes: determining the sector where the currently non-running second image file is located based on the currently running first image file; writing the third image file to the sector and replacing the second image file; the third image file and the second image file are of the same type.
[0050] In some embodiments of this application, the image file processing method further includes:
[0051] Receive operation completion information sent by the target processor;
[0052] Send a view request to the target processor to obtain the version information of the image file currently running on the target processor.
[0053] According to a third aspect of the embodiments of this application, a mirror file processing system is provided, comprising:
[0054] The central processing unit is used to execute the steps in the method of the second aspect of the embodiments of this application to control the target processor to perform a mirror switching operation or a mirror refresh operation;
[0055] The target processor is used to perform the steps of the image switching operation or image refresh operation as described in the first aspect of the embodiments of this application.
[0056] In some embodiments of this application, the image file processing system further includes:
[0057] An external storage device, connected to the target processor, is used to store at least one of the following when the non-volatile memory in the target processor is insufficient: a first image file of the main program, a second image file of the main program, a third image file of the main program, a first image file of the startup program, a second image file of the startup program, a third image file of the startup program, or a flag bit.
[0058] In some embodiments of this application, the image file processing system further includes:
[0059] The baseboard management controller is connected to the target processor via an integrated circuit bus and is used to obtain the version information of the image file currently running in the target processor.
[0060] According to a fourth aspect of the embodiments of this application, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the methods of the first or second aspects of the embodiments of this application.
[0061] According to a fifth aspect of the embodiments of this application, a computer non-volatile readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the methods of the first or second aspects of the embodiments of this application.
[0062] According to a sixth aspect of the embodiments of this application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the methods of the first or second aspects of the embodiments of this application.
[0063] The image file processing method provided in this application divides the memory into multiple sectors, storing two image files of the same type but different versions (a first image file and a second image file) in different sectors. The target processor receives a first / second instruction from the CPU (Central Processing Unit) to switch the currently running first image file to a redundant second image file, or to refresh the redundant second image file using an external third image file.
[0064] In this application, the target processor can switch firmware versions by switching between different sectors. For customers with customized version requirements, retaining two available image files of different versions in different sectors of memory allows for convenient and rapid switching between the two image files, meeting the user's frequent switching needs for different versions. This eliminates the need to externally flash data to the target processor for each version switch, saving significant bandwidth resources and ensuring the stability of the server's services. For production line engineers, simultaneously retaining both old and new image files in memory facilitates firmware version rollback, simplifies production line problem localization, troubleshooting, and management, and greatly simplifies the version control process. Attached Figure Description
[0065] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0066] Figure 1 is a flowchart of one embodiment of the image file processing method proposed in this application;
[0067] Figure 2 is a second flowchart of an embodiment of the image file processing method proposed in this application;
[0068] Figure 3 is a schematic diagram of the sector division of the internal Flash memory of the MCU in one embodiment of this application;
[0069] Figure 4 is a flowchart of MCU processing image files in one embodiment of this application;
[0070] Figure 5 is a schematic diagram of a mirror file processing system according to an embodiment of this application;
[0071] Figure 6 is a schematic diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0072] 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.
[0073] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.
[0074] In the various embodiments of this application, it should be understood that the sequence number of each process described below does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0075] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects as detailed in this application.
[0076] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.
[0077] After the server powers on, each hardware device reads the image from a fixed location in the storage and runs it. In related technologies, when a hardware device needs to switch firmware versions, the new version's image file is flashed from an external source into the fixed location, overwriting the original image file. This method requires performing an external image flashing and overwriting operation every time a firmware version is switched. For users with multiple customization needs, frequent firmware version switching is necessary, leading to frequent data flashing, cumbersome operations, and high bandwidth consumption. Especially for edge servers, which are often used outdoors, firmware version switching is easily affected by network or external factors, potentially causing data loss and impacting normal server operations.
[0078] This application proposes a method for processing image files, enabling fast and stable firmware version switching and ensuring the stability of server-provided services. Taking an MCU (Microcontroller Unit) as an example, this application will be described in detail below with reference to the accompanying drawings and embodiments.
[0079] Figure 1 is a flowchart of an image file processing method according to an embodiment of this application. Figure 1(a) shows the flow of the target processor performing an image switching operation. As shown, the method includes:
[0080] S11: Receive the first instruction sent by the central processing unit;
[0081] S12: Execute a mirror switching operation according to the first instruction; the mirror switching operation includes: determining the sector where the currently not running second mirror file is located based on the currently running first mirror file; wherein the first mirror file and the second mirror file are mirror files of the same type that are pre-stored in different sectors of the memory; reading the second mirror file from the sector and running it.
[0082] Figure 1(b) is a flowchart of the target processor performing a mirror refresh operation. As shown, the method includes:
[0083] S11': Receive the second instruction sent by the central processing unit;
[0084] S12': Execute the image refresh operation according to the second instruction; the image refresh operation includes: determining the sector where the currently non-running second image file is located based on the currently running first image file; writing the third image file to the sector and replacing the second image file; the third image file is of the same type as the first image file.
[0085] In this embodiment, when the edge server powers on, its internal MCU first reads one version of the image file (i.e., the first image file) from the memory and executes it, while the other version (the second image file) serves as a redundancy. During the MCU's execution of the first image file, it receives a first instruction from the host CPU and, based on this instruction, performs an image switching operation. This scheme pre-stores two versions of the image file in different sectors of the memory. For example, the first image file is stored in the first sector, and the second image file is stored in the second sector. Upon receiving the first instruction from the host CPU, the image switching operation is performed. The second sector, where the second image file is not currently running, is located is determined, and then the second image file is read from the second sector and executed, thus achieving image switching. That is, the currently running first image file is switched to the running second image file.
[0086] When the MCU is running the first image file, it receives a second instruction from the host CPU and performs an image refresh operation according to the second instruction. The CPU sends a new version of the image file (the third image file) to the MCU, and the MCU uses the third image file to refresh the redundant image file (the second image file) in memory. Specifically, the third image file is written to the second sector where the second image file is located, and replaces the second image file.
[0087] This method always maintains two available image files in the memory and quickly switches the firmware version by switching between different sectors read by the MCU. This meets the user's frequent switching needs for different versions, eliminates the need to write data to the MCU from the outside every time a version is switched, saves a lot of bandwidth resources, ensures the stability of the services provided by the server, improves the overall performance of the edge server, and simplifies the version management process.
[0088] For production line engineers, this allows for better control and localization of production line errors. By simultaneously storing both the old and new firmware versions and recording the timestamps of version updates, error logs from the new and old versions can be correlated, facilitating on-site problem localization, troubleshooting, and management. For example, if a DIAG (Diagnostic Process) error is suspected to be due to a version issue, it can be verified by switching versions, eliminating the need for frequent firmware flashing and preventing additional flashing operations from causing production line errors.
[0089] In terms of product quality, this method provides a convenient firmware rollback mechanism for MCUs. In the event of problems with the new firmware, the MCU can quickly roll back to a stable older version by switching the sectors it reads, ensuring the continuous availability of the device and the stability of business operations.
[0090] For customers with customized version requirements, this application enables the retention of two available image files in different sectors of the memory. When switching between these two image files, there is no need to frequently write data to the MCU from the outside, saving a lot of bandwidth resources. At the same time, it ensures the stability of the services provided by the server, greatly simplifies the management process, and improves the scalability and adaptability of the edge server in different scenarios.
[0091] Based on the same inventive concept, an embodiment of this application provides a method for processing image files. Figure 2 is a second flowchart of the image file processing method proposed in an embodiment of this application. In Figure 2(a), it is a flowchart of the central processing unit performing an image switching operation. As shown in the figure, the method includes:
[0092] S21: Obtain the first task, which is used to instruct the target processor to perform a mirror switching operation; the mirror switching operation includes: determining the sector where the currently non-running second mirror file is located based on the currently running first mirror file; wherein the first mirror file and the second mirror file are mirror files of the same type that are pre-stored in different sectors of the memory; reading the second mirror file from the sector and running it.
[0093] Figure 2(b) shows the flow of the central processing unit performing the image refresh operation. As shown, the method includes:
[0094] S21': Obtain the second task, which is used to instruct the target processor to perform an image refresh operation; the image refresh operation includes: determining the sector where the currently non-running second image file is located based on the currently running first image file; writing the third image file to the sector and replacing the second image file; the third image file is of the same type as the first image file.
[0095] In this embodiment, the host CPU generates a first instruction based on the first task submitted by the user (i.e., switching the running version) and sends the first instruction to the microcontroller unit of the edge server, so that the microcontroller unit performs a mirror switching operation. In some embodiments of this application, the first instruction is a command line containing custom variables. After receiving the first instruction, the MCU reads the custom variables to determine the type of operation to be performed (e.g., mirror switching operation).
[0096] The CPU generates a second instruction based on the user-submitted second task (i.e., flashing a new firmware version) and sends the second instruction to the MCU to perform a mirror refresh operation. In some embodiments of this application, the second instruction is a command line containing custom variables. After receiving the second instruction, the MCU reads the custom variables to determine the type of operation to be performed (e.g., mirror refresh operation), and simultaneously receives the new image file (i.e., the third image file) sent by the CPU, writes it to the memory buffer, and waits for integrity verification.
[0097] In this embodiment, the CPU on the user host and the MCU on the edge server communicate via a serial port. Before the CPU sends instructions, a communication link needs to be established between the CPU and the MCU. This solution configures serial port information based on the first port on the CPU and the second port on the MCU, including: the port number of the first port, the port number of the second port, the baud rate, and the data transmission and reception rules. The specific steps are as follows:
[0098] (1) Determine the serial port number for communication between the MCU and the host CPU;
[0099] (2) Implement serial communication between CPU and MCU in the operating system, configure the serial port using the program library, including port number, baud rate, etc. to establish communication, configure serial port read and write functions and configuration file transmission protocol, etc.
[0100] After the MCU powers on, it first loads one of the stored versions of the image file. In this embodiment, the image file includes a bootloader file and a main program file. After the MCU powers on, it loads the bootloader first, and then loads the main program. During the execution of the image file, it receives instructions sent by the CPU and performs corresponding operations on the image file in memory.
[0101] In one embodiment, the user host and the edge server communicate via a network. Mirroring or refreshing operations performed by the target processor are packaged as an HTTP (Hypertext Transfer Protocol) service and provided externally. This HTTP protocol enables remote control of the edge server to perform firmware version switching or firmware refreshing. Specifically, the host CPU is deployed on a remote server and communicates with the target processor on the edge server via HTTP. The CPU packages the first instruction into an HTTP request and sends it to the target processor on the edge server to use the HTTP service (mirroring / refresh) provided by the target processor. To ensure data security, a token is used for authentication between the CPU and the target processor during the use of the HTTP service to ensure the legitimacy of the operation and data security.
[0102] As one implementation of this application, determining the sector where a currently non-running second image file is located based on a currently running first image file includes:
[0103] According to the first instruction, update the switching flag; the switching flag is used to indicate the type of operation performed by the target processor.
[0104] Read the version flag and determine the first sector where the first image file currently in operation is located based on the version flag; the version flag is used to indicate the version of the currently running image file.
[0105] Based on the first sector, determine the second sector where the currently non-running second image file is located.
[0106] In one embodiment, the mirroring switch operation is performed by first updating the switching flag. In this embodiment, the switching flag is represented by 2 bits of binary data. The specific meanings of the switching flag are as follows: 00: Switch bootloader version; 01: Switch main program version; 10: Refresh bootloader version; 11: Refresh main program version. The MCU updates the switching flag according to the first instruction, and then performs a reset operation to enable the flag. For example, if the first instruction is to switch the bootloader version, the switching flag is updated to "00", and the MCU is reset and enabled.
[0107] Simultaneously, the current version flag is read to determine the sector where the currently running image file is located. Since this scheme stores the first and second image files in two sectors respectively, given the location of the currently running first image file in the first sector, the location of the currently not running second image file in the second sector can be directly determined.
[0108] As one embodiment of this application, reading and running a second image file from a sector includes:
[0109] Perform a reset operation and update the version flag based on the second sector;
[0110] After reset, based on the updated version flag, the second image file is read from the second sector and loaded into memory for execution.
[0111] In one embodiment, after determining the second sector, an MCU Reset is performed, and the version flag is updated based on that sector. In this embodiment, the MCU maintains the version flag in real time, and the version flag corresponds to the sector where the currently running image file is located. When performing an image switching operation, the MCU updates the version flag. For example, the value of the current version flag indicating "running image file 1 in the first sector" is updated to the value indicating "running image file 2 in the second sector".
[0112] As one embodiment of this application, the version flag includes: a major version flag and a startup version flag;
[0113] Based on the second sector update version flag, including:
[0114] If the second image file stored in the second sector is the main program file, update the major version flag.
[0115] If the second image file stored in the second sector is a bootloader file, update the boot version flag.
[0116] In one embodiment, 8-bit binary representations are used to represent the major version flag and the boot version flag, and different values are used to distinguish image files of different sectors, as follows:
[0117] Major version flag "00000000": corresponds to the sector where main program 1 is located;
[0118] Major version flag "00000001": corresponds to the sector where main program 2 is located;
[0119] The boot version flag "00000000": corresponds to the sector where bootloader1 is located;
[0120] The boot version flag "00000001" corresponds to the sector where bootloader2 is located.
[0121] Figure 4 is a flowchart of the MCU processing image files in one embodiment of this application. As shown in Figure 4, after the MCU receives the first instruction sent by the central processing unit, it first updates the switching flag bit, then executes MCU Reset to reset the microcontroller unit, and updates the corresponding version flag bit. When updating the version flag bit, the type of image file stored in the sector to be read is updated as needed. For example, if it is necessary to switch the second image file stored in the second sector to be read as the main program file, the main version flag bit is updated accordingly; if the second image file is a startup program file, the startup version flag bit is updated accordingly. After reset, the MCU reads the image file from the corresponding sector into memory for execution according to the current version flag bit.
[0122] As one implementation of this application, determining the sector where a currently non-running second image file is located based on a currently running first image file includes:
[0123] According to the second instruction, update the switching flag; the switching flag is used to indicate the type of operation performed by the target processor.
[0124] Read the version flag and determine the first sector where the first image file currently in operation is located based on the version flag; the version flag is used to indicate the version of the currently running image file.
[0125] Based on the first sector, determine the second sector where the currently non-running second image file is located.
[0126] As shown in Figure 4, in this embodiment, after receiving the second instruction sent by the central processing unit, the MCU first updates the switching flag bit, and then determines the sector where the external third image file needs to be written, that is, the sector where the currently non-running second image file is located. Specifically, it reads the current version flag bit to determine the sector where the currently running image file is located. Since the first and second image files are stored in two sectors respectively in this scheme, given that the first sector where the currently running first image file is located is determined, the second sector where the currently non-running second image file is located can be directly determined.
[0127] As one embodiment of this application, writing the third image file to a sector and replacing the second image file includes:
[0128] Receives a third image file sent by the central processing unit;
[0129] Perform integrity verification on the third-party image file;
[0130] If the integrity verification passes, the third image file is written to the second sector and replaces the second image file.
[0131] In one embodiment, after receiving the second instruction, the MCU also receives a third image file sent by the central processing unit (CPU) and writes the new image file (i.e., the third image file) into the memory buffer. The MCU performs an integrity check on the third image file. If the integrity check is successful, the third image file is written to the sector where the currently non-running second image file is located, replacing the second image file and realizing the version update of redundant firmware. If the integrity check fails, the third image file is discarded and the switching flag is restored.
[0132] For example, if the new image file is the main program 3 and the main program 2 is not currently running, replace the main program 2 with the main program 3 that has passed the integrity verification.
[0133] As one embodiment of this application, after writing the third image file to the second sector and replacing the second image file, the method further includes:
[0134] Perform a reset operation and update the version flags based on the second sector; the version flags include: the major version flag and the startup version flag;
[0135] After reset, based on the updated version flag, the third image file is read from the second sector and loaded into memory for execution.
[0136] As one embodiment of this application, the version flag includes: a major version flag and a startup version flag;
[0137] Based on the second sector update version flag, including:
[0138] If the third image file stored in the second sector is the main program file, update the main version flag.
[0139] If the third image file stored in the second sector is a bootloader file, update the boot version flag.
[0140] In one embodiment, after a new third image file is flashed to the second sector, the MCU automatically switches to run the third image file. Specifically, after the flashing is complete, an MCU Reset operation is performed, and the version flag is updated according to the type of the image file stored in the second sector. After the MCU resets, the third image file is read from the second sector and loaded into memory for execution based on the updated version flag.
[0141] In some embodiments of this application, when the CPU generates a second instruction based on a second task submitted by the user, the host provides the user with an option via a user interface to choose whether to switch to running the new firmware version after flashing the firmware. If the user selects "flash firmware only without switching," a third instruction is generated based on the second task submitted by the user and sent to the target processor. The target processor, based on the third instruction, performs the aforementioned image flashing operation. After flashing the third image file, a reset operation is not automatically performed; the currently running first image file is still maintained.
[0142] The method provided in this embodiment enables users to perform subsequent operations such as firmware refresh on a pre-defined target processor, improving the flexibility and controllability of the target processor and avoiding service interruption caused by the edge server switching firmware versions during business operation.
[0143] As one embodiment of this application, after performing the image switching operation or the image refresh operation, the method further includes:
[0144] Send operation completion information to the central processing unit;
[0145] It receives a viewing request from the central processing unit and sends the version information of the currently running image file to the central processing unit.
[0146] As one embodiment of this application, the image file processing method further includes:
[0147] Receive operation completion information sent by the target processor;
[0148] Send a view request to the target processor to obtain the version information of the image file currently running on the target processor.
[0149] In this embodiment, the MCU performs a mirror switching operation or a mirror refresh operation according to the first instruction or the second instruction. After the server where the MCU is located powers on, the MCU upgrade is complete, and it returns operation completion information to the CPU on the host side to promptly notify the user. The user can send a viewing request to the MCU through the central processing unit to obtain the currently running firmware version in the MCU and view it through the user interface on the host side.
[0150] As one embodiment of this application, the memory includes: non-volatile memory in the target processor; the non-volatile memory is pre-divided into multiple sectors and used to store: a first image file of the main program, a second image file of the main program, a third image file of the main program, a first image file of the startup program, a second image file of the startup program, a third image file of the startup program, or at least one of a flag bit.
[0151] The flags include a switching flag and a version flag. The switching flag indicates the type of operation performed by the target processor, and the version flag indicates the version of the currently running image file.
[0152] In one embodiment, the flash memory within the microcontroller unit is used to store the image file and flag bits. To accommodate the dual-image redundancy switching scheme, the flash memory is pre-divided into multiple sectors. Figure 3 is a schematic diagram of the sector division of the flash memory inside the MCU in one embodiment of this application. As shown in Figure 3, the flash is divided into 7 sectors:
[0153] Sector 1 and sector 2 are used to store two versions of the startup program file (startup program 1 and startup program 2), respectively.
[0154] Sector 3 and sector 4 are used to store two versions of the main program file (main program 1 and main program 2), respectively.
[0155] Sector 5 is a buffer used to temporarily store the third image file (main program file or startup program file) to be verified;
[0156] Sector 6 (Flag Area) is used to store all flags, including: switch flag, major version flag, and startup version flag;
[0157] Sector 7 is used to store other data from the MCU.
[0158] After power-on, the MCU continuously reads the flag bits in sector 6 at time intervals. By reading the switching flag bit, it determines the type of operation to be performed (i.e., whether it's a mirror switch or a mirror refresh). By reading the main version flag bit and the startup version flag bit, it determines the version of the currently running image file. It's important to note that updating the switching flag bit requires an MCU reset. After sector division, the version flag bits are associated with the sectors. For example, the main version flag bit "00000000" corresponds to sector 3, and the main version flag bit "00000001" corresponds to sector 4. When the MCU resets and reads the main version flag bit "00000001", it indicates that the currently running main program should be the image file in sector 4 (main program 2).
[0159] When it is necessary to switch the currently running main program 1 to main program 2, the switching flag is updated to "01", and the MCU is reset to enable the switching flag. Simultaneously, the main version flag is updated to "00000001". After resetting, the MCU first reads the switching flag "01" to determine that a main program switch is needed, then reads the main version flag "00000001" to determine that main program 2 in sector 4 needs to be run. Based on the flag reading results, a mirror switching operation is performed, reading the main program file (main program 2) from sector 4 into memory for execution, thus completing the mirror switching operation.
[0160] In this embodiment, different versions of image files are isolated by dividing the system into sectors, thereby preventing data updates from affecting currently running data and causing image files to malfunction. For example, when writing a new image file, the new image file in the buffer is overwritten into the sector where the currently non-running image is located (e.g., the new main program 3 is overwritten into sector 4), replacing the old version image file (main program 2) in that sector. This prevents the writing of new data from affecting the currently running image (e.g., main program 1), ensuring system stability and normal business operation.
[0161] As one embodiment of this application, the memory further includes: an external memory connected to the target processor; the external memory is used to store at least one of the following when the storage space of the non-volatile memory in the target processor is insufficient: a first image file of the main program, a second image file of the main program, a third image file of the main program, a first image file of the startup program, a second image file of the startup program, a third image file of the startup program, or a flag bit.
[0162] In some scenarios, insufficient memory capacity within the target processor may occur. Since this solution stores multiple redundant image files in the memory, insufficient storage capacity may arise when the image files are large. For example, when the MCU's Flash memory capacity is 128KB and a main program occupies 70KB, the MCU's Flash memory does not have enough space to store two complete main program image files. Therefore, in one embodiment, the problem of insufficient storage space is solved by connecting an external memory device to the target processor.
[0163] In one embodiment, an EEPROM (Electrically Erasable Programmable Read Only Memory) is used as external storage. In edge servers, the baseboard MCU is typically connected to an external EEPROM for collecting and recording MCU-related logs. Since EEPROMs usually have a large storage capacity, they can be used as part of the storage in this solution to expand the storage space for redundant image files. Specifically, when the flash memory space inside the MCU is insufficient, data that needs to be stored in one or more sectors of the flash memory (e.g., main program 2 in sector 4) is stored in one or more sectors of the external storage. It is worth noting that serial communication between the MCU and the external storage needs to be pre-initialized, and the external storage needs to be pre-partitioned into sectors to isolate different versions of image files, thereby improving data security and system stability.
[0164] In this embodiment, when the storage capacity of the target processor's internal memory is insufficient, external storage is used to store the image file. The same effect can be achieved by replacing operations on the target processor's internal memory with operations on the external storage. In this way, support for large firmware files is achieved without changing the overall logic, while maintaining the logical consistency of image switching and refreshing, thus improving the system's flexibility and adaptability.
[0165] Based on the same inventive concept, one embodiment of this application provides a mirror file processing system. The system includes:
[0166] The central processing unit is used to execute the image file processing method as described in the above embodiments, so as to control the target processor to perform image switching operations or image refresh operations;
[0167] The target processor is used to perform the image switching operation or image refresh operation in the image file processing method as described in the above embodiments.
[0168] As one embodiment of this application, the image file processing system further includes:
[0169] An external storage device, connected to the target processor, is used to store at least one of the following when the non-volatile memory in the target processor is insufficient: a first image file of the main program, a second image file of the main program, a third image file of the main program, a first image file of the startup program, a second image file of the startup program, a third image file of the startup program, or a flag bit.
[0170] As one embodiment of this application, the image file processing system further includes:
[0171] The baseboard management controller is connected to the target processor via an integrated circuit bus and is used to obtain the version information of the image file currently running in the target processor.
[0172] Figure 5 is a schematic diagram of an image file processing system according to an embodiment of this application. As shown in Figure 5, the central processing unit 101 and the microcontroller unit 102 communicate via serial port, and the microcontroller unit 102 communicates with the baseboard management controller 104 via an integrated circuit bus (I2C bus). The microcontroller unit 102 is connected to the external memory 103, and the two communicate via serial port. When the Flash memory in the microcontroller unit 102 is insufficient, the storage address of the image file or the flag bit is migrated to the external memory 103.
[0173] In one embodiment, the server also houses a Baseboard Management Controller (BMC). After the server powers on, the host user can remotely connect to the BMC and send a second viewing request to the MCU to obtain the version information of the currently running image file. The BMC then displays the obtained firmware version information of the MCU in its user interface. In this embodiment, the BMC enables users to remotely monitor the MCU firmware version and operation status of the edge server, saving time and labor costs.
[0174] Based on the same inventive concept, one embodiment of this application provides a mirror file processing apparatus, including:
[0175] The first communication module is configured to receive a first instruction sent by the central processing unit; or, to receive a second instruction sent by the central processing unit.
[0176] The first processing module is configured to perform a mirror switching operation according to a first instruction; the mirror switching operation includes: determining the sector where a currently non-running second mirror file is located based on the currently running first mirror file; wherein the first mirror file and the second mirror file are mirror files of the same type that are pre-stored in different sectors of the memory; reading the second mirror file from the sector and running it;
[0177] The second processing module is configured to perform a mirror refresh operation according to the second instruction. The mirror refresh operation includes: determining the sector where the currently non-running second mirror file is located based on the currently running first mirror file; writing the third mirror file to the sector and replacing the second mirror file; the third mirror file is of the same type as the first mirror file.
[0178] As one embodiment of this application, the first processing module is configured to determine the sector where a currently non-running second image file is located based on the currently running first image file, including:
[0179] According to the first instruction, update the switching flag; the switching flag is used to indicate the type of operation performed by the target processor.
[0180] Read the version flag and determine the first sector where the first image file currently in operation is located based on the version flag; the version flag is used to indicate the version of the currently running image file.
[0181] Based on the first sector, determine the second sector where the currently non-running second image file is located.
[0182] As one embodiment of this application, the first processing module is configured to read and run a second image file from a sector, including:
[0183] Perform a reset operation and update the version flag based on the second sector;
[0184] After reset, based on the updated version flag, the second image file is read from the second sector and loaded into memory for execution.
[0185] As one embodiment of this application, the version flag includes: a major version flag and a startup version flag;
[0186] The first processing module is configured to update the version flag based on the second sector, including:
[0187] If the second image file stored in the second sector is the main program file, update the major version flag.
[0188] If the second image file stored in the second sector is a bootloader file, update the boot version flag.
[0189] As one embodiment of this application, the second processing module is configured to determine the sector where a currently non-running second image file is located based on the currently running first image file, including:
[0190] According to the second instruction, update the switching flag; the switching flag is used to indicate the type of operation performed by the target processor.
[0191] Read the version flag and determine the first sector where the first image file currently in operation is located based on the version flag; the version flag is used to indicate the version of the currently running image file.
[0192] Based on the first sector, determine the second sector where the currently non-running second image file is located.
[0193] As one embodiment of this application, the second processing module is configured to write the third image file to a sector and replace the second image file, including:
[0194] Receives a third image file sent by the central processing unit;
[0195] Perform integrity verification on the third-party image file;
[0196] If the integrity verification passes, the third image file is written to the second sector and replaces the second image file.
[0197] In one embodiment of this application, the second processing module is further configured to perform the following steps after writing the third image file to the second sector and replacing the second image file:
[0198] Perform a reset operation and update the version flags based on the second sector; the version flags include: the major version flag and the startup version flag;
[0199] After reset, based on the updated version flag, the third image file is read from the second sector and loaded into memory for execution.
[0200] As one embodiment of this application, the version flag includes: a major version flag and a startup version flag;
[0201] The second processing module is configured to update the version flag based on the second sector, including:
[0202] If the third image file stored in the second sector is the main program file, update the main version flag.
[0203] If the third image file stored in the second sector is a bootloader file, update the boot version flag.
[0204] In one embodiment of this application, the first communication module is further configured to perform the following operations after executing a mirror switching operation or a mirror refresh operation:
[0205] Send operation completion information to the central processing unit;
[0206] It receives a viewing request from the central processing unit and sends the version information of the currently running image file to the central processing unit.
[0207] Based on the same inventive concept, one embodiment of this application provides a mirror file processing device deployed in a central processing unit, the device comprising:
[0208] The first task acquisition module is configured to acquire a first task, which is used to instruct the target processor to perform an image switching operation. The image switching operation includes: determining the sector where the currently non-running second image file is located based on the currently running first image file; wherein the first image file and the second image file are image files of the same type that are pre-stored in different sectors of the memory; reading the second image file from the sector and running it.
[0209] The second task acquisition module is configured to acquire a second task, which is used to instruct the target processor to perform an image refresh operation. The image refresh operation includes: determining the sector where the currently non-running second image file is located based on the currently running first image file; writing the third image file to the sector and replacing the second image file; the third image file is of the same type as the first image file.
[0210] The instruction generation module is configured to generate a first instruction based on a first task, or to generate a second instruction based on a second task;
[0211] The second communication module is configured to send a first instruction or a second instruction to the target processor.
[0212] In one embodiment of this application, the second communication module is also configured to perform the following operations:
[0213] Receive operation completion information sent by the target processor;
[0214] Send a view request to the target processor to obtain the version information of the image file currently running on the target processor.
[0215] Based on the same inventive concept, one embodiment of this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps in the image file processing method of any of the above embodiments of this application.
[0216] Based on the same inventive concept, one embodiment of this application provides a non-volatile readable storage medium storing a computer program thereon. When the program is executed by a processor, it implements the steps in the image file processing method of any of the above embodiments of this application.
[0217] Based on the same inventive concept, one embodiment of this application provides an electronic device. Figure 6 is a schematic diagram of an electronic device according to an embodiment of this application. As shown in Figure 6, the electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the image file processing method of any of the above embodiments of this application.
[0218] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0219] The above are merely preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
[0220] For the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that some embodiments of this application described in the specification are preferred embodiments, and the actions and components involved are not necessarily essential to this application.
[0221] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0222] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or one or more blocks of the block diagrams.
[0223] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more block diagrams.
[0224] These computer program instructions may also be loaded onto a computer or other programmable data processing terminal equipment to cause a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable terminal equipment, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.
[0225] Although preferred embodiments of the embodiments of this application have been described, those skilled in the art, once they understand the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, this application is to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of this application.
[0226] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes the element.
[0227] The above provides a detailed description of the image file processing method, system, and product provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for processing image files, characterized in that, It should be configured as the target processor; The method includes: Receive the first instruction sent by the central processing unit; According to the first instruction, execute the image switching operation; The image switching operation includes: determining the sector where a currently non-running second image file is located based on the currently running first image file; wherein the first image file and the second image file are image files of the same type that are pre-stored in different sectors of the memory; reading the second image file from the sector and running it; Alternatively, receive a second instruction sent by the central processing unit; According to the second instruction, perform the image refresh operation; The image refresh operation includes: determining the sector where a second image file that is not currently running is located based on the first image file that is currently running; writing a third image file into the sector and replacing the second image file; the third image file is of the same type as the first image file.
2. The image file processing method according to claim 1, characterized in that, Based on the currently running first image file, determine the sector where the currently not running second image file is located, including: According to the first instruction, the switching flag is updated; the switching flag is configured to indicate the type of operation performed by the target processor. Read the version flag bit and determine the first sector where the currently running first image file is located based on the version flag bit; the version flag bit is configured to indicate the version of the currently running image file; Based on the first sector, determine the second sector where the currently non-running second image file is located.
3. The image file processing method according to claim 2, characterized in that, Reading and running the second image file from the sector includes: Perform a reset operation and update the version flag bit based on the second sector; After reset, based on the updated version flag, the second image file is read from the second sector and loaded into memory for execution.
4. The image file processing method according to claim 3, characterized in that, The version flags include: the major version flag and the startup version flag; Updating the version flag based on the second sector includes: If the second image file stored in the second sector is the main program file, update the main version flag. If the second image file stored in the second sector is a startup program file, update the startup version flag.
5. The image file processing method according to claim 1, characterized in that, Based on the currently running first image file, determine the sector where the currently not running second image file is located, including: According to the second instruction, the switching flag is updated; the switching flag is configured to indicate the type of operation performed by the target processor. Read the version flag bit and determine the first sector where the currently running first image file is located based on the version flag bit; the version flag bit is configured to indicate the version of the currently running image file; Based on the first sector, determine the second sector where the currently non-running second image file is located.
6. The image file processing method according to claim 5, characterized in that, Writing the third image file to the sector and replacing the second image file includes: Receive the third image file sent by the central processing unit; Perform an integrity check on the third image file; If the integrity verification passes, the third image file is written to the second sector and replaces the second image file.
7. The image file processing method according to claim 6, characterized in that, After performing integrity verification on the third image file, the process also includes: If the integrity check fails, discard the third image file and restore the switching flag.
8. The image file processing method according to claim 6, characterized in that, After writing the third image file to the second sector and replacing the second image file, the process further includes: Perform a reset operation and update the version flag bit based on the second sector; the version flag bit includes: a major version flag bit and a startup version flag bit; After reset, based on the updated version flag, the third image file is read from the second sector and loaded into memory for execution.
9. The image file processing method according to claim 8, characterized in that, The version flags include: the major version flag and the startup version flag; Updating the version flag based on the second sector includes: If the third image file stored in the second sector is the main program file, update the main version flag. If the third image file stored in the second sector is a startup program file, update the startup version flag.
10. The image file processing method according to claim 1, characterized in that, After performing an image switching operation or an image refresh operation, the following is also included: Send operation completion information to the central processing unit; The system receives a viewing request from the central processing unit and sends the version information of the currently running image file to the central processing unit.
11. The image file processing method according to claim 1, characterized in that, The memory includes: non-volatile memory in the target processor; the non-volatile memory is pre-divided into multiple sectors and configured to store: a first image file of the main program, a second image file of the main program, a third image file of the main program, a first image file of the startup program, a second image file of the startup program, a third image file of the startup program, or at least one of a flag bit; The flags include a switching flag and a version flag; the switching flag is configured to indicate the type of operation performed by the target processor, and the version flag is configured to indicate the version of the currently running image file.
12. The image file processing method according to claim 11, characterized in that, The memory further includes: an external memory connected to the target processor; the external memory is configured to store at least one of the following when the storage space of the non-volatile memory in the target processor is insufficient: a first image file of the main program, a second image file of the main program, a third image file of the main program, a first image file of the startup program, a second image file of the startup program, a third image file of the startup program, or a flag bit.
13. A method for processing image files, characterized in that, It should be configured as a central processing unit, including: Obtain a first task, configured to instruct a target processor to perform a mirror switching operation; the mirror switching operation includes: determining the sector where a currently non-running second image file is located based on the currently running first image file; wherein the first image file and the second image file are image files of the same type pre-stored in different sectors of memory; reading the second image file from the sector and running it; Alternatively, a second task may be acquired, configured to instruct the target processor to perform a mirror refresh operation; the mirror refresh operation includes: determining the sector containing a currently non-running second mirror file based on the currently running first mirror file; writing a third mirror file into the sector and replacing the second mirror file; the third mirror file being of the same type as the first mirror file.
14. The image file processing method according to claim 13, characterized in that, Also includes: Receive operation completion information sent by the target processor; Send a view request to the target processor to obtain the version information of the image file currently running in the target processor.
15. A mirror file processing system, characterized in that, include: The central processing unit is configured to perform the method as described in claim 12 or 13 to control the target processor to perform a mirror switching operation or a mirror refresh operation; The target processor is configured to perform a mirror switching operation or a mirror refresh operation as described in any one of claims 1-11.
16. The image file processing system according to claim 15, characterized in that, Also includes: An external storage device, connected to the target processor, is configured to store at least one of the following when the storage space of the non-volatile memory in the target processor is insufficient: a first image file of the main program, a second image file of the main program, a third image file of the main program, a first image file of the startup program, a second image file of the startup program, a third image file of the startup program, or a flag bit.
17. The image file processing system according to claim 15, characterized in that, Also includes: The baseboard management controller, connected to the target processor via an integrated circuit bus, is configured to acquire version information of the currently running image file in the target processor.
18. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1-12, or the method as described in any one of claims 13-14.
19. A computer non-volatile readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1-12, or the method as described in any one of claims 13-14.
20. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1-12, or the method as described in any one of claims 13-14.
Citation Information
Patent Citations
Firmware refreshing method and system for uninterrupted output of server power supply
CN112000359A
Mirror image file processing method, system and product
CN119046249A
Domestic server BIOS firmware backup device
CN218974903U
Module mirroring during non-disruptive upgrade
US20200042312A1