An upgrading method and device
By providing common preset structures and interface functions for different modules in electronic devices, the problem of differences in module upgrade processes is solved, and the unified and efficient upgrade of module upgrades is achieved.
Patent Information
- Application Number
- CN202111274832.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2041-10-29
AI Technical Summary
There are differences in upgrade processes for modules with different functions in electronic devices (such as BIOS, PSU, CPLD, FPGA), which leads to the problem of unified upgrades.
An upgrade method is provided, by providing a common preset structure for modules with different functions in electronic devices, using the interface functions in the structure for initialization, generating respective structures, and when receiving the upgrade instruction, the interface functions are run in accordance with the unified upgrade process to complete the module upgrade.
The upgrade process of different modules is unified, the upgrade process is simplified, and the upgrade efficiency and consistency are improved.
Smart Images

Figure CN114003257B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of firmware upgrade, and particularly relates to an upgrade method and device. Background Art
[0002] Currently, there are differences in the upgrade processes of modules with different functions in electronic devices. For example, an electronic device includes modules such as BIOS (Basic Input Output System), PSU (Power Supply Unit), CPLD (Complex Programmable Logic Device), and FPGA (Field Programmable Gate Array). The BIOS upgrade can be completed through the firmware upgrade process in the AMI solution, and the firmware upgrade process is implemented based on the original code of AMI. The three modules of PSU, CPLD, and FPGA are upgraded by calling their respective related APPs (Applications). Due to different upgrade methods for different modules, there are certain differences in the upgrade processes of each module in the electronic device. Summary of the Invention
[0003] This application provides an upgrade method and device.
[0004] On the one hand, this application provides an upgrade method, and the method includes:
[0005] Respectively use the upgrade methods of the first module and the second module to initialize the interface functions in the preset structure to obtain the first structure of the first module and the second structure of the second module. The preset structure corresponds to the upgrade process, the interface function points to a link in the upgrade process, and the first module and the second module are two modules with different functions in the electronic device;
[0006] For any module to be upgraded in the first module and the second module, if an upgrade instruction for the module to be upgraded is received, call the structure corresponding to the module to be upgraded;
[0007] Run the interface function in the structure corresponding to the module to be upgraded according to the upgrade process to complete the upgrade of the module to be upgraded.
[0008] Optionally, the first module and the second module provide a unified external interface, and each external interface points to a link in the upgrade method, so as to access the upgrade method through the external interface to perform assignment processing on the interface functions in the preset structure.
[0009] Optionally, the method further includes:
[0010] Obtain the configuration file of the electronic device, where the configuration file is used to indicate the upgrade of the first module and the second module;
[0011] If the configuration file indicates the upgrade of the third module and the third module is the same as the first module, reuse the first structure of the first module as the third structure of the third module;
[0012] If an upgrade instruction for the third module is received, call the third structure of the third module;
[0013] Run the interface function in the third structure of the third module according to the upgrade process to complete the upgrade of the third module.
[0014] Optionally, the method further includes:
[0015] If the management process receives an upgrade instruction for the module to be upgraded, call the management process to generate an upgrade management file for the module to be upgraded, where the upgrade management file is at least used to indicate the upgrade environment of the module to be upgraded;
[0016] Call the management process to send the upgrade management file of the module to be upgraded to the upgrade process;
[0017] Call the upgrade process to parse the upgrade management file of the module to be upgraded to verify whether the current operating environment of the electronic device matches the upgrade environment of the module to be upgraded;
[0018] The step of "if an upgrade instruction for the module to be upgraded is received, call the corresponding structure of the module to be upgraded" includes: if the current operating environment of the electronic device matches the upgrade environment of the module to be upgraded, call the corresponding structure of the module to be upgraded.
[0019] Optionally, the step of "call the management process to send the upgrade management file of the module to be upgraded to the upgrade process" includes:
[0020] Call the management process to create an upgrade task for the module to be upgraded, where the upgrade task carries the upgrade management file of the module to be upgraded;
[0021] Call the management process to write the upgrade task of the module to be upgraded into the upgrade queue; the upgrade process can read the upgrade task of the module to be upgraded from the upgrade queue to extract the upgrade management file of the module to be upgraded from the upgrade task of the module to be upgraded.
[0022] Optionally, the method further includes:
[0023] During the upgrade process, the upgrade thread runs the interface functions in the structure corresponding to the module to be upgraded according to the upgrade process, and uses the recording thread in the upgrade process to record the upgrade status of the module to be upgraded;
[0024] The reporting thread in the upgrade process is used to report the upgrade status of the module to be upgraded.
[0025] Optionally, the upgrade status includes: the module identifier of the module to be upgraded, the upgrade result, the current upgrade operation, and the upgrade progress; the upgrade result is represented by the identifier in the preset upgrade results, and the current upgrade operation and the upgrade progress are used to indicate whether the upgrade is completed and the stage at which it is not completed.
[0026] On the other hand, the present application provides an upgrade device, which includes:
[0027] An initialization unit, configured to initialize the interface functions in the preset structure by using the upgrade methods of the first module and the second module respectively, to obtain the first structure of the first module and the second structure of the second module. The preset structure corresponds to the upgrade process, the interface function points to a link in the upgrade process, and the first module and the second module are two modules with different functions in the electronic device;
[0028] A calling unit, configured to, for any module to be upgraded in the first module and the second module, if an upgrade instruction for the module to be upgraded is received, call the structure corresponding to the module to be upgraded;
[0029] An operating unit, configured to run the interface functions in the structure corresponding to the module to be upgraded according to the upgrade process to complete the upgrade of the module to be upgraded.
[0030] On yet another aspect, the present application provides an electronic device, which includes: a first module, a second module, a memory, and a processor;
[0031] The memory is configured to store a preset structure, the preset structure corresponds to the upgrade process, and the interface function points to a link in the upgrade process;
[0032] The processor is configured to initialize the interface functions in a preset structure respectively by using the upgrade methods of the first module and the second module, so as to obtain a first structure of the first module and a second structure of the second module, where the first module and the second module are two modules with different functions in an electronic device; for any module to be upgraded in the first module and the second module, if an upgrade instruction for the module to be upgraded is received, the structure corresponding to the module to be upgraded is called; and the interface functions in the structure corresponding to the module to be upgraded are run according to the upgrade process to complete the upgrade of the module to be upgraded.
[0033] In another aspect, the present application provides a storage medium storing computer program code, and when the computer program code is executed, the above-mentioned upgrade method is implemented.
[0034] The above-mentioned upgrade method and device respectively use the upgrade methods of the first module and the second module to initialize the interface functions in a preset structure, so as to obtain a first structure of the first module and a second structure of the second module. The preset structure corresponds to the upgrade process, and the interface function points to a link of the upgrade process. The first module and the second module are two modules with different functions in an electronic device; for any module to be upgraded in the first module and the second module, if an upgrade instruction for the module to be upgraded is received, the structure corresponding to the module to be upgraded is called; and the interface functions in the structure corresponding to the module to be upgraded are run according to the upgrade process to complete the upgrade of the module to be upgraded.
[0035] The present application provides a shared preset structure for the first module and the second module in an electronic device. The preset structure points to the upgrade process of the module, and the interface functions in the preset structure point to a link of the upgrade process. Before upgrading the first module or the second module, the preset structure can be assigned values by using the upgrade methods of each module to obtain the respective structures of each module. The respective structures of each module have values related to the upgrade methods of the module, so as to complete the upgrade of the model by running the structure of the model. And the respective structures of each module are obtained by assigning values to the preset structure, so that except for different parameter values, the interface functions and the sorting of the interface functions of different modules are the same. The interface function corresponds to a link of the upgrade process. In the case where the interface functions and the sorting of the interface functions are the same, the upgrade processes of the structures of different modules are also the same, realizing the unification of the upgrade processes of different modules. Description of the Drawings
[0036] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0037] Figure 1 It is a flowchart of an upgrade method provided by an embodiment of the present application;
[0038] Figure 2 It is a flowchart of another upgrade method provided by an embodiment of the present application;
[0039] Figure 3 It is a flowchart of yet another upgrade method provided by an embodiment of the present application;
[0040] Figure 4 It is a schematic structural diagram of an upgrade device provided by an embodiment of the present application;
[0041] Figure 5 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Specific embodiments
[0042] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present application.
[0043] Please refer to Figure 1 , which shows an optional process of an upgrade method provided by an embodiment of the present application and may include the following steps:
[0044] 101. Respectively use the upgrade methods of the first module and the second module to perform initialization processing on the interface functions in the preset structure to obtain the first structure of the first module and the second structure of the second module. The preset structure corresponds to the upgrade process, the interface function points to a link in the upgrade process, and the first module and the second module are two modules with different functions in the electronic device.
[0045] In this embodiment, the preset structure includes multiple interface functions, and each interface function points to a link in the upgrade process. Different interface functions point to different links. Thus, through the multiple interface functions in the preset structure, a single upgrade process shared by each module in the electronic device is pointed to. The multiple interface functions in the preset structure are determined according to the links in the upgrade process. For example, the upgrade process at least includes five links: obtaining the upgrade version, upgrade preparation, firmware verification, firmware burning, and upgrade result output. The upgrade process is for the to-be-upgraded template in the electronic device. When there is an upgrade requirement for the first module and the second module, the first module and the second module are the to-be-upgraded modules in the electronic device. For the to-be-upgraded modules, the functions of the above five links in the upgrade process are as follows:
[0046] Obtaining the upgrade version is used to obtain the latest version identifier of the to-be-upgraded module, such as obtaining the latest version number of the to-be-upgraded module; upgrade preparation is used to prepare the upgrade environment required when the to-be-upgraded module is upgraded, so that the upgrade environment of the electronic device conforms to the required upgrade environment; firmware verification is used to verify the to-be-upgraded module to verify whether it meets the preset indicators, such as verifying its reliability, etc.; firmware burning is used to burn the to-be-upgraded module of the latest version. For example, in embedded startup, the to-be-upgraded module of the latest version can be downloaded to the embedded storage device, and the latest version of the to-be-upgraded module can be called from the storage device when the electronic device is started next time; upgrade result output is used to output the upgrade result of the to-be-upgraded module, such as whether the upgrade fails or succeeds, etc. The upgrade result output can also output the upgrade status during the upgrade process.
[0047] The preset structure can set five interface functions according to the above five links, and obtain interface functions corresponding to obtaining the upgrade version, upgrade preparation, firmware verification, firmware burning, and upgrade result output respectively. In some examples, the form of the preset structure is as follows:
[0048] typedef struct
[0049]
[0050] Among them, *GetFwVersion corresponds to the link of obtaining the upgrade version, *DoUpdatePrepare corresponds to the link of upgrade preparation, *DoImageValidation corresponds to the link of firmware verification, *DoImageUpdate corresponds to the link of firmware burning, and *GetImageUpdateProgress corresponds to the link of upgrade result output. In addition, the upgrade process can also include a link for outputting the upgrade progress, and the corresponding preset structure includes an interface function corresponding to it, such as int(*GetImageUpdateProgress)(void).
[0051] The preset structure is a structure shared by all modules in the electronic device. However, there are certain differences among different modules in the electronic device. For example, the upgrade versions of different modules are different, and the functions of different modules are different. Therefore, the versions obtained during the upgrade and the firmware to be burned (the module to be upgraded) will also be different. Therefore, for each module in the electronic device, the electronic device can use the upgrade method of each module to initialize the interface functions in the preset structure to obtain the structure of each module.
[0052] Taking the first module and the second module as an example above, the electronic device can use the upgrade method of the first module and the upgrade method of the second module to initialize the interface functions in the preset structure respectively to obtain the first structure of the first module and the second structure of the second module. Since the first structure of the first module and the second structure of the second module are obtained by initializing the interface functions in the preset structure, the first structure and the second structure can respectively correspond to the upgrade requirements of their respective modules, and the interface functions in the first structure and the second structure are the same (the functions are the same but the values are different), and the sorting of the interface functions is also the same, so that the upgrade processes of different modules are unified when meeting the upgrade requirements of their respective modules.
[0053] In this embodiment, the purpose of the electronic device using the upgrade method of the first module and the upgrade method of the second module to initialize the interface functions in the preset structure respectively is that: the first structure of the first module corresponds to the upgrade method of the first module, and the second structure of the second module corresponds to the upgrade method of the second module. Then, running the structures corresponding to each module means running the upgrade methods of each module. Based on this, one way of initialization in this embodiment is to use the upgrade method to assign values to the interface functions in the preset structure. For example, obtain the parameter values matching the parameters of each interface function in the typedef struct from the upgrade method, and write the parameter values into the corresponding interface functions to complete the initialization.
[0054] In addition, the first module and the second module can provide a unified external interface, and each external interface points to a link in the upgrade method respectively. When initializing the interface functions in the preset structure, the electronic device can access the upgrade method through the external interface to assign values to the interface functions in the preset structure. For example, access each link of the upgrade method through the external interface, and obtain the parameter values matching the parameters of each interface function in the typedef struct from each link of the upgrade method.
[0055] In some examples, the unified external interfaces provided by the first module and the second module can correspond to the links of the upgrade process. For example, the external interfaces include: a preparation interface (Prepare), a verification interface (Validation), a flashing interface (Update), and a status interface (Progress). The preparation interface corresponds to upgrade preparation, the verification interface corresponds to firmware verification, the flashing interface corresponds to firmware flashing, and the status interface corresponds to the output of the upgrade result. The specific implementation of module upgrade is accessed using these interfaces, and the specific implementation of module upgrade is the upgrade method of module upgrade.
[0056] For example, an electronic device includes modules such as BIOS, PSU, CPLD, PSoC (programmable system-on-chip), and FPGA. For these modules, the electronic device can respectively set a preparation interface (Prepare), a verification interface (Validation), a flashing interface (Update), and a status interface (Progress), and access the specific implementation of each module upgrade using the respective external interfaces of each module.
[0057] 102. For any module to be upgraded in the first module and the second module, if an upgrade instruction for the module to be upgraded is received, call the corresponding structure body of the module to be upgraded.
[0058] In some examples, the electronic device can indicate the module to be upgraded in the configuration file. For example, the electronic device can write the module identifier of the first module and / or the second module in the configuration file, and indicate the module currently being upgraded, that is, the module to be upgraded (which can also be called firmware), through the module identifier. If a module identifier is parsed from the configuration file, it indicates that an upgrade instruction for the module to be upgraded pointed to by the module identifier is received.
[0059] In some examples, the electronic device can receive an upgrade instruction for the module to be upgraded sent by other devices. For example, it receives an upgrade instruction for the module to be upgraded sent by the server of the module manufacturer. The upgrade instruction for the module to be upgraded can be encapsulated following HTTP (Hyper Text Transfer Protocol). This embodiment does not make a limitation.
[0060] 103. Run the interface function in the structure body corresponding to the module to be upgraded according to the upgrade process to complete the upgrade of the module to be upgraded.
[0061] The upgrade process can specify the sequence of each link of the upgrade of the module to be upgraded. For example, the specified sequence of the upgrade process is to obtain the upgrade version, upgrade preparation, firmware verification, firmware flashing, and upgrade result output. After obtaining the upgrade version and completing the upgrade preparation and verification, firmware flashing is performed to complete the upgrade of the module to be upgraded.
[0062] The interface functions in the structure corresponding to the module to be upgraded are obtained by initializing the interface functions in the preset structure. During initialization, they are obtained by assignment using the upgrade method of the module to be upgraded (which can also be called the specific implementation of module upgrade), so that the structure corresponding to the module to be upgraded is equivalent to the specific implementation of the upgrade of the module to be upgraded. Therefore, running the interface functions of the structure corresponding to the module to be upgraded according to the upgrade process is equivalent to running the specific implementation of the upgrade of the module to be upgraded according to the upgrade process, thus completing the upgrade of the module to be upgraded.
[0063] In this embodiment, a common preset structure is provided for the first module and the second module in the electronic device. The preset structure points to the upgrade process of the module, and the interface functions in the preset structure point to a link in the upgrade process. Before upgrading the first module or the second module, the preset structure can be assigned values using the upgrade methods of each module to obtain the respective structures of each module. The respective structures of each module have values related to the upgrade methods of the modules, so that the upgrade of the model can be completed by running the structure of the model. And the respective structures of each module are obtained by assigning values to the preset structure, so that except for different parameter values, the interface functions and the sorting of the interface functions of different modules are the same. The interface functions correspond to a link in the upgrade process. In the case where the interface functions and the sorting of the interface functions are the same, the upgrade processes of the structures of different modules are also the same, realizing the unification of the upgrade processes of different modules.
[0064] Please refer to Figure 2 , which shows an optional process of another upgrade method provided by the embodiments of the present application, and may include the following steps:
[0065] 201. Respectively use the upgrade methods of the first module and the second module to initialize the interface functions in the preset structure to obtain the first structure of the first module and the second structure of the second module. The preset structure corresponds to the upgrade process, the interface functions point to a link in the upgrade process, and the first module and the second module are two modules with different functions in the electronic device.
[0066] 202. Obtain the configuration file of the electronic device. The configuration file is used to indicate the upgrade of the first module and the second module.
[0067] The electronic device can write the module identifiers of the first module and / or the second module in the configuration file, and indicate the module to be upgraded currently, that is, the module to be upgraded, through the module identifiers. If a module identifier is parsed from the configuration file, it means that an upgrade instruction for the module pointed to by the module identifier is received.
[0068] Among them, the module identifiers of each module in the electronic device can be recorded in an enumeration array. When indicating module upgrade, the module identifier of the module can be found from the enumeration array. Examples of the enumeration array and the module identifier are as follows:
[0069]
[0070] 203. If the configuration file indicates an upgrade to the third module, and the third module is the same as the first module, reuse the first structure of the first module as the third structure of the third module.
[0071] In this embodiment, since the third module is the same as the first module, it means that the third module and the first module are two modules with the same upgrade methods and interface implementations. The structures corresponding to the third module and the first module are also the same. Since the first structure of the first module has been obtained, the first structure of the first module can be directly reused, saving the process of constructing the third structure of the third module.
[0072] 204. If an upgrade instruction for the third module is received, call the third structure of the third module.
[0073] 205. Run the interface function in the third structure of the third module according to the upgrade process to complete the upgrade of the third module.
[0074] In this embodiment, when the third module in the electronic device is the same as the first module, the structure of the same module can be reused, that is, the first structure of the first module is reused to obtain the third structure of the third module, thus saving the links of writing the upgrade method and external interface of the third module and constructing the third structure of the third module, achieving the maximum reuse of the structure. When the upgrade methods and interfaces are the same, the electronic device can modify the configuration file and write the module identifier of the module to be upgraded in the configuration file. For example, the electronic device includes 4 PSUs, and user 1 can upgrade 2 of the 4 PSUs (such as PSU1 and PSU2), and user 2 can upgrade PSU1. The configuration file method facilitates users to specify the module to be upgraded to achieve personalized upgrade, and the method of modifying the configuration file can save the process of modifying the upgrade source code, further maximizing the reuse.
[0075] Please refer to Figure 3 , which shows an alternative process of another upgrade method provided by the embodiments of the present application, and may include the following steps:
[0076] 301. Initialize the interface functions in the preset structure using the upgrade methods of the first module and the second module respectively to obtain the first structure of the first module and the second structure of the second module. The preset structure corresponds to the upgrade process, and the interface function points to a link in the upgrade process. The first module and the second module are two modules with different functions in the electronic device.
[0077] 302. For any module to be upgraded in the first module and the second module, if the management process receives an upgrade instruction for the module to be upgraded, call the management process to generate an upgrade management file for the module to be upgraded. The upgrade management file is at least used to indicate the upgrade environment of the module to be upgraded.
[0078] In this embodiment, the upgrade instruction is used to indicate that the module to be upgraded has an upgrade requirement, and the upgrade management file is used to indicate the upgrade environment of the module to be upgraded. When the upgrade environment is met, the module to be upgraded is triggered to upgrade. That is to say, when the upgrade instruction is received, the module to be upgraded can be in the upgrade waiting state, and when the upgrade environment is met, the module to be upgraded starts to upgrade.
[0079] Among them, the upgrade environment can indicate the upgrade timing of the module to be upgraded, the state of the electronic device during the upgrade. In addition, the upgrade environment can also indicate the path and the module configuration after the upgrade. The upgrade management file can be a TASK file encapsulated in JSON (JavaScript Object Notation) format. The upgrade environment of the module to be upgraded is recorded in the TASK file. The following shows an example of an upgrade environment:
[0080]
[0081]
[0082] FilePath is the upgrade path of the module to be upgraded, and the upgrade process can load the content of the module to be upgraded according to this path; ProgressFile is the upgrade progress display file, specifying that the upgrade progress information is written into the upgrade progress display file; UpgradeHostOff is the state of the electronic device during the upgrade, indicating whether the upgrade of the module to be upgraded is carried out in the system shutdown state; UpgradeNow is the upgrade timing, indicating whether the upgrade of the module to be upgraded is executed immediately; PreserveConfig is, indicating whether the current module configuration is included during the upgrade.
[0083] 303. Call the management process to send the upgrade management file of the module to be upgraded to the upgrade process.
[0084] If the management process and the upgrade process are written in different languages, for example, the management process is written in C language and the upgrade process is written in LUA language, the convenience and friendliness between the processes written in different languages are reduced. Therefore, the complexity of passing the upgrade environment through communication messages between the two processes is increased, resulting in the cumbersome process of message passing between processes.
[0085] To address this issue, in this embodiment, the management process and the upgrade process interact in the form of files. The parsing difficulty of files under different programming languages is less than that of messages. Therefore, when the processes interact in the form of files, on the one hand, the cumbersome process of message passing between processes is avoided. On the other hand, the management process encapsulates the upgrade management file in JSON format, and the upgrade process can parse the upgrade management file in the same JSON format.
[0086] 304. Call the upgrade process to parse the upgrade management file of the module to be upgraded to verify whether the current operating environment of the electronic device matches the upgrade environment of the module to be upgraded.
[0087] The upgrade process obtains the environment parameters related to the upgrade environment recorded in the upgrade management file by parsing the upgrade management file, and then verifies whether the current operating environment of the electronic device matches the environment parameters.
[0088] Taking the above {
[0089] "BIOS":{
[0090] "FilePath":" / tmp / xxxx.bin",
[0091] "ProgressFile":" / tmp / xxx",
[0092] "UpgradeHostOff":"NO",
[0093] "UpgradeNow":"YES",
[0094] “PreserveConfig":"YES”
[0095] }
[0096] as an example, it is specified to be executed immediately when the system is powered on. If the system of the electronic device is powered on, it means that the current operating environment of the electronic device matches the environment parameters, and the electronic device can immediately trigger the upgrade of the module to be upgraded. If it is specified not to be executed immediately when the system is powered on, and if the system of the electronic device is powered on, the electronic device can wait for a period of time to trigger the upgrade of the module to be upgraded.
[0097] 305. If the current operating environment of the electronic device matches the upgrade environment of the module to be upgraded, call the corresponding structure of the module to be upgraded.
[0098] 306. Run the interface function in the corresponding structure of the module to be upgraded according to the upgrade process to complete the upgrade of the module to be upgraded.
[0099] In this embodiment, the management process and the upgrade process interact in the form of files, eliminating the need to transmit messages. In this way, even if different processes are written in different languages, the cumbersome problems caused by transmitting messages between different processes can be avoided through the file form.
[0100] The electronic device may upgrade multiple modules to be upgraded. Then, the management process sends the upgrade management files of different modules to be upgraded to the upgrade process. To reduce the interference of multiple upgrade management files during transmission, this embodiment shows a way to call the management process to send the upgrade management file of the module to be upgraded to the upgrade process, as follows:
[0101] Call the management process to create an upgrade task for the module to be upgraded. The upgrade task carries the upgrade management file of the module to be upgraded; call the management process to write the upgrade task of the module to be upgraded into the upgrade queue. The upgrade process can read the upgrade task of the module to be upgraded from the upgrade queue to extract the upgrade management file of the module to be upgraded from the upgrade task.
[0102] The management process can create an upgrade task for each module to be upgraded, carry the upgrade management file of the module to be upgraded in the upgrade task, and write the upgrade task carrying the upgrade management file into the upgrade queue. Since the management process can only write one upgrade task into the upgrade queue at a time, interference between multiple upgrade tasks can be avoided from the management process side, and thus interference between multiple upgrade management files can be avoided. The upgrade process can read one upgrade task from the upgrade queue each time (such as reading in the first-in, first-out manner). In this way, the upgrade process can only obtain the upgrade management file of one module to be upgraded each time, avoiding interference between multiple upgrade management files.
[0103] Moreover, the upgrade process obtains one upgrade management file from the task queue each time, which also means that the upgrade process will process the upgrade of one module to be upgraded each time, avoiding interference caused by multiple modules being upgraded simultaneously. Here, it should be noted that: to avoid interference caused by multiple modules being upgraded simultaneously, before the upgrade process obtains the upgrade management file from the task queue or before performing the upgrade, the upgrade process can determine whether there is a module to be upgraded that is being upgraded. If so, the upgrade process can wait until the module to be upgraded completes the upgrade.
[0104] In this embodiment, the upgrade process may include an upgrade thread, a recording thread, and a reporting thread. The upgrade thread is used to complete the upgrade of the module to be upgraded. The recording thread is used to record the upgrade status of the module to be upgraded. The reporting thread is used to report the upgrade status of the module to be upgraded. The upgrade thread, the recording thread, and the reporting thread can be executed in parallel, so that the upgrade status can be recorded and reported in a timely manner during the upgrade process.
[0105] Correspondingly, the upgrade method provided in this embodiment may further include: the upgrade thread in the upgrade process runs the interface function in the structure corresponding to the module to be upgraded according to the upgrade process, and uses the recording thread in the upgrade process to record the upgrade status of the module to be upgraded; uses the reporting thread in the upgrade process to report the upgrade status of the module to be upgraded. In this way, the upgrade process performs upgrade, upgrade status recording, and upgrade status reporting through different threads, preventing upgrade interruption caused by recording and reporting.
[0106] Among them, the upgrade status includes: the module identifier of the module to be upgraded, the upgrade result, the current upgrade operation, and the upgrade progress; the upgrade result is represented by the identifier in the preset upgrade result, and the current upgrade operation and the upgrade progress are used to indicate whether the upgrade is completed and the stage where it is not completed.
[0107] An example of the preset upgrade result is as follows:
[0108] typedef enum{
[0109] LNV_EXT_FLASHER_UPGRADE_FAILURE=-1, / / -1 indicates failure
[0110] LNV_EXT_FLASHER_UPGRADE_STARTUP_PREPARE=0, / / 0 indicates starting upgrade preparation
[0111] LNV_EXT_FLASHER_UPGRADE_PREPARE_OK=1, / / 1 indicates preparation completed LNV_EXT_FLASHER_UPGRADE_WRITE_IMG_IN_PROGRESS=2, / / indicates that burning is in progress
[0112] LNV_EXT_FLASHER_UPGRADE_WRITE_IMG_FAILURE=3, / / indicates burning failure
[0113] LNV_EXT_FLASHER_UPGRADE_VALIDATION_FAILURE=4, / / indicates verification failure
[0114] LNV_EXT_FLASHER_UPGRADE_FW_MISMATCH_ERROR = 5, / / Indicates a mismatch error
[0115] LNV_EXT_FLASHER_UPGRADE_COMPLETE_SUCCESS = 6, / / Indicates successful upgrade
[0116] LNV_EXT_FLASHER_UPGRADE_NOT_ALLOWED_ERROR = 7, / / Indicates a non - allowed error
[0117] LNV_EXT_FLASHER_UPGRADE_STATUS_MAX, / / Indicates that other status codes are added before this
[0118] }。
[0119] The corresponding reported upgrade status can be encapsulated in JSON format. For example, the upgrade status is "{\"type\":\"FPGA\",\"result\":\"6\",\"action\":\"done\",\"progress\":\"100\"}". "type" corresponds to the module identifier, indicating the module to be upgraded currently being upgraded, such as one of FPGA, BIOS, CPLD, PSU; "result" corresponds to the upgrade result, and the corresponding number can be selected from the above - preset upgrade results; "action" corresponds to the current upgrade operation. For example, "done" indicates that the upgrade is completed, and "flashing" indicates that the flashing is in progress; "progress" corresponds to the upgrade progress, expressed as a percentage of the upgrade process.
[0120] For different modules to be upgraded, the upgrade of each module to be upgraded can be comprehensively understood through a unified upgrade status, realizing real - time monitoring of the upgrade of the modules to be upgraded.
[0121] For the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be in other sequences or carried out simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.
[0122] Corresponding to the above - mentioned method embodiments, the embodiment of the present application provides an upgrade device, and its optional structure is as Figure 4 shown, and may include: an initialization unit 10, a call unit 20, and an operation unit 30.
[0123] Initialization unit 10 is used to initialize the interface functions in the preset structure respectively by using the upgrade methods of the first module and the second module, so as to obtain the first structure of the first module and the second structure of the second module. The preset structure corresponds to the upgrade process, and the interface function points to a link in the upgrade process. The first module and the second module are two modules with different functions in the electronic device.
[0124] The first module and the second module provide a unified external interface, and each external interface points to a link in the upgrade method respectively, so as to access the upgrade method through the external interface to assign values to the interface functions in the preset structure and complete the initialization process of the interface functions. For the description of the preset structure and initialization, please refer to the above embodiments and will not be elaborated here.
[0125] Invocation unit 20 is used to, for any module to be upgraded in the first module and the second module, if an upgrade instruction for the module to be upgraded is received, invoke the structure corresponding to the module to be upgraded.
[0126] Running unit 30 is used to run the interface functions in the structure corresponding to the module to be upgraded according to the upgrade process, so as to complete the upgrade of the module to be upgraded.
[0127] The upgrade process can specify the sequence of each link in the upgrade of the module to be upgraded. For example, the specified sequence of the upgrade process is to obtain the upgrade version, upgrade preparation, firmware verification, firmware burning, and upgrade result output. After obtaining the upgrade version and completing the upgrade preparation and verification, firmware burning is performed to complete the upgrade of the module to be upgraded.
[0128] The interface functions in the structure corresponding to the module to be upgraded are obtained by initializing the interface functions in the preset structure. When initializing, they are assigned values by using the upgrade method of the module to be upgraded (which can also be called the specific implementation of module upgrade), so that the structure corresponding to the module to be upgraded is equivalent to the specific implementation of the upgrade of the module to be upgraded. Therefore, running the interface functions of the structure corresponding to the module to be upgraded according to the upgrade process is equivalent to running the specific implementation of the upgrade of the module to be upgraded according to the upgrade process, thus completing the upgrade of the module to be upgraded.
[0129] In this embodiment, a shared preset structure is provided for a first module and a second module in an electronic device. The preset structure points to the upgrade process of the module, and the interface functions in the preset structure point to a link in the upgrade process. Before upgrading the first module or the second module, the preset structure can be assigned values by using the upgrade methods of each module to obtain the respective structures of each module. The respective structures of each module have values related to the upgrade methods of the module, so as to complete the upgrade of the model by running the structure of the model. Moreover, the respective structures of each module are obtained by assigning values to the preset structure, so that except for different parameter values, the interface functions and the sorting of the interface functions of different modules are the same. The interface functions correspond to a link in the upgrade process. When the interface functions and the sorting of the interface functions are the same, the upgrade processes of the structures of different modules are also the same, realizing the unification of the upgrade processes of different modules.
[0130] In some examples, the upgrade device may further include an acquisition unit and a reuse unit. The acquisition unit is used to acquire the configuration file of the electronic device, and the configuration file is used to indicate the upgrade of the first module and the second module; the reuse unit is used to reuse the first structure of the first module as the third structure of the third module if the configuration file indicates the upgrade of the third module and the third module is the same as the first module.
[0131] The corresponding call unit is used to call the third structure of the third module if an upgrade instruction for the third module is received; the running unit is used to run the interface functions in the third structure of the third module according to the upgrade process to complete the upgrade of the third module.
[0132] In some examples, the call unit is further used to perform the following steps: if the management process receives an upgrade instruction for the module to be upgraded, call the management process to generate an upgrade management file for the module to be upgraded, and the upgrade management file is at least used to indicate the upgrade environment of the module to be upgraded;
[0133] Call the management process to send the upgrade management file of the module to be upgraded to the upgrade process;
[0134] Call the upgrade process to parse the upgrade management file of the module to be upgraded to verify whether the current operating environment of the electronic device matches the upgrade environment of the module to be upgraded;
[0135] If the current operating environment of the electronic device matches the upgrade environment of the module to be upgraded, call the structure corresponding to the module to be upgraded.
[0136] Among them, the management process calls the upgrade process to send the upgrade management file of the module to be upgraded, which includes: the management process creates an upgrade task for the module to be upgraded, and the upgrade management file of the module to be upgraded is carried in the upgrade task; the management process writes the upgrade task of the module to be upgraded into the upgrade queue; the upgrade process can read the upgrade task of the module to be upgraded from the upgrade queue, so as to extract the upgrade management file of the module to be upgraded from the upgrade task of the module to be upgraded.
[0137] In some examples, the upgrade device may further include a status management unit, which is used to record the upgrade status of the module to be upgraded by the recording thread in the upgrade process while the upgrade thread in the upgrade process runs the interface function in the structure corresponding to the module to be upgraded according to the upgrade process; and report the upgrade status of the module to be upgraded by the reporting thread in the upgrade process.
[0138] Please refer to Figure 5 , which shows an optional structure of an electronic device provided by an embodiment of the present application. The electronic device may include: a first module 100, a second module 200, a memory 300, and a processor 400.
[0139] The memory 300 is used to store a preset structure, the preset structure corresponds to the upgrade process, and the interface function points to a link in the upgrade process.
[0140] The processor 400 is used to initialize the interface function in the preset structure by using the upgrade methods of the first module 100 and the second module 200 respectively, so as to obtain the first structure of the first module 100 and the second structure of the second module 200. The first module 100 and the second module 200 are two modules with different functions in the electronic device; for any module to be upgraded in the first module 100 and the second module 200, if an upgrade instruction for the module to be upgraded is received, the structure corresponding to the module to be upgraded is called; the interface function in the structure corresponding to the module to be upgraded is run according to the upgrade process, so as to complete the upgrade of the module to be upgraded.
[0141] Optionally, the first module and the second module provide a unified external interface, and each external interface points to a link in the upgrade method respectively, so as to access the upgrade method through the external interface to assign values to the interface function in the preset structure.
[0142] In some examples, the processor 400 is configured to obtain a configuration file of an electronic device, where the configuration file is used to indicate an upgrade to a first module and a second module; if the configuration file indicates an upgrade to a third module and the third module is the same as the first module, reuse a first structure of the first module as a third structure of the third module; if an upgrade instruction for the third module is received, call the third structure of the third module; and run an interface function in the third structure of the third module according to an upgrade process to complete the upgrade of the third module.
[0143] In some examples, the processor 400 is configured to, if a management process receives an upgrade instruction for a module to be upgraded, call the management process to generate an upgrade management file for the module to be upgraded, where the upgrade management file is at least used to indicate an upgrade environment of the module to be upgraded; call the management process to send the upgrade management file of the module to be upgraded to an upgrade process; call the upgrade process to parse the upgrade management file of the module to be upgraded to verify whether a current operating environment of the electronic device matches the upgrade environment of the module to be upgraded; and if the current operating environment of the electronic device matches the upgrade environment of the module to be upgraded, call a structure corresponding to the module to be upgraded.
[0144] Among them, calling the management process to send the upgrade management file of the module to be upgraded to the upgrade process includes: calling the management process to create an upgrade task for the module to be upgraded, where the upgrade task carries the upgrade management file of the module to be upgraded; calling the management process to write the upgrade task of the module to be upgraded into an upgrade queue; and the upgrade process can read the upgrade task of the module to be upgraded from the upgrade queue to extract the upgrade management file of the module to be upgraded from the upgrade task of the module to be upgraded.
[0145] In some examples, the processor 400 is configured to, when an upgrade thread in the upgrade process runs an interface function in a structure corresponding to a module to be upgraded according to an upgrade process, use a recording thread in the upgrade process to record an upgrade status of the module to be upgraded; and use a reporting thread in the upgrade process to report the upgrade status of the module to be upgraded.
[0146] Among them, the upgrade status includes: a module identifier of the module to be upgraded, an upgrade result, a current upgrade operation, and an upgrade progress; the upgrade result is represented by an identifier in a preset upgrade result, and the current upgrade operation and the upgrade progress are used to indicate whether the upgrade is completed and the stage at which it is not completed.
[0147] An embodiment of the present application further provides a storage medium, in which computer program code is stored, and when the computer program code is executed, the above-mentioned upgrade method is implemented.
[0148] It should be noted that the various embodiments in this specification can be described in a progressive manner. The features described in each embodiment in this specification can be replaced or combined with each other. Each embodiment focuses on the differences from other embodiments. For the similarities between the various embodiments, reference can be made to each other. For device embodiments, since they are basically similar to method embodiments, they are described relatively simply. For the relevant parts, reference can be made to the partial description of the method embodiments.
[0149] Finally, it should also be noted that in this text, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
[0150] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0151] The above are only the preferred embodiments of the present application. It should be pointed out that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.
Claims
1. An upgrade method, the method comprising: Initializing interface functions in a preset structure by using the upgrade methods of a first module and a second module respectively to obtain a first structure of the first module and a second structure of the second module. The first structure and the second structure have the same interface functions and the same sorting of interface functions except for different parameter values. The preset structure corresponds to an upgrade process, the interface functions point to a link of the upgrade process, and the first module and the second module are two modules with different functions in an electronic device; For any module to be upgraded in the first module and the second module, if an upgrade instruction for the module to be upgraded is received, call the structure corresponding to the module to be upgraded; Run the interface functions in the structure corresponding to the module to be upgraded according to the upgrade process to complete the upgrade of the module to be upgraded.
2. The method according to claim 1, wherein the first module and the second module provide a unified external interface, and each external interface points to a link in the upgrade method to perform an assignment process on the interface functions in the preset structure by accessing the upgrade method through the external interface.
3. The method according to claim 1, the method further comprising: Obtaining a configuration file of the electronic device, the configuration file being used to indicate the upgrade of the first module and the second module; If the configuration file indicates the upgrade of a third module and the third module is the same as the first module, reusing the first structure of the first module as a third structure of the third module; If an upgrade instruction for the third module is received, call the third structure of the third module; Run the interface functions in the third structure of the third module according to the upgrade process to complete the upgrade of the third module.
4. The method according to claim 1, the method further comprising: If the management process receives an upgrade instruction for the module to be upgraded, calling the management process to generate an upgrade management file for the module to be upgraded, the upgrade management file being at least used to indicate the upgrade environment of the module to be upgraded; Calling the management process to send the upgrade management file of the module to be upgraded to the upgrade process; Calling the upgrade process to parse the upgrade management file of the module to be upgraded to verify whether the current operating environment of the electronic device matches the upgrade environment of the module to be upgraded; The step of "if an upgrade instruction for the module to be upgraded is received, call the structure corresponding to the module to be upgraded" includes: if the current operating environment of the electronic device matches the upgrade environment of the module to be upgraded, call the structure corresponding to the module to be upgraded.
5. The method according to claim 4, the step of "calling the management process to send the upgrade management file of the module to be upgraded to the upgrade process" includes: Calling the management process to create an upgrade task for the module to be upgraded, the upgrade task carrying the upgrade management file of the module to be upgraded; Calling the management process to write the upgrade task of the module to be upgraded into an upgrade queue; The upgrade process can read the upgrade task of the module to be upgraded from the upgrade queue, and extract the upgrade management file of the module to be upgraded from the upgrade task of the module to be upgraded.
6. The method according to claim 1, wherein the method further comprises: In the upgrade process, the upgrade thread runs the interface function in the structure corresponding to the module to be upgraded according to the upgrade process, and the record thread in the upgrade process records the upgrade status of the module to be upgraded; The reporting thread in the upgrade process reports the upgrade status of the module to be upgraded.
7. The method according to claim 6, wherein the upgrade status includes: The module identifier, upgrade result, current upgrade operation, and upgrade progress of the module to be upgraded; The upgrade result is represented by an identifier in a preset upgrade result, and the current upgrade operation and the upgrade progress are used to indicate whether the upgrade is completed and the stage when it is not completed.
8. An upgrade device, the device comprising: An initialization unit, configured to initialize the interface functions in a preset structure by using the upgrade methods of the first module and the second module respectively, to obtain the first structure of the first module and the second structure of the second module. Except for different parameter values, the interface functions and the sorting of the interface functions are the same. The preset structure corresponds to an upgrade process, the interface function points to a stage of the upgrade process, and the first module and the second module are two modules with different functions in an electronic device; A calling unit, configured to, for any module to be upgraded in the first module and the second module, if an upgrade instruction for the module to be upgraded is received, call the structure corresponding to the module to be upgraded; An operation unit, configured to run the interface function in the structure corresponding to the module to be upgraded according to the upgrade process, so as to complete the upgrade of the module to be upgraded.
9. An electronic device, the electronic device comprising: The first module, the second module, a memory, and a processor; The memory is configured to store a preset structure, the preset structure corresponds to an upgrade process, and the interface function points to a stage of the upgrade process; The processor is configured to initialize the interface functions in a preset structure by using the upgrade methods of the first module and the second module respectively, to obtain the first structure of the first module and the second structure of the second module. Except for different parameter values, the interface functions and the sorting of the interface functions are the same. The first module and the second module are two modules with different functions in an electronic device; for any module to be upgraded in the first module and the second module, if an upgrade instruction for the module to be upgraded is received, call the structure corresponding to the module to be upgraded; run the interface function in the structure corresponding to the module to be upgraded according to the upgrade process, so as to complete the upgrade of the module to be upgraded.
10. A storage medium storing computer program code, which when executed implements the upgrade method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for software upgrading
CN104156244A
Terminal system upgrading method and device
CN105138364A