Upgrading method for firmware in off-chip memory
By reading and comparing existing firmware and upgraded firmware in SOC off-chip memory, determining and writing differentiated first upgraded firmware modules are solved, and maintenance efficiency and storage space utilization are improved.
Patent Information
- Application Number
- CN202411855208.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-05-16
AI Technical Summary
There is a risk of failure in upgrading SOC off-chip firmware, and multiple versions of firmware take up a large storage space, reducing maintenance efficiency.
By reading the existing firmware to be upgraded and the upgraded firmware, comparing and determining the first upgraded firmware module, and writing it to off-chip memory, adopting a differentiated storage strategy to save storage space.
Improves the maintenance efficiency of off-chip firmware, reduces storage space usage, and ensures the reliability of the upgrade process.
Smart Images

Figure CN120010882A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of chip technology, and in particular to a method for upgrading firmware in an off-chip memory. Background Art
[0002] SOC (System-on-a-Chip) is an integrated circuit with a dedicated purpose, which contains all the contents of a complete system and embedded software. The firmware of SOC usually consists of multiple firmware modules. The firmware can have multiple historical version data at the same time. Any change in any firmware module will cause the firmware version to change.
[0003] The off-chip firmware of the SOC is stored in a firmware storage device such as an off-chip memory, and can be upgraded through a burning tool, but there is a risk of system abnormalities caused by upgrade failure. In addition, when there are multiple versions of the firmware, it often takes up a large storage space, making the maintenance efficiency of the off-chip firmware low. Summary of the invention
[0004] In view of this, the present application provides a method for upgrading firmware in an off-chip memory to improve the maintenance efficiency of the off-chip firmware.
[0005] In a first aspect, an embodiment of the present invention provides a method for upgrading firmware in an off-chip memory, comprising: reading existing firmware to be upgraded and upgrade firmware used to upgrade the existing firmware; wherein the existing firmware and the upgrade firmware respectively contain one or more firmware modules, and the firmware modules of the existing firmware are stored in the off-chip memory; comparing the upgrade firmware with the existing firmware to determine a first upgrade firmware module in the upgrade firmware, wherein the first upgrade firmware module is different from the firmware modules of the existing firmware, and the first upgrade firmware module is used to upgrade the first firmware module of the existing firmware; and writing the first upgrade firmware module into the off-chip memory.
[0006] In a specific implementation scheme, the first firmware module includes a first basic firmware module and a first historical upgrade firmware module for upgrading the first basic firmware module; the writing of the first upgrade firmware module to the off-chip memory includes: determining whether the amount of data of the existing firmware stored in the off-chip memory reaches a preset threshold, or determining whether the number of upgrades of the existing firmware reaches a preset threshold; if the preset threshold is reached, erasing the first historical upgrade firmware module and writing the first upgrade firmware module to the off-chip memory; or, erasing the first basic firmware module and the first historical upgrade firmware module, and writing the first upgrade firmware module to the off-chip memory; if the preset threshold is not reached, writing the first upgrade firmware module to the off-chip memory.
[0007] In a specific implementation, after writing the first upgraded firmware module into the off-chip memory, the method further includes: obtaining an initial list of firmware modules, wherein the initial list of firmware modules is used to characterize the various firmware modules of the firmware running by default; updating the initial list of firmware modules to obtain an updated list of firmware modules, wherein the updated list of firmware modules is used to characterize the various firmware modules of the firmware running at the current time; and running the firmware running at the current time based on the firmware module updated list.
[0008] In a specific implementation scheme, after writing the first upgrade firmware module into the off-chip memory, the method further includes: setting the firmware upgrade flag in the off-chip memory to the first flag; before updating the initial list of firmware modules, the method further includes: reading the firmware upgrade flag; if the firmware upgrade flag is the first flag, updating the firmware module represented by the initial list of firmware modules to the firmware module of the upgraded firmware; if the firmware upgrade flag is the second flag, updating the firmware module represented by the initial list of firmware modules to the firmware module of the currently selected firmware.
[0009] In a specific implementation scheme, the off-chip memory also stores identifiers of each firmware module of the existing firmware, labels of each firmware module of the existing firmware, and a version number of the existing firmware; wherein, if any firmware module of the existing firmware includes a basic firmware module and a historical upgraded firmware module for upgrading the basic firmware module, the label of the basic firmware module is the same as the label of the historical upgraded firmware module; after writing the first upgraded firmware module to the off-chip memory, the method further includes: writing the identifier of the first upgraded firmware module, the label of the first upgraded firmware module, and the version number of the upgraded firmware to the off-chip memory; wherein the label of the first upgraded firmware module is the same as the label of the first firmware module.
[0010] In a specific implementation scheme, the firmware module list records the identifiers of each firmware module of the default running firmware; the updating of the initial list of firmware modules includes: determining the identifiers of previously upgraded firmware modules, wherein the previously upgraded firmware modules refer to the newly added upgraded firmware modules in each upgrade from the default running firmware to the currently specified running firmware; determining the identifiers to be replaced in the initial list of firmware modules and the replacement identifiers in the identifiers of the previously upgraded firmware modules, wherein the firmware module corresponding to the identifier to be replaced has the same label as the firmware module corresponding to the replacement identifier; and replacing the identifiers to be replaced in the initial list of firmware modules with the identifiers in the replacement identifiers in turn according to the upgrade order of the firmware modules corresponding to the identifiers in the replacement identifiers.
[0011] In a specific implementation scheme, the identifiers of the firmware modules of the existing firmware and the identifier of the first upgrade firmware module are natural numbers arranged in sequence according to the upgrade order; the off-chip memory also stores the cumulative number of firmware modules corresponding to the version number of the existing firmware, wherein the cumulative number of firmware modules corresponding to the version number of the firmware refers to the number of different firmware modules contained in the firmware and the previous upgraded firmware; after writing the first upgrade firmware module into the off-chip memory, the method further includes: writing the cumulative number of firmware modules corresponding to the version number of the upgrade firmware into the off-chip memory; determining the identifiers of the previously upgraded firmware modules includes: determining the starting value of the identifiers of the previously upgraded firmware modules according to the cumulative number of firmware modules corresponding to the version number of the default running firmware; determining the ending value of the identifiers of the previously upgraded firmware modules according to the difference between the cumulative number of firmware modules corresponding to the version number of the firmware specified to be run this time and the cumulative number of firmware modules corresponding to the version number of the default running firmware; and determining the identifiers of the previously upgraded firmware modules according to the starting value and the ending value.
[0012] In a specific implementation scheme, after writing the first upgrade firmware module into the off-chip memory, the method further includes: reading the version number of the currently selected firmware from the off-chip memory; if the version number of the currently selected firmware is different from the version number of the upgrade firmware, and the upgrade firmware is successfully run, then updating the version number of the currently selected firmware stored in the off-chip memory to the version number of the upgrade firmware.
[0013] In a specific implementation, after writing the first upgrade firmware module into the off-chip memory, the method further includes: determining the version number of the rolled-back firmware; and updating the version number of the currently selected firmware stored in the off-chip memory to the version number of the rolled-back firmware.
[0014] In a second aspect, an embodiment of the present invention further provides a firmware upgrade method, comprising: reading an existing firmware to be upgraded and an upgrade firmware for upgrading the existing firmware; wherein the existing firmware and the upgrade firmware respectively contain one or more firmware modules; comparing the upgrade firmware with the existing firmware to determine a first upgrade firmware module in the upgrade firmware, wherein the first upgrade firmware module is different from the firmware modules of the existing firmware, and the first upgrade firmware module is used to upgrade the first firmware module of the existing firmware; generating an upgrade file for upgrading the existing firmware; wherein the upgrade file records the firmware modules of the existing firmware and the first upgrade firmware module.
[0015] In a specific implementation, after the upgrade file is generated, the method further includes: based on the upgrade file, writing the first upgrade firmware module into an off-chip memory; or, based on the upgrade file, writing each firmware module of the existing firmware and the first upgrade firmware module into an off-chip memory.
[0016] In a specific implementation scheme, the upgrade file further describes at least one of the following: an identifier of each firmware module of the existing firmware, a label of each firmware module of the existing firmware, a version number of the existing firmware, an identifier of the first upgrade firmware module, a label of the first upgrade firmware module, a version number of the upgrade firmware, a version number of the currently selected firmware, a cumulative number of firmware modules corresponding to the version number of the existing firmware, and a cumulative number of firmware modules corresponding to the version number of the upgrade firmware; wherein, if any firmware module of the existing firmware includes a basic firmware module and a historical upgrade firmware module for upgrading the basic firmware module, the label of the basic firmware module is the same as the label of the historical upgrade firmware module; the label of the first upgrade firmware module is the same as the label of the first firmware module; the cumulative number of firmware modules corresponding to the version number of the firmware refers to the number of different firmware modules contained in the firmware and the previous upgraded firmware; After generating the upgrade file, the method further includes: based on the upgrade file, writing at least one of the following items into an off-chip memory: an identifier of each firmware module of the existing firmware, a label of each firmware module of the existing firmware, a version number of the existing firmware, an identifier of the first upgrade firmware module, a label of the first upgrade firmware module, a version number of the upgrade firmware, a version number of the currently selected firmware, a cumulative number of firmware modules corresponding to the version number of the existing firmware, and a cumulative number of firmware modules corresponding to the version number of the upgrade firmware. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A flowchart of a method for upgrading firmware in an off-chip memory provided in an embodiment of the present application; Figure 2 A flowchart of the operation after the firmware upgrade in an off-chip memory provided in an embodiment of the present application; Figure 3 A flowchart of an initial list of updating firmware modules provided in an embodiment of the present application; Figure 4 A flowchart of programming an off-chip memory provided in an embodiment of the present application; Figure 5 A firmware operation flow chart of an off-chip memory provided in an embodiment of the present application; Figure 6A flowchart of an initial list of updating firmware modules provided in an embodiment of the present application; Figure 7 A flowchart of a synchronization firmware running state provided in an embodiment of the present application; Figure 8 A firmware operation flow chart of another off-chip memory provided in an embodiment of the present application; Fig. 9 A flowchart of another method for updating an initial list of firmware modules provided in an embodiment of the present application. DETAILED DESCRIPTION
[0019] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0020] It should be clear that the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0021] Firmware, or firmware file, is a program written into a firmware storage device such as an off-chip memory. The early processor startup process was simple. After the processor's internal hardware was initialized, the computing unit directly obtained the firmware from the off-chip memory for execution. As the complexity of processor logic increases, the latest processors mostly adopt SOC design. The processor usually has built-in on-chip firmware and stores it in BOOTROM (Boot Read-Only Memory, a read-only memory that stores the on-chip system startup program). An integrity verification circuit is designed for the on-chip firmware, so that the on-chip firmware can be used as a trusted root to load and verify the off-chip firmware in sequence, and then execute the off-chip firmware. Among them, on-chip refers to the internal environment of the processor, and off-chip refers to the external environment of the processor.
[0022] The off-chip firmware of SOC is stored in a firmware storage device such as an off-chip memory. The off-chip firmware is usually composed of multiple firmware modules. The firmware can have multiple historical version data at the same time. Any change in any firmware module will cause the firmware version to change. It can be upgraded through a burning tool, but there is a risk of system abnormality caused by upgrade failure. In addition, when there are multiple versions of the firmware, it often takes up a large storage space. Therefore, in order to improve the maintenance efficiency of the off-chip firmware, on the one hand, such as Figure 1 As shown, an embodiment of the present invention provides a method for upgrading firmware in an off-chip memory, and the method may include: S11, reading the existing firmware to be upgraded and the upgrade firmware for upgrading the existing firmware; wherein the existing firmware and the upgrade firmware respectively include one or more firmware modules, and the firmware modules of the existing firmware are stored in the off-chip memory.
[0023] In this embodiment, there may be multiple existing firmwares, each of which may correspond to a firmware version, and the upgrade firmware may be the latest current version used to upgrade the existing firmware. The existing firmware and the upgrade firmware may respectively contain one or more firmware modules. Reading the existing firmware means reading the firmware modules contained in the existing firmware, and reading the upgrade firmware means reading the firmware modules contained in the upgrade firmware, wherein the firmware modules of the existing firmware are stored in the off-chip memory. Specifically, the off-chip memory may store the different firmware modules of the existing firmware to avoid repeated storage of the firmware modules commonly contained in multiple firmwares. Based on the firmware modules of the existing firmware stored in the off-chip memory, the corresponding version of the existing firmware may be constructed. The firmware modules included in the upgrade firmware may be some firmware modules that are different from the firmware modules stored in the off-chip memory, or all firmware modules that are different from the firmware modules stored in the off-chip memory.
[0024] S12: Compare the upgrade firmware with the existing firmware to determine a first upgrade firmware module in the upgrade firmware, wherein the first upgrade firmware module is different from each firmware module of the existing firmware, and the first upgrade firmware module is used to upgrade the first firmware module of the existing firmware.
[0025] It can be understood that if the firmware module of the upgraded firmware is the same as the firmware module of the existing firmware, if all the firmware modules of the upgraded firmware are stored in the off-chip memory, the same firmware module will be stored repeatedly, resulting in reduced storage space utilization of the off-chip memory and reduced production capacity utilization of the production line. At the same time, repeatedly burning the same firmware module into the off-chip memory will increase the complexity of the production process and the possibility of production anomalies, such as processor system anomalies caused by burning anomalies.
[0026] Therefore, in this embodiment, the upgrade firmware is compared with the existing firmware stored in the off-chip memory, that is, the firmware module of the upgrade firmware is compared with the firmware module of the existing firmware in the off-chip memory, and the first upgrade firmware module in the upgrade firmware is determined. The first upgrade firmware module is a difference firmware module between the upgrade firmware and the existing firmware, that is, the first upgrade firmware module is different from each firmware module of the existing firmware, and the first upgrade firmware module is used to upgrade the first firmware module of the existing firmware. The number of the first upgrade firmware modules can be one or more.
[0027] S13, writing the first upgrade firmware module into an off-chip memory.
[0028] After the first upgrade firmware module is determined, only the first upgrade firmware module is written to the off-chip memory. Since the off-chip memory also stores the firmware modules of the existing firmware, if the upgrade firmware and the existing firmware have the same firmware module, the upgrade firmware can be obtained by reading the same firmware module and the written first upgrade firmware module from the off-chip memory.
[0029] For example, as shown in Table 1 below, firmware E01 includes firmware modules fw1.bin_v01, fw2.bin_v01, fw3.bin_v01, and fw4.bin_v01. At this time, the off-chip memory stores firmware modules fw1.bin_v01, fw2.bin_v01, fw3.bin_v01, and fw4.bin_v01. If firmware E01 needs to be upgraded to firmware E02, firmware E02 includes firmware modules fw1.bin_v01, fw2.bin_v01, and fw3.bin_v01. fw3.bin_v02 ,fw4.bin_v01.
[0030] According to the method of this embodiment, the firmware module of firmware E01 is the firmware module of the existing firmware, and firmware E02 is the upgraded firmware. The firmware module of firmware E02 is compared with the firmware module of the existing firmware to determine the first upgraded firmware module. fw3.bin_v02 Therefore, only the first firmware upgrade module needs to be fw3.bin_v02 The firmware modules of firmware E01 are also retained. At this time, the firmware modules fw1.bin_v01, fw2.bin_v01, fw3.bin_v01, fw4.bin_v01, fw3.bin_v02 Thus, when the firmware E02 needs to be run, the firmware modules fw1.bin_v01, fw2.bin_v01, fw3.bin_v02 , fw4.bin_v01, and when it is necessary to roll back to firmware E01, the firmware modules fw1.bin_v01, fw2.bin_v01, fw3.bin_v01, and fw4.bin_v01 included in firmware E01 can also be read from the off-chip memory.
[0031]
[0032] It can be seen that this embodiment only stores the difference firmware module of the upgraded firmware compared with the existing firmware, that is, the storage strategy of the first upgraded firmware module, which not only saves the storage space of the off-chip memory, but also ensures the integrity of each firmware module of the upgraded firmware and each firmware module of the existing firmware. According to the firmware modules of the existing firmware stored in the off-chip memory and the first upgraded firmware module, the upgraded firmware or the corresponding version of the existing firmware can be obtained.
[0033] The embodiment of the present invention provides a method for upgrading firmware in an off-chip memory, which reads the existing firmware to be upgraded and the upgrade firmware used to upgrade the existing firmware; wherein the existing firmware and the upgrade firmware respectively contain more than one firmware module, and the firmware modules of the existing firmware are stored in the off-chip memory; then the upgrade firmware is compared with the existing firmware to determine the first upgrade firmware module in the upgrade firmware, wherein the first upgrade firmware module is different from the firmware modules of the existing firmware, and the first upgrade firmware module is used to upgrade the first firmware module of the existing firmware; then the first upgrade firmware module can be written into the off-chip memory. This method adopts a differentiated storage strategy for firmware modules for the existing firmware and the upgrade firmware, which can not only save the storage space of the off-chip memory, but also run the specified version of the firmware, thereby improving the maintenance efficiency of the firmware in the off-chip memory.
[0034] With the continuous upgrade and update of the off-chip firmware, there will be more and more firmware versions and corresponding firmware modules. The continuously accumulated data of the firmware modules will occupy the storage space of the off-chip memory, and the data of the older and less commonly used firmware versions will reduce the storage space utilization of the off-chip memory. To solve this problem, optionally, in one embodiment of the present invention, the first firmware module includes a first basic firmware module and a first historical upgrade firmware module for upgrading the first basic firmware module; step S13 writes the first upgrade firmware module to the off-chip memory, including: determining whether the data amount of the existing firmware stored in the off-chip memory reaches a preset threshold, or determining whether the number of upgrades of the existing firmware reaches a preset threshold; if the preset threshold is reached, erasing the first historical upgrade firmware module and writing the first upgrade firmware module to the off-chip memory; or, erasing the first basic firmware module and the first historical upgrade firmware module, and writing the first upgrade firmware module to the off-chip memory; if the preset threshold is not reached, writing the first upgrade firmware module to the off-chip memory.
[0035] Each firmware often has an initial version, and the firmware module corresponding to the initial version is a basic firmware module. For defects or deficiencies of the basic firmware module, the basic firmware module is often replaced by upgrading. For example, for a certain basic firmware module, it is currently necessary to upgrade it with an upgraded firmware module, and for this certain basic firmware module, it may have been upgraded with a historical upgraded firmware module. Specifically, for the first firmware module of this embodiment, it can include the first basic firmware module in the initial version, and it can also include the first historical upgraded firmware module obtained by upgrading the first basic firmware module in the historical upgraded version, and the first upgraded firmware module currently determined can be used to upgrade the first basic firmware module and the first historical upgraded firmware module. In order to improve the utilization rate of the storage space of the off-chip memory, this embodiment determines whether the data volume of the existing firmware stored in the off-chip memory reaches a preset threshold, or determines whether the number of upgrades of the existing firmware reaches a preset threshold, so as to adopt different storage strategies. For example, if the preset threshold is reached, the first basic firmware module is erased, or the first historical upgraded firmware module is further erased, and then the first upgraded firmware module is written to the off-chip memory, which is conducive to improving the utilization rate of the storage space of the off-chip memory.
[0036] For example, as shown in Table 2 below, firmware E01 includes basic firmware modules fw1.bin_v01, fw2.bin_v01, fw3.bin_v01, and fw4.bin_v01. At this time, the basic firmware modules fw1.bin_v01, fw2.bin_v01, fw3.bin_v01, and fw4.bin_v01 are stored in the off-chip memory. If firmware E01 needs to be upgraded to firmware E02, firmware E02 includes firmware modules fw1.bin_v01, fw2.bin_v01, and fw4.bin_v01. fw3.bin_v02 , fw4.bin_v01, compare the firmware module of firmware E02 with the firmware module of firmware E01, and determine the first upgraded firmware module fw3.bin_v02 According to the method of this embodiment, if the preset threshold is reached, the basic firmware module fw3.bin_v01 in the off-chip memory can be erased, and then the first upgrade firmware module fw3.bin_v02 Write to off-chip memory.
[0037]
[0038] As another example, as shown in Table 3, in the historical upgrade process of upgrading firmware E01 to firmware E02, the first historical upgrade firmware module fw3.bin_v02 Used to upgrade the first basic firmware module fw3.bin_v01. Currently, firmware E02 needs to be upgraded to firmware E03. The firmware module of firmware E03 is compared with the firmware module of firmware E02 to determine the first upgraded firmware module. fw3.bin_v03 , the first upgrade firmware module fw3.bin_v03 Can be used to upgrade the first basic firmware module fw3.bin_v01 and the first historical upgrade firmware module fw3.bin_v02 According to the method of this embodiment, if the preset threshold is reached, the first basic firmware module fw3.bin_v01 in the off-chip memory and the first historical upgrade firmware module fw3.bin_v02 Erase and then upgrade the firmware module first fw3.bin_v03 Write to off-chip memory.
[0039]
[0040] It can be seen that this method facilitates further differentiated management of the firmware modules stored in the off-chip memory, and when the storage space is insufficient, the storage space occupied by the off-chip memory can be reduced. Furthermore, based on this method, other basic firmware modules or other historical upgraded firmware modules of the existing firmware in the off-chip memory can be selectively erased, and the corresponding redundant firmware versions can be cleared, and the required firmware versions can be retained, thereby reducing the number of firmware modules stored in the off-chip memory and improving the retrieval speed of the retained firmware modules.
[0041] Optional, such as Figure 2 As shown, in one embodiment of the present invention, after writing the first upgrade firmware module into the off-chip memory, the method further includes: S21. Obtain an initial list of firmware modules, wherein the initial list of firmware modules is used to represent each firmware module of the firmware running by default.
[0042] The initial list of firmware modules can be used to characterize each firmware module of the default running firmware. For example, the default running firmware can be preset as the initial version of the firmware. In this way, each firmware module characterized by the initial list of firmware modules is a basic firmware module included in the initial version of the firmware. There are many methods for characterization. For example, each firmware module stored in the off-chip memory can be configured with a unique identifier, and the corresponding firmware module can be determined according to the identifier. The initial list of firmware modules can characterize the corresponding firmware module based on the identifier.
[0043] S22: Update the initial list of firmware modules to obtain an updated list of firmware modules, where the updated list of firmware modules is used to represent each firmware module of the firmware that is currently specified to be run.
[0044] The firmware specified to be run this time can be the latest upgraded version of the firmware or a historical version of the firmware. The initial list of firmware modules is updated, that is, the firmware modules represented by the initial list of firmware modules are updated to the firmware modules included in the firmware specified to be run this time, thereby obtaining a firmware module update list.
[0045] S23. Based on the firmware module update list, run the firmware that is designated to run at that time.
[0046] Based on the solution of this embodiment, by storing the firmware modules of each firmware in the off-chip memory, after obtaining the firmware module update list, each firmware module represented by the firmware module update list can be loaded and run, that is, the firmware specified to be run at that time can be loaded and run. In this way, when storing the firmware modules of each firmware in the off-chip memory, only the firmware modules that are different from each other of the firmware can be stored; for the firmware modules commonly included in multiple firmwares, repeated storage can be avoided, thereby improving the utilization rate of the storage space of the off-chip memory.
[0047] During the upgrade process of the off-chip firmware, after the first upgrade firmware module of the new version of the firmware is written into the off-chip memory, when the processor runs the off-chip firmware, it is necessary to determine whether to load and run the original version of the firmware or load and run the new version of the firmware. Therefore, optionally, in one embodiment of the present invention, after the first upgrade firmware module is written into the off-chip memory in step S13, the upgrade method further includes: setting the firmware upgrade flag in the off-chip memory to the first flag; before updating the initial list of firmware modules in step S22, the upgrade method further includes: reading the firmware upgrade flag; if the firmware upgrade flag is the first flag, updating the firmware module represented by the initial list of firmware modules to the firmware module of the upgrade firmware; if the firmware upgrade flag is the second flag, updating the firmware module represented by the initial list of firmware modules to the firmware module corresponding to the version number of the currently selected firmware.
[0048] The first flag bit can be used to indicate that the latest version of the upgrade firmware is written into the current off-chip memory, and the latest version of the upgrade firmware needs to be loaded and run. The second flag bit can be used to indicate that the currently selected firmware is loaded in normal mode. The currently selected firmware can be any historical version of the firmware selected by the user. By setting the firmware upgrade flag bit to the first flag bit, when the processor starts, the initial list of firmware modules is updated according to the firmware upgrade flag bit. Specifically, if the firmware upgrade flag bit is the first flag bit, the firmware module represented by the initial list of firmware modules is updated to the firmware module of the upgrade firmware to load and run the upgrade firmware; if the firmware upgrade flag bit is the second flag bit, the firmware module represented by the initial list of firmware modules is updated to the firmware module corresponding to the version number of the currently selected firmware to load and run the version number of the currently selected firmware.
[0049] Preferably, in some embodiments, if the firmware upgrade flag is the first flag, the firmware module represented by the initial list of firmware modules is updated to the firmware module of the upgraded firmware, and the firmware upgrade flag in the off-chip memory is set to the second flag. In this way, the processor can still load the currently selected firmware selected by the user in the normal mode when it is started next time.
[0050] After writing each firmware module in the off-chip memory, in order to facilitate reading the corresponding firmware module, optionally, in one embodiment of the present invention, the off-chip memory also stores the identifier of each firmware module of the existing firmware, the label of each firmware module of the existing firmware, and the version number of the existing firmware; wherein, if any firmware module of the existing firmware includes a basic firmware module and a historical upgrade firmware module for upgrading the basic firmware module, then the label of the basic firmware module is the same as the label of the historical upgrade firmware module; after writing the first upgrade firmware module to the off-chip memory in step S13, the upgrade method further includes: writing the identifier of the first upgrade firmware module, the label of the first upgrade firmware module, and the version number of the upgrade firmware to the off-chip memory; wherein, the label of the first upgrade firmware module is the same as the label of the first firmware module.
[0051] As mentioned above, the identifier of each firmware module can be a unique identifier. For example, the identifier of each firmware module can be compiled based on coding rules, and the corresponding firmware module can be determined according to the identifier. In this way, the initial list of firmware modules can be updated according to the identifier of the firmware module to obtain a firmware module update list to load and run the corresponding firmware.
[0052] For example, as shown in Table 4, if firmware E01 is updated to firmware E02, the firmware modules represented by the initial list of firmware modules need to be updated to the firmware modules of firmware E02. The firmware modules of firmware E01 are: fw1.bin_v01, fw2.bin_v01, fw3.bin_v01, fw4.bin_v01, and the corresponding firmware module identifiers are: 0, 1, 2, 3, respectively. The firmware modules of firmware E02 are: fw1.bin_v01, fw2.bin_v01, fw3.bin_v02, fw4.bin_v01, and the corresponding firmware module identifiers are: 0, 1, 4, 3, respectively. Therefore, the initial list of firmware modules can be updated according to the identifiers 0, 1, 4, 3.
[0053] If the firmware modules represented by the initial list of firmware modules are the initial firmware, that is, the firmware modules of firmware E01, then the initial list of firmware modules can use identifiers 0, 1, 2, and 3 to represent the firmware modules of firmware E01, and firmware E02, as an upgraded firmware for upgrading firmware E01, can use the identifiers 0, 1, 4, and 3 of the firmware modules of firmware E02 to update the firmware modules represented by the initial list of firmware modules, so that the firmware module update list can use identifiers 0, 1, 4, and 3 to represent the firmware modules of firmware E02, thereby loading and running the firmware modules of firmware E02 according to the firmware module update list.
[0054]
[0055] At the same time, in this embodiment, for any firmware module of the existing firmware, if the firmware module includes a basic firmware module and a historical upgraded firmware module that upgrades the basic firmware module, the label of the basic firmware module and the label of the historical upgraded firmware module are set to the same label, so that it is convenient to determine the corresponding basic firmware module and historical upgraded firmware module according to the same label. For example, as shown in Table 5, the labels configured for each firmware module of the initial version firmware E01 are: fw1.bin_v01 label is c0, fw2.bin_v01 label is c1, fw3.bin_v01 label is c2, and fw4.bin_v01 label is c3. The second version firmware E02 includes a historical upgrade firmware module fw3.bin_v02. The historical upgrade firmware module fw3.bin_v02 is used to upgrade the basic firmware module fw3.bin_v01 in firmware E01. The label of the historical upgrade firmware module fw3.bin_v02 can be set to the same label c2 as the corresponding label of the basic firmware module fw3.bin_v01. For the third version of firmware, i.e., the current upgrade firmware E03, the upgrade firmware E03 is compared with the firmware E02 to determine the first upgrade firmware modules fw2.bin_v02 and fw3.bin_v03, and the label of the first upgrade firmware module fw2.bin_v02 and the label of the corresponding first firmware module fw2.bin_v01 can be set to the same label c1; and the first firmware module corresponding to the first upgrade firmware module fw3.bin_v03 includes the first basic firmware module fw3.bin_v01 and the first historical upgrade firmware module fw3.bin_v02, so the label of the first upgrade firmware module fw3.bin_v03, the label of the corresponding first basic firmware module fw3.bin_v01, and the label of the first historical upgrade firmware module fw3.bin_v02 can be set to the same label c2. Through the above label setting method, it is convenient to determine the corresponding first firmware module and the first upgrade firmware module used to upgrade the first firmware module by comparing the same labels.
[0056]
[0057] In addition, in this embodiment, the off-chip memory also stores the version number of the existing firmware and the version number of the upgraded firmware, so as to determine the corresponding firmware according to the version number and implement the backtracking operation of the historical version firmware.
[0058] Optional, such as Figure 3 As shown, in one embodiment of the present invention, the firmware module list records the identifiers of each firmware module of the default running firmware; step S22 updates the initial firmware module list, including: S221. Determine identifiers of previously upgraded firmware modules, where the previously upgraded firmware modules refer to newly added upgraded firmware modules in each upgrade from the default running firmware to the currently designated running firmware.
[0059] S222: Determine the identifiers to be replaced in the initial list of firmware modules and the replacement identifiers in the identifiers of previously upgraded firmware modules, wherein the firmware module corresponding to the identifier to be replaced and the firmware module corresponding to the replacement identifier have the same label.
[0060] S223. According to the upgrade order of the firmware modules corresponding to the identifiers in the replacement identifiers, the identifiers in the replacement identifiers are used in sequence to replace the identifiers to be replaced in the initial list of the firmware modules.
[0061] Based on the identifiers and labels set for each firmware module in the off-chip memory, the initial list of firmware modules can be very conveniently updated. For example, as shown in Table 5, if the default running firmware is the initial version firmware E01, the initial list of firmware modules can record the identifiers 0, 1, 2, and 3 of each firmware module of the default running firmware E01. For the third version firmware E03, the determined previously upgraded firmware modules include: the newly added upgraded firmware module fw3.bin_v02 in the upgrade from the initial version firmware E01 to the second version firmware E02, and the newly added upgraded firmware modules fw2.bin_v02 and fw3.bin_v03 in the upgrade from the second version firmware E02 to the third version firmware E03. The corresponding identifiers of the previously upgraded firmware modules are: identifier 4 of fw3.bin_v02, identifier 5 of fw2.bin_v02, and identifier 6 of fw3.bin_v03.
[0062] Since the firmware module fw2.bin_v01 represented by the firmware module initial list and the previously upgraded firmware module fw2.bin_v02 have the same label c1, the identifier 1 used to represent the firmware module fw2.bin_v01 in the firmware module initial list can be determined as the identifier to be replaced, and the identifier 5 of the previously upgraded firmware module fw2.bin_v02 can be determined as the replacement identifier. Then the replacement identifier 5 can be used to replace the identifier 1 to be replaced in the firmware module initial list, and 0, 5, 2, and 3 are obtained.
[0063] Furthermore, since the firmware module fw3.bin_v01 represented by the initial list of firmware modules has the same label c2 as the previously upgraded firmware modules fw3.bin_v02 and fw3.bin_v03, the identifier 2 used to represent the firmware module fw3.bin_v01 in the initial list of firmware modules can be determined as the identifier to be replaced, and the identifier 4 of the previously upgraded firmware module fw3.bin_v02 and the identifier 6 of the previously upgraded firmware module fw3.bin_v03 can be determined as the replacement identifiers, and then according to the upgrade order of the firmware modules fw3.bin_v02 and fw3.bin_v03 corresponding to the identifiers 4 and 6 in the replacement identifiers, the identifier 2 to be replaced in the initial list of firmware modules is replaced with the identifiers 4 and 6 in the replacement identifiers in turn, and finally 0, 5, 6, and 3 are obtained, so that the firmware module update list can be obtained. Based on the identifiers 0, 5, 6, and 3 recorded in the firmware module update list, each firmware module of the third version firmware E03 can be determined, and then the corresponding third version firmware E03 can be loaded and run.
[0064] Optionally, in one embodiment of the present invention, the identifiers of the firmware modules of the existing firmware and the identifier of the first upgraded firmware module are natural numbers arranged in sequence according to the upgrade order; the off-chip memory further stores the cumulative number of firmware modules corresponding to the version number of the existing firmware, wherein the cumulative number of firmware modules corresponding to the version number of the firmware refers to the number of different firmware modules contained in the firmware and the previous upgraded firmware; After writing the first upgrade firmware module into the off-chip memory in step S13, the upgrade method further includes: writing the accumulated number of firmware modules corresponding to the version number of the upgrade firmware into the off-chip memory; Step S221 determines the identifiers of the firmware modules that have been upgraded, including: S2211. Determine the starting value of the identifier of each firmware module that has been upgraded previously according to the accumulated number of firmware modules corresponding to the version number of the default running firmware.
[0065] S2212: Determine the end value of the identifier of the firmware module that has been upgraded previously according to the difference between the cumulative number of firmware modules corresponding to the version number of the firmware that is currently designated to be run and the cumulative number of firmware modules corresponding to the version number of the firmware that is currently run by default.
[0066] S2213: Determine the identifier of each firmware module that has been upgraded previously according to the start value and the end value.
[0067] The identifiers of the firmware modules stored in the off-chip memory are arranged in natural numbers according to the upgrade order, and the cumulative number of firmware modules corresponding to the version number of each firmware is stored, which can further facilitate the determination of the corresponding firmware module and update the initial list of firmware modules.
[0068] For example, as shown in Table 5 above and Table 6 below, if the default running firmware is the initial version firmware E01, the cumulative number of firmware modules corresponding to the version number of firmware E01 is 4 (respectively fw1.bin_v01, fw2.bin_v01, fw3.bin_v01, fw4.bin_v01). The number of different firmware modules contained in firmware E02 and the previous upgraded firmware E01 is 5 (respectively fw1.bin_v01, fw2.bin_v01, fw3.bin_v01, fw4.bin_v01, fw3.bin_v02), so the cumulative number of firmware modules corresponding to the version number of firmware E02 is 5. The number of different firmware modules contained in firmware E03 and the previous upgraded firmware E01 and firmware E02 is 7 (respectively fw1.bin_v01, fw2.bin_v01, fw3.bin_v01, fw4.bin_v01, fw3.bin_v02, fw2.bin_v02, fw3.bin_v03), so the cumulative number of firmware modules corresponding to the version number of firmware E03 is 7.
[0069] According to the cumulative number of firmware modules 4 corresponding to the version number Base of the default running firmware E01, the starting value of the identifier of the firmware module upgraded in succession can be determined, for example, the starting value is 4.
[0070] The difference between the cumulative number of firmware modules corresponding to the version number of the firmware specified to be run at the time, such as the version number B of firmware E03, and the cumulative number of firmware modules corresponding to the version number Base of the default firmware E01 can be used as a reference value, and the reference value is 3, so as to determine the end value of the identifier of the firmware module that has been upgraded in the past. For example, the end value = the starting value + the reference value of the number -1, and the corresponding end value can be 6; according to the starting value 4 and the end value 6, it can be determined that the identifiers of the firmware modules that have been upgraded in the past are 4, 5, and 6 respectively. It can be seen that the identifiers of the firmware modules stored in the off-chip memory are arranged in sequence based on natural numbers, which can further facilitate the determination of the identifiers of the firmware modules, and is conducive to improving the updating efficiency of the initial list of firmware modules and the loading and running efficiency of the firmware.
[0071]
[0072] During the upgrade process of the off-chip firmware, upgrade failure may also occur. In this case, the new version of the firmware cannot be loaded and run normally. In this case, if it is not possible to roll back to the original version of the firmware, it may cause immeasurable losses and affect the user experience. Therefore, optionally, in one embodiment of the present invention, after writing the first upgrade firmware module to the off-chip memory, the upgrade method also includes: reading the version number of the currently selected firmware from the off-chip memory; if the version number of the currently selected firmware is different from the version number of the upgrade firmware, and the upgrade firmware is successfully run, then the version number of the currently selected firmware stored in the off-chip memory is updated to the version number of the upgrade firmware.
[0073] As mentioned above, the currently selected firmware can be any historical version of the firmware selected by the user. As shown in Table 6, the version number of the currently selected firmware can be stored in the off-chip memory. By judging whether the upgrade firmware is loaded and run normally, the version number of the currently selected firmware is updated to the version number of the upgrade firmware if the upgrade firmware is loaded and run normally. If the upgrade firmware is not loaded and run normally, the version number of the currently selected firmware is not updated. In this way, even if the upgrade fails, the original version of the firmware can still be loaded and run during the next startup and operation, thereby ensuring the reliability and maintainability of the off-chip firmware upgrade.
[0074] Since a differentiated storage strategy is adopted for the firmware modules of the upgraded firmware, and the version number of the corresponding firmware is stored in the off-chip memory during each upgrade process, in order to be able to roll back to any historical version of the firmware, optionally, in one embodiment of the present invention, after writing the first upgraded firmware module to the off-chip memory in step S13, the upgrade method also includes: determining the version number of the rolled back firmware; and updating the version number of the currently selected firmware stored in the off-chip memory to the version number of the rolled back firmware.
[0075] Through this method, after the off-chip firmware is updated and upgraded, in a subsequent operation process, the version number of the rolled back firmware can be selected as needed, and the version number of the currently selected firmware stored in the off-chip memory can be updated to the version number of the rolled back firmware. Since this embodiment adopts differentiated storage for firmware modules, the firmware module corresponding to the version number of the rolled back firmware can be read and loaded according to the version number of the rolled back firmware, thereby realizing the rollback operation of the off-chip firmware.
[0076] In summary, this embodiment specifically provides an example of a method for upgrading firmware in an off-chip memory, such as Figure 4 As shown, the following steps are included: First, step S101 is used to determine whether it is in the burning mode, that is, whether the relevant firmware module needs to be burned into the external memory. For example, if the currently selected firmware is a historical version of the firmware, it is not necessary to burn the relevant firmware module into the external memory. If it is the upgraded firmware of the aforementioned step S12, it is necessary to burn the new firmware module into the external memory.
[0077] If a firmware module needs to be burned into the off-chip memory, the upgrade firmware can be read in step S102, the existing firmware in the off-chip memory can be read in step S103, and then the upgrade firmware and the existing firmware are compared in step S104 to determine the first upgrade firmware module.
[0078] In step S105, the corresponding firmware module in the off-chip memory may be erased according to whether the data volume of the existing firmware stored in the off-chip memory or the number of upgrades of the existing firmware reaches a preset threshold, for example, the first basic firmware module and the first historical upgrade firmware module corresponding to the first upgrade firmware module may be erased to save storage space of the off-chip memory. Then, in step S106, the first upgrade firmware module is burned into the off-chip memory.
[0079] If there is no need to burn the firmware module into the external memory, the operating information in the external memory can be updated according to the version number of the currently selected firmware through step S107. For example, if the user selects the version number of the rolled-back firmware, the version number of the currently selected firmware stored in the external memory can be changed to the version number of the rolled-back firmware to load and run the rolled-back firmware.
[0080] After the first upgrade firmware module is burned into the off-chip memory or the operation information in the off-chip memory is updated, during the firmware operation, the Figure 5 As shown, in step S201, an initial list of firmware modules is obtained; in step S202, the initial list of firmware modules is updated to obtain an updated list of firmware modules; in step S203, the firmware modules are sequentially loaded and run according to the updated list of firmware modules; in step S204, the firmware running status is synchronized, for example, if the upgraded firmware is successfully run, the version number of the currently selected firmware stored in the off-chip memory can be synchronously updated to the version number of the upgraded firmware.
[0081] In the process of updating the initial list of firmware modules in step S202, the following may be specifically described: Figure 6As shown, the firmware upgrade flag is read in step S2021. If the firmware upgrade flag is the first flag, it is in upgrade mode. The firmware upgrade flag can be set to the second flag in step S2022, and then the update information and existing information of the off-chip memory are read in step S2023. For example, the update information may include an identifier of the first upgrade firmware module, a label of the first upgrade firmware module, and a version number of the upgrade firmware. The existing information may include identifiers of each firmware module of the existing firmware, labels of each firmware module of the existing firmware, and a version number of the existing firmware, etc., and then the relevant operating information of the currently selected firmware, that is, the relevant operating information of the upgrade firmware, such as identifiers and labels of each firmware module of the upgrade firmware, can be determined in step S2025.
[0082] If the firmware upgrade flag is the second flag, it is in normal mode, and the existing information in the off-chip memory can be read in step S2024, for example, the existing information can include the identifiers of each firmware module of the existing firmware, the labels of each firmware module of the existing firmware, and the version number of the existing firmware, and then the relevant operation information of the currently selected firmware can be determined in step S2025, such as the identifiers and labels of each firmware module of the currently selected firmware. Among them, the version number of the currently selected firmware can be stored in the off-chip memory, and the user can modify the version number of the currently selected firmware in the off-chip memory according to the use requirements, so as to facilitate rolling back to any historical version of the firmware.
[0083] Then, in step S2026, the initial firmware module list can be updated according to the relevant operation information of the currently selected firmware to obtain the firmware module update list, wherein the initial firmware module list is used to represent each firmware module of the default running firmware, and the firmware module update list is used to represent each firmware module of the currently selected firmware.
[0084] In the process of synchronizing the firmware running status in step S204, the specific steps are as follows: Figure 7 As shown, first, step S2041 reads the version number of the currently selected firmware from the off-chip memory, and then step S2042 compares the version number of the currently selected firmware with the version number of the upgrade firmware. If step S2043 determines that the version number of the currently selected firmware and the version number of the upgrade firmware are the same, the process ends. If they are different, step S2044 detects whether the upgrade firmware runs successfully. If the upgrade firmware fails to run successfully, the process ends. If the upgrade firmware runs successfully, the version number of the currently selected firmware in the off-chip memory is updated to the version number of the upgrade firmware in step S2045.
[0085] In addition, in a specific application scenario, for example, when it is not necessary to configure the off-chip memory with information such as the version number of the currently selected firmware, the firmware can also be used as follows during the firmware operation. Figure 8As shown, only step S201 is used to obtain the initial list of firmware modules, step S202 is used to update the initial list of firmware modules, and the firmware module update list is obtained. Step S203 is used to load and run the firmware modules in sequence according to the firmware module update list. In the process of updating the initial list of firmware modules in step S202, the following specific steps can be performed: Fig. 9 As shown, in step S2023, the update information and existing information of the off-chip memory are read, for example, the update information may include the identifier of the first upgraded firmware module, and the existing information includes the identifiers of each firmware module of the existing firmware, etc., and then the relevant operation information of the currently selected firmware, such as the identifiers and labels of each firmware module of the currently selected firmware, may be determined in step S2025. Then, in step S2026, according to the relevant operation information of the currently selected firmware, the initial list of firmware modules is updated to obtain the firmware module update list. The above steps can also realize the correct loading and operation of the currently selected firmware, and multiple historical versions of firmware can also exist at the same time, and any historical version of firmware can be rolled back to run according to needs.
[0086] In a second aspect, an embodiment of the present invention further provides a firmware upgrade method, comprising: S31, reading the existing firmware to be upgraded and the upgrade firmware for upgrading the existing firmware; wherein the existing firmware and the upgrade firmware respectively include one or more firmware modules.
[0087] S32: Compare the upgrade firmware with the existing firmware to determine a first upgrade firmware module in the upgrade firmware, wherein the first upgrade firmware module is different from each firmware module of the existing firmware, and the first upgrade firmware module is used to upgrade the first firmware module of the existing firmware.
[0088] S33, generating an upgrade file for upgrading the existing firmware; wherein the upgrade file records each firmware module of the existing firmware and the first upgrade firmware module.
[0089] After the upgrade file is generated by the above method, different usage requirements can be met according to the upgrade file. For example, the upgrade file can be released to users, so that users can obtain the firmware modules included in the upgrade firmware or the firmware modules included in the existing firmware according to the upgrade file. Users can also write all the firmware modules included in the upgrade file to the off-chip memory or other storage device according to the upgrade file, so as to obtain various versions of firmware, or selectively write certain firmware modules included in the upgrade file, so as to obtain the corresponding version of firmware.
[0090] Optionally, in one embodiment of the present invention, after step S33 generates the upgrade file, the method further includes: based on the upgrade file, writing the first upgrade firmware module into the off-chip memory; or, based on the upgrade file, writing the firmware modules of the existing firmware and the first upgrade firmware module into the off-chip memory.
[0091] Optionally, in one embodiment of the present invention, the upgrade file further expresses at least one of the following: an identifier of each firmware module of the existing firmware, a label of each firmware module of the existing firmware, a version number of the existing firmware, an identifier of the first upgrade firmware module, a label of the first upgrade firmware module, a version number of the upgrade firmware, a version number of the currently selected firmware, a cumulative number of firmware modules corresponding to the version number of the existing firmware, and a cumulative number of firmware modules corresponding to the version number of the upgrade firmware; wherein, if any firmware module of the existing firmware includes a basic firmware module and a historical upgrade firmware module for upgrading the basic firmware module, the label of the basic firmware module is the same as the label of the historical upgrade firmware module; the label of the first upgrade firmware module is the same as the label of the first firmware module; the cumulative number of firmware modules corresponding to the version number of the firmware refers to the number of different firmware modules included in the firmware and the previous upgraded firmware; After step S33 generates the upgrade file, the upgrade method also includes: based on the upgrade file, writing at least one of the following items in the off-chip memory: the identifier of each firmware module of the existing firmware, the label of each firmware module of the existing firmware, the version number of the existing firmware, the identifier of the first upgrade firmware module, the label of the first upgrade firmware module, the version number of the upgrade firmware, the version number of the currently selected firmware, the cumulative number of firmware modules corresponding to the version number of the existing firmware, and the cumulative number of firmware modules corresponding to the version number of the upgrade firmware.
[0092] After writing the firmware modules included in the upgrade file in the off-chip memory, further writing the above information in the off-chip memory can form the operation information about the existing firmware and the upgrade firmware, which is convenient for determining the firmware modules included in the currently selected firmware. According to user needs, the recorded information in the upgrade file can be written in batches to one or more specified off-chip memories.
[0093] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0094] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0095] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0096] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for upgrading firmware in an off-chip memory, characterized in that: include: Reading an existing firmware to be upgraded and an upgrade firmware for upgrading the existing firmware; wherein the existing firmware and the upgrade firmware each include one or more firmware modules, and the firmware modules of the existing firmware are stored in an off-chip memory; Comparing the upgrade firmware with the existing firmware to determine a first upgrade firmware module in the upgrade firmware, wherein the first upgrade firmware module is different from each firmware module of the existing firmware, and the first upgrade firmware module is used to upgrade the first firmware module of the existing firmware; The first upgrade firmware module is written into the off-chip memory.
2. The method for upgrading firmware in an off-chip memory according to claim 1, characterized in that: The first firmware module includes a first basic firmware module and a first historical upgrade firmware module for upgrading the first basic firmware module; The step of writing the first upgrade firmware module into the off-chip memory comprises: Determining whether the data volume of the existing firmware stored in the off-chip memory reaches a preset threshold, or determining whether the upgrade times of the existing firmware reaches a preset threshold; If the preset threshold is reached, the first historical upgrade firmware module is erased, and the first upgrade firmware module is written into the off-chip memory; or the first basic firmware module and the first historical upgrade firmware module are erased, and the first upgrade firmware module is written into the off-chip memory; If the preset threshold is not reached, the first upgrade firmware module is written into the off-chip memory.
3. The method for upgrading firmware in an off-chip memory according to claim 1, characterized in that: After writing the first upgrade firmware module into the off-chip memory, the method further includes: Obtaining an initial list of firmware modules, wherein the initial list of firmware modules is used to characterize each firmware module of the firmware running by default; The initial list of firmware modules is updated to obtain an updated list of firmware modules, wherein the updated list of firmware modules is used to represent each firmware module of the firmware that is currently specified to be run; Based on the firmware module update list, the firmware designated to be run at that time is run.
4. The method for upgrading firmware in an off-chip memory according to claim 3, characterized in that: After writing the first upgrade firmware module into the off-chip memory, the method further includes: setting a firmware upgrade flag in the off-chip memory to a first flag; Before updating the initial list of firmware modules, the method further includes: reading the firmware upgrade flag; If the firmware upgrade flag is the first flag, updating the firmware module represented by the initial list of firmware modules to the firmware module of the upgraded firmware; If the firmware upgrade flag is the second flag, the firmware module represented by the initial list of firmware modules is updated to the firmware module of the currently selected firmware.
5. The method for upgrading firmware in an off-chip memory according to claim 3, characterized in that: The off-chip memory further stores identifiers of each firmware module of the existing firmware, labels of each firmware module of the existing firmware, and version numbers of the existing firmware; wherein, if any firmware module of the existing firmware includes a basic firmware module and a historical upgrade firmware module for upgrading the basic firmware module, the label of the basic firmware module is the same as the label of the historical upgrade firmware module; After writing the first upgrade firmware module into the off-chip memory, the method further includes: Writing the identifier of the first upgrade firmware module, the label of the first upgrade firmware module, and the version number of the upgrade firmware into the off-chip memory; wherein the label of the first upgrade firmware module is the same as the label of the first firmware module.
6. The method for upgrading firmware in an off-chip memory according to claim 5, characterized in that: The firmware module list records the identifiers of the firmware modules of the default running firmware; The updating of the initial list of firmware modules includes: Determine identifiers of previously upgraded firmware modules, wherein the previously upgraded firmware modules refer to newly added upgraded firmware modules in each upgrade from the default running firmware to the currently designated running firmware; Determine the identifier to be replaced in the initial list of the firmware modules and the replacement identifier among the identifiers of the previously upgraded firmware modules, wherein the firmware module corresponding to the identifier to be replaced and the firmware module corresponding to the replacement identifier have the same label; According to the upgrade order of the firmware modules corresponding to the identifiers in the replacement identifiers, the identifiers in the replacement identifiers are used in turn to replace the identifiers to be replaced in the initial list of the firmware modules.
7. The method for upgrading firmware in an off-chip memory according to claim 6, characterized in that: The identifiers of the firmware modules of the existing firmware and the identifier of the first upgraded firmware module are natural numbers arranged in sequence according to the upgrade order; the off-chip memory also stores the cumulative number of firmware modules corresponding to the version number of the existing firmware, wherein the cumulative number of firmware modules corresponding to the version number of the firmware refers to the number of different firmware modules contained in the firmware and the previous upgraded firmware; After writing the first upgrade firmware module into the off-chip memory, the method further comprises: writing the accumulated number of firmware modules corresponding to the version number of the upgrade firmware into the off-chip memory; The step of determining the identifiers of the firmware modules that have been upgraded previously includes: Determining the starting value of the identifier of the previously upgraded firmware module according to the accumulated number of firmware modules corresponding to the version number of the default running firmware; Determine the end value of the identifier of the previously upgraded firmware module according to the difference between the cumulative number of firmware modules corresponding to the version number of the firmware running at the current time and the cumulative number of firmware modules corresponding to the version number of the firmware running by default; The identifiers of the firmware modules upgraded all the time are determined according to the starting value and the ending value.
8. The method for upgrading firmware in an off-chip memory according to claim 1, characterized in that: After writing the first upgrade firmware module into the off-chip memory, the method further includes: Reading the version number of the currently selected firmware from the off-chip memory; If the version number of the currently selected firmware is different from the version number of the upgraded firmware and the upgraded firmware is successfully executed, the version number of the currently selected firmware stored in the off-chip memory is updated to the version number of the upgraded firmware.
9. The method for upgrading firmware in an off-chip memory according to claim 1, characterized in that: After writing the first upgrade firmware module into the off-chip memory, the method further includes: Determine the version number of the rolled-back firmware; The version number of the currently selected firmware stored in the off-chip memory is updated to the version number of the rolled-back firmware.
10. A method for upgrading firmware, characterized in that: include: Reading an existing firmware to be upgraded and an upgrade firmware for upgrading the existing firmware; wherein the existing firmware and the upgrade firmware each include one or more firmware modules; Comparing the upgrade firmware with the existing firmware to determine a first upgrade firmware module in the upgrade firmware, wherein the first upgrade firmware module is different from each firmware module of the existing firmware, and the first upgrade firmware module is used to upgrade the first firmware module of the existing firmware; An upgrade file is generated for upgrading the existing firmware; wherein the upgrade file records the firmware modules of the existing firmware and the first upgrade firmware module.
11. The firmware upgrade method according to claim 10, characterized in that: After generating the upgrade file, the method further includes: writing the first upgrade firmware module into an off-chip memory based on the upgrade file; or, writing each firmware module of the existing firmware and the first upgrade firmware module into an off-chip memory based on the upgrade file.
12. The firmware upgrade method according to claim 10, characterized in that: The upgrade file also describes at least one of the following: an identifier of each firmware module of the existing firmware, a label of each firmware module of the existing firmware, a version number of the existing firmware, an identifier of the first upgrade firmware module, a label of the first upgrade firmware module, a version number of the upgrade firmware, a version number of the currently selected firmware, a cumulative number of firmware modules corresponding to the version number of the existing firmware, and a cumulative number of firmware modules corresponding to the version number of the upgrade firmware; wherein, if any firmware module of the existing firmware includes a basic firmware module and a historical upgrade firmware module for upgrading the basic firmware module, the label of the basic firmware module is the same as the label of the historical upgrade firmware module; the label of the first upgrade firmware module is the same as the label of the first firmware module; the cumulative number of firmware modules corresponding to the version number of the firmware refers to the number of different firmware modules contained in the firmware and the previous upgraded firmware; After generating the upgrade file, the method further includes: based on the upgrade file, writing at least one of the following items into an off-chip memory: an identifier of each firmware module of the existing firmware, a label of each firmware module of the existing firmware, a version number of the existing firmware, an identifier of the first upgrade firmware module, a label of the first upgrade firmware module, a version number of the upgrade firmware, a version number of the currently selected firmware, a cumulative number of firmware modules corresponding to the version number of the existing firmware, and a cumulative number of firmware modules corresponding to the version number of the upgrade firmware.