Firmware upgrading method, chip and electronic equipment

By dividing the firmware into the first segment and the second segment, and storing and upgrading in the storage area of ​​the activated and inactive states, the problems of low resource utilization and low upgrade efficiency in the prior art are solved, and the problem of low resource utilization and low upgrade efficiency is realized. More efficient firmware upgrades.

CN119292630APending Publication Date: 2025-01-10XIAN CHIPSEA MICROELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411459774.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

The existing firmware upgrade method requires the configuration of a dedicated backup storage area, resulting in low system resource utilization and low upgrade efficiency.

Method used

The firmware is divided into the first segment firmware and the second segment firmware, and stored and upgraded in the storage areas of the activated state and the inactive state respectively, and segmented upgrades are achieved by switching the storage area state.

Benefits of technology

It improves system resource utilization and firmware upgrade efficiency, saves storage space, and achieves a more efficient firmware upgrade process through segmented upgrades.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119292630A_ABST
    Figure CN119292630A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of integrated circuits, in particular to a firmware upgrading method, a chip and electronic equipment, and the firmware upgrading method comprises the following steps: receiving firmware upgrading data; when the upgrading object is the first segmented firmware, writing a firmware upgrading program into a first storage area in an inactive state; when the upgrading object is the second segmented firmware, writing the firmware upgrading program into a corresponding second storage area; firmware is started; by means of the mode, the firmware is divided into the first segmented firmware and one or more second segmented firmware, and the first segmented firmware is configured with the first storage area used for writing in the activated state of the execution object and the first storage area used for writing in the non-activated state of the upgrading data; only a second storage area for writing the execution object is configured for each second segmented firmware, so that the utilization rate of system resources is improved; and during firmware upgrading, the first segmented firmware or the second segmented firmware can be subjected to segmented upgrading, so that the firmware upgrading efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of integrated circuit technology, and in particular to a firmware upgrade method, chip and electronic device. Background Art

[0002] Firmware is the software that performs the lowest-level work in the chip, which is used to ensure the normal operation of the chip or the electronic device installed with the chip. The firmware is generally burned when the chip is manufactured, and the firmware needs to be upgraded during the use of the chip.

[0003] At present, when a chip performs a firmware upgrade, it is necessary to write a complete firmware upgrade data into the chip or write multiple firmware upgrade data into the chip in sequence to form complete firmware upgrade data, and then complete the firmware upgrade after verifying the written complete firmware upgrade data. In the above firmware upgrade method, the system needs to configure a dedicated spare storage area for the firmware upgrade data and needs to receive a large amount of firmware upgrade data each time the upgrade is performed, which is not conducive to improving the utilization rate of system resources and the efficiency of firmware upgrade. Summary of the invention

[0004] In view of the above problems, the embodiments of the present application provide a firmware upgrade method, a chip and an electronic device to solve the above technical problems that are not conducive to improving system resource utilization and improving firmware upgrade efficiency.

[0005] In a first aspect, an embodiment of the present application provides a firmware upgrade method, which is applied to a chip, wherein the chip includes two first storage areas and at least one second storage area, wherein the two first storage areas are respectively a first storage area in an activated state and a first storage area in an inactivated state, wherein the firmware includes a first segment firmware and at least one second segment firmware, wherein the first segment firmware is stored in the first storage area in an activated state, and the second segment firmware is stored in the corresponding second storage area; the firmware upgrade method includes:

[0006] receiving firmware upgrade data, wherein the firmware upgrade data includes a firmware upgrade program;

[0007] When the upgrade object of the firmware upgrade program is the first segmented firmware, the firmware upgrade program is written to the first storage area in an inactive state; the first storage area in an active state is switched to an inactive state and the first storage area in an inactive state is switched to an active state;

[0008] When the upgrade object of the firmware upgrade program is the second segmented firmware, writing the firmware upgrade program into the corresponding second storage area;

[0009] The firmware is restarted by activating the first segment firmware stored in the first storage area.

[0010] In a second aspect, an embodiment of the present application provides a chip, wherein the chip stores firmware, the chip includes two first storage areas and at least one second storage area, the two first storage areas are respectively a first storage area in an activated state and a first storage area in an inactivated state, the firmware includes a first segmented firmware and at least one second segmented firmware, the first segmented firmware is stored in the first storage area in an activated state, and the second segmented firmware is stored in the corresponding second storage area; the chip is used to implement the above-mentioned firmware upgrade method.

[0011] In a third aspect, an embodiment of the present application provides an electronic device, wherein the electronic device includes the above-mentioned chip.

[0012] The firmware upgrade method, chip and electronic device provided in the embodiments of the present application divide the firmware into a first segmented firmware and one or more second segmented firmwares, configure a first storage area in an activated state for writing an execution object and a first storage area in an inactivated state for writing upgrade data for the first segmented firmware, and configure only a second storage area for writing an execution object for each second segmented firmware, which is beneficial to improving system resource utilization; when upgrading the firmware, the first segmented firmware or the second segmented firmware can be upgraded in segments, which is beneficial to improving the firmware upgrade efficiency.

[0013] These and other aspects of the present application will become more clearly understood in the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 A schematic diagram of the structure of a chip in a firmware upgrade method provided in an embodiment of the present application is shown.

[0015] Figure 2 A diagram showing an example structure of firmware in a firmware upgrade method provided in an embodiment of the present application is shown.

[0016] Figure 3 A flowchart of a firmware upgrade method provided in an embodiment of the present application is shown.

[0017] Figure 4 A schematic diagram of updating the first segment firmware in the firmware upgrade method provided in an embodiment of the present application is shown.

[0018] Figure 5 A structural diagram of firmware upgrade data in a firmware upgrade method provided in an embodiment of the present application is shown.

[0019] Figure 6A flowchart of the storage step of the first segmented firmware in the firmware upgrade method provided in an embodiment of the present application is shown.

[0020] Figure 7 A flowchart of the storage step of the second segment firmware in the firmware upgrade method provided in an embodiment of the present application is shown.

[0021] Figure 8 A schematic diagram of the structure of a chip in a firmware upgrade method provided in an embodiment of the present application is shown.

[0022] Fig. 9 A schematic diagram of the structure of a chip provided in one embodiment of the present application is shown.

[0023] Fig.10 A schematic structural diagram of an electronic device provided in one embodiment of the present application is shown. DETAILED DESCRIPTION

[0024] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.

[0025] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.

[0026] In the embodiments of the present application, it should be noted that, in this article, relational terms such as first and second, etc. are merely 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.

[0027] Moreover, the terms "comprises," "comprising," or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0028] In the description of the embodiments of the present application, words such as "example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "example" or "for example" in the embodiments of the present application is not to be interpreted as being more preferred or having more advantages than another embodiment or design. The use of words such as "example" or "for example" is intended to present relative concepts in a clear manner.

[0029] In addition, the "plurality" in the embodiments of the present application refers to two or more than two. In view of this, in the embodiments of the present application, "plurality" can also be understood as "at least two". "At least one" can be understood as one or more, for example, one, two or more. For example, including at least one means including one, two or more, and there is no limit on which ones are included. For example, including at least one of A, B and C, then A, B, C, A and B, A and C, B and C, or A, B and C can be included.

[0030] It should be noted that, in the embodiments of the present application, "and / or" describes the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / ", unless otherwise specified, generally indicates that the associated objects before and after are in an "or" relationship.

[0031] It should be noted that in the embodiments of the present application, "connection" can be understood as electrical connection, and the connection between two electrical components can be a direct or indirect connection between the two electrical components. For example, the connection between A and B can be either a direct connection between A and B or an indirect connection between A and B through one or more other electrical components.

[0032] like Figure 1 , Figure 2 and Figure 3 As shown, an embodiment of the present application provides a firmware upgrade method, which is applied to chip 100.

[0033] See also Figure 1 As shown, the chip 100 includes two first storage areas 11 and at least one second storage area 12 , and the first storage area 11 and the second storage area 12 are non-volatile storage areas respectively.

[0034] The two first storage areas 11 are respectively an activated first storage area 11 and an inactivated first storage area 11 .

[0035] The firmware 200 includes multiple segmented firmwares, and the multiple segmented firmwares may include a first segmented firmware 21 and at least one second segmented firmware 22. The firmware 200 is stored in segments, and the first segmented firmware 21 as the execution object is stored in the first storage area 11 in an activated state, and the first storage area 11 in an inactive state is used as an upgrade backup area for the first segmented firmware 21. At least one second storage area 12 and at least one second segmented firmware 22 are correspondingly set, and the second segmented firmware 22 is stored in the corresponding second storage area 12.

[0036] The first segment firmware 21 is used to implement basic functions. If the first segment firmware 21 cannot be executed, the entire firmware 200 may not be executed. For example, the first segment firmware 21 can be used to implement the startup function of the firmware 200 and the data transmission function during the execution of the firmware 200.

[0037] Among them, the part of the firmware 200 except the first segmented firmware 21 is used to implement one or more business functions. For example, the part of the firmware 200 except the first segmented firmware 21 can be divided into multiple second segmented firmware 22, each second segmented firmware 22 can respectively implement a business function or several second segmented firmware 22 can jointly implement a business function, each second segmented firmware 22 can include at least one functional function, if any second segmented firmware 22 cannot be executed, only the corresponding business function cannot be executed, and the basic functions and other business functions of the firmware 200 can be executed normally.

[0038] Among them, see Figure 2 As shown, corresponding segment identification information can be configured for each segmented firmware in the firmware 200, for example, the first segmented firmware 21 corresponds to segment identification id11, the first second segmented firmware 22 corresponds to segment identification id21, the second second segmented firmware 22 corresponds to segment identification id22, the third second segmented firmware 22 corresponds to segment identification id23, and the Nth second segmented firmware 22 corresponds to segment identification id2N, where N is a natural number and N≥2.

[0039] See also Figure 3 As shown, the firmware upgrade method includes the following steps S11 to S14:

[0040] Step S11: receiving firmware upgrade data, wherein the firmware upgrade data includes a firmware upgrade program.

[0041] The firmware 200 may be upgraded in segments, and the received firmware upgrade data may be upgrade data for the first segment firmware 21 or upgrade data for the second segment firmware 22. Correspondingly, the firmware upgrade program may be a new first segment firmware or a new second segment firmware.

[0042] Step S12: When the upgrade object of the firmware upgrade program is the first segment firmware, write the firmware upgrade program to the first storage area in the inactive state; switch the first storage area in the active state to the inactive state and switch the first storage area in the inactive state to the active state.

[0043] Among them, when the first segmented firmware is upgraded, the firmware upgrade program is written into the spare inactive first storage area 11. During the process of writing the firmware upgrade program, that is, the process of writing the new version of the first segmented firmware into the inactive first storage area 11, the old version of the first segmented firmware 21 stored in the active first storage area 11 can still be executed. After the new version of the first segmented firmware is written into the inactive first storage area 11, the active first storage area 11 (storing the old version of the first segmented firmware 21) is switched to the inactive state and the inactive first storage area 11 (storing the new version of the first segmented firmware 21) is switched to the active state. When the firmware 200 is restarted, the new version of the first segmented firmware 21 is executed.

[0044] After the firmware upgrade program is written, the storage area states of the two first storage areas 11 are switched respectively, the first storage area 11 storing the firmware upgrade program (new first segment firmware) is activated, and the first storage area 11 storing the old first segment firmware is switched from the activated state to the inactivated state. The storage area states of the two first storage areas 11 are exclusively linked between the activated state and the inactivated state, and the storage area states of the two first storage areas 11 are always opposite.

[0045] Any existing or future method may be used to indicate that the two first storage areas 11 are in an activated state or an inactivated state. Exemplarily, the indication is made through a storage area state identifier, which includes a first preset value and a second preset value. When the storage area state identifier is the first preset value, it indicates that the storage area 11 is in an activated state, and when the storage area state identifier is the second preset value, it indicates that the storage area 11 is in an inactivated state. For example, the first preset value may be 1 or 0, and the second preset value may be 0 or 1.

[0046] For example, see Figure 4As shown, in the initial state of the chip 100, the first segment firmware of the initial version 1.0 is written in the activated first storage area 11, and the inactivated first storage area 11 is not used. When the first segment firmware of the initial version 1.0 is upgraded, the first segment firmware of the revised version 2.0 is written to the inactivated first storage area 11, the activated first storage area 11 is switched to the inactivated state, the inactivated first storage area 11 is switched to the activated state, and then the system executes the first segment firmware of the revised version 2.0. When the first segment firmware of the revised version 2.0 is upgraded, the first segment firmware of the revised version 3.0 is written to the inactivated first storage area 11, the activated first storage area 11 is switched to the inactivated state, the inactivated first storage area 11 is switched to the activated state, and then the system executes the first segment firmware of the revised version 3.0.

[0047] Step S13: When the upgrade object of the firmware upgrade program is the second segment firmware, the firmware upgrade program is written into the corresponding second storage area.

[0048] When the second segment firmware is upgraded, the firmware upgrade program is written into the corresponding second storage area 12. During the process of writing the firmware upgrade program, the second segment firmware cannot be executed. During the process of writing the firmware upgrade program, the old version of the second segment firmware in the corresponding second storage area 12 is overwritten by the firmware upgrade program (the new version of the second segment firmware).

[0049] Step S14: Restarting the firmware by using the first segment firmware stored in the first storage area in an activated state.

[0050] After the firmware upgrade program is written, it is necessary to restart the firmware 200 to complete the firmware upgrade. If the new version of the first segment firmware 21 is written, the firmware 200 is restarted by starting the new version of the first segment firmware 21; if the new version of the second segment firmware 22 is written, the firmware 200 is restarted by restarting the first segment firmware 21 that is currently being executed and has not been upgraded.

[0051] In this embodiment, the firmware is divided into a first segmented firmware and one or more second segmented firmwares. A first storage area in an activated state for writing an execution object and a first storage area in an inactivated state for writing upgrade data are configured for the first segmented firmware. Each second segmented firmware is only configured with a second storage area for writing the execution object, which is beneficial to improving system resource utilization. When upgrading the firmware, the first segmented firmware or the second segmented firmware can be upgraded in segments, which is beneficial to improving the efficiency of firmware upgrade.

[0052] Illustratively, the firmware upgrade method of this embodiment is particularly suitable for embedded systems with relatively limited storage space. The storage area of ​​the firmware 200 includes an activated first storage area 11 and multiple second storage areas 12. Since a segmented upgrade method is adopted, in addition to the above-mentioned storage area of ​​the firmware 200, the system only needs to configure an inactivated first storage area 11 for the firmware upgrade process, which is beneficial to saving system storage space.

[0053] As an implementation, see Figure 5 As shown, the firmware upgrade data also includes upgrade configuration information, and the upgrade configuration information is used to characterize the firmware upgrade program.

[0054] After step S11, the firmware upgrade method further includes the following steps:

[0055] Step S21: determining the upgrade object of the firmware upgrade program according to the upgrade configuration information.

[0056] Among them, the upgrade configuration information is matched with each segmented firmware respectively, and the matched segmented firmware is the upgrade object. For example, the upgrade configuration information may include segment identification information, and the upgrade object and the storage area for writing the firmware upgrade program can be determined according to the segment identification information. The segment identification of each segmented firmware is matched respectively according to the segment identification information, and the target segmented firmware corresponding to the target segment identification matching the segment identification information is taken as the upgrade object. For example, the segment identification information matches the segment identification of the first segmented firmware, the first segmented firmware is the upgrade object, and the storage area for writing the firmware upgrade program is the inactive first storage area 11; for another example, the segment identification information matches the segment identification of the Mth second segmented firmware, the Mth second segmented firmware is the upgrade object, and the storage area for writing the firmware upgrade program is the second storage area 12 corresponding to the Mth second segmented firmware.

[0057] In some implementations, the following steps are further included after step S21:

[0058] Step S22, determining whether the upgrade object meets the upgrade program startup conditions.

[0059] Among them, whether the upgrade program startup conditions are met can be determined based on the current execution status of the upgrade object, specifically: when the upgrade object is the first segmented firmware, it is determined that the upgrade program startup conditions are met; when the upgrade object is the second segmented firmware and the current execution status of the upgrade object is not executed, it is determined that the upgrade program startup conditions are met; when the upgrade object is the second segmented firmware and the current execution status of the upgrade object is executed, it is determined that the upgrade program startup conditions are not met.

[0060] When the upgrade program startup condition is met, step S12 or step S13 is continued to be executed; when the upgrade program startup condition is met, step S22 is continued to be executed until the upgrade object meets the upgrade program startup condition.

[0061] In some embodiments, the upgrade configuration information may include segment identification information and the data size of the firmware upgrade program. In step S22, whether the upgrade object meets the upgrade program startup conditions can be determined based on the data size of the firmware upgrade program and the size of the storage area used to write the firmware upgrade program. Specifically: when the data size of the firmware upgrade program is smaller than the size of the storage area used to write the firmware upgrade program, it is determined that the upgrade object meets the upgrade program startup conditions; when the data size of the firmware upgrade program is greater than or equal to the size of the storage area used to write the firmware upgrade program, it is determined that the upgrade object does not meet the upgrade program startup conditions.

[0062] In some embodiments, the upgrade configuration information may include segment identification information and version information of the firmware upgrade program. In step S22, whether the upgrade object meets the upgrade program startup conditions can be determined based on the version information of the firmware upgrade program. Specifically: when the version of the firmware upgrade program is higher than the current version of the corresponding segment firmware, it is determined that the upgrade object meets the upgrade program startup conditions; when the version of the firmware upgrade program is the same as the current version of the corresponding segment firmware, it is determined that the upgrade object does not meet the upgrade program startup conditions.

[0063] As an implementation, please continue to see Figure 5 As shown, the firmware upgrade data also includes upgrade verification information, and the upgrade verification information is generated according to the upgrade configuration information and the firmware upgrade program.

[0064] When the firmware upgrade program upgrades the first segment firmware 11, refer to Figure 6 As shown, in step S12, before switching the first storage area in the activated state to the inactivated state and switching the first storage area in the inactivated state to the activated state, the following steps are also included:

[0065] Step S12b: verify the firmware upgrade data according to the upgrade verification information.

[0066] The verification information is generated according to the upgrade configuration information and the firmware upgrade program when assembling the firmware upgrade data. During the verification process, the received upgrade configuration information and the firmware upgrade program can be operated in the same operation method as when assembling the firmware upgrade data; if the operation result is consistent with the verification information, the verification passes; if the operation result is inconsistent with the verification information, the verification fails. If the verification passes, continue to execute step S12c to switch the first storage area in the activated state to the inactivated state and switch the first storage area in the inactivated state to the activated state; if the verification fails, stop the upgrade process.

[0067] When the firmware upgrade program upgrades the second segment firmware 12, refer to Figure 7 As shown, step S13 also includes:

[0068] Step S13b: verify the firmware upgrade data according to the upgrade verification information.

[0069] The verification information is generated according to the upgrade configuration information and the firmware upgrade program when assembling the firmware upgrade data. During the verification process, the received upgrade configuration information and the firmware upgrade program can be operated in the same operation mode as when assembling the firmware upgrade data; if the operation result is consistent with the verification information, the verification is passed; if the operation result is inconsistent with the verification information, the verification fails. If the verification is passed, continue to step S14; if the verification fails, stop the upgrade process.

[0070] In some implementations, in step S12b or step S13b, the firmware upgrade data is verified according to the upgrade verification information, specifically including the following steps:

[0071] S31, calculating the upgrade configuration information and the firmware upgrade program according to a first preset algorithm to obtain first calculation data;

[0072] S32: If the upgrade verification information matches the first operation data, the verification passes.

[0073] The verification information is obtained by calculating the upgrade configuration information and the firmware upgrade program according to a first preset algorithm when assembling the firmware upgrade data. If the firmware upgrade data is not wrong during packaging and / or transmission, the verification information is consistent with the first calculation data, and the verification passes. If the verification information is inconsistent with the first calculation data, the verification fails.

[0074] In this implementation, each firmware upgrade data is verified to ensure that there is no error in the firmware upgrade data during transmission, which is beneficial to improving the accuracy of the data.

[0075] Exemplarily, the first preset algorithm may be a CRC algorithm (Cyclic Redundancy Check), which is a fast algorithm that generates a short fixed-bit check code based on data such as a data packet or a file, and is mainly used to detect or check errors that may occur after data transmission or storage. The CRC algorithm is used to generate the first check information and the first operation data, with only two bytes of redundant code, which improves accuracy without affecting transmission time.

[0076] As an implementation mode, the first segment firmware 21 includes a startup function code and a transmission function code; the second segment firmware 22 includes a service function code.

[0077] The startup function code is used to implement the startup function of the firmware 200. The startup of the firmware 200 starts from the execution of the startup function code. The transmission function code is used to implement the data transmission function during the execution of the firmware 200. The first segment firmware 21 is used to implement the basic function. If the first segment firmware 21 cannot be executed, the entire firmware 200 may not be executed.

[0078] Among them, the business function code is used to execute the corresponding business function. If any second segment firmware 22 cannot be executed, the corresponding business function cannot be executed, and the basic functions of the firmware 200 and other business function functions can be executed normally.

[0079] In some embodiments, see Figure 8 As shown, the firmware 200 also includes at least one third segment firmware 23, the third segment firmware 23 includes a coupling function code, and the third segment firmware 23 is used to couple at least two different second segment firmwares 22; the chip 100 also includes a third storage area 13 for storing the third segment firmware 23.

[0080] In this embodiment, the firmware 200 involves the implementation of multiple business functions, and the implementation of each business function may involve the calling of business function functions of one or more second segment firmwares 22 and business function functions of different second segment firmwares 22. For example, when one second segment firmware 22 needs to call another second segment firmware 22, it does not directly call the other second segment firmware 22, but sends a request to the third segment firmware 23, and obtains the calculation result of the business function of the other second segment firmware 22 through the third segment firmware 23. The setting of the third segment firmware 23 can decouple the two second segment firmwares 22 that were originally tightly coupled, and the change of one second segment firmware 22 will not affect the other second segment firmware 22, further improving the firmware upgrade efficiency.

[0081] In some implementations, the firmware upgrade method further includes the following steps:

[0082] Step S41: When the upgrade object of the firmware upgrade program is the third segment firmware, the firmware upgrade program is written into the corresponding third storage area.

[0083] When the third segment firmware is upgraded, the firmware upgrade program is written into the corresponding third storage area 13. During the process of writing the firmware upgrade program, the third segment firmware cannot be executed. During the process of writing the firmware upgrade program, the old version of the third segment firmware in the corresponding third storage area 13 is overwritten by the firmware upgrade program (the new version of the second segment firmware).

[0084] In this embodiment, the setting of the third segmented firmware is conducive to the decoupling between the segmented firmwares of firmware 200, and each segmented firmware is relatively independent, which is conducive to improving the efficiency of firmware upgrade. In addition, there is no need to configure a backup storage area for the third segmented firmware, which is conducive to improving system resource utilization.

[0085] In some implementations, step S14 specifically includes the following steps:

[0086] Step S51: reload the startup function code of the first segment firmware stored in the first storage area in the activated state to reload the firmware.

[0087] Among them, after the firmware upgrade program is stored in the corresponding storage area, the chip 100 needs to be restarted. After the chip 100 is reset, the startup program (Startup Software, SSW) is the first program executed after the chip 100 is powered on or reset. It is used to execute the startup logic after the system is powered on or reset to guide the chip 100 to start. The startup program is stored in the boot read-only memory (boot read-only memory, BootROM) inside the chip. The startup program will jump to the starting address of the startup function code to load the startup function code to achieve reloading of the firmware.

[0088] In some embodiments, please refer to Figure 8 As shown, the chip 100 includes a memory 100a, two first storage areas 11, at least one second storage area 12 and at least one third storage area 13 are different partitions on the memory 100a. The memory 100a may be a non-volatile memory, for example, the memory 100a may be a flash memory.

[0089] In some implementations, when a problem occurs in the first segment firmware 21 being executed, the firmware 200 may be unable to run. Generally, the first segment firmware 21 needs to be rewritten with the aid of a flashing tool to restore the operation of the firmware.

[0090] The firmware upgrade method also includes the following steps:

[0091] Step S61: when a fault occurs in the first segment firmware being executed, the first storage area in the activated state is switched to the inactivated state and the first storage area in the inactivated state is switched to the activated state.

[0092] Among them, the first segmented firmware in execution is stored in the first storage area in an activated state. If the first segmented firmware in execution fails to run normally, the activated first storage area can be directly deactivated and the inactivated first storage area can be activated to re-run the firmware through the old version of the first segmented firmware in the spare first storage area.

[0093] Step S62: reload the first segment firmware stored in the first storage area in the activated state to reload the firmware.

[0094] After the chip 100 is reset, the startup program will jump to the starting address of the startup function code of the first segment firmware of the old version to load the startup function code, thereby reloading the firmware.

[0095] In this embodiment, when the first segment code that implements the basic function fails, the firmware is re-run using the old version of the first segment firmware in the spare first storage area to temporarily restore the operation of the firmware. The operation of the firmware can be restored without the need to rewrite the first segment firmware 21 with the help of a flashing tool. After the firmware is restored, the first segment firmware 21 can be rewritten to the inactive first storage area by writing.

[0096] An embodiment of the present application provides a chip 300, see Fig. 9 As shown, the chip 300 includes two first storage areas 11 and at least one second storage area 12, the first storage area 11 and the second storage area 12 are non-volatile storage areas, respectively. The two first storage areas 11 are respectively an activated first storage area 11 and an inactivated first storage area 11.

[0097] The firmware includes a first segment firmware 21 and at least one second segment firmware 22. The firmware is stored in segments, the first segment firmware 21 as the execution object is stored in the first storage area 11 in an activated state, the first storage area 11 in an inactive state is used as an upgrade backup area for the first segment firmware 21, at least one second storage area 12 and at least one second segment firmware 22 are correspondingly set, and the second segment firmware 22 is stored in the corresponding second storage area 12.

[0098] The chip 300 is used to implement the firmware upgrade method of the above-mentioned embodiment or implementation.

[0099] The structure of the chip 300 is the same as that of the chip 100 in the above embodiment. For details, please refer to the description of the above chip 100, which will not be described here one by one.

[0100] In this embodiment, the chip 300 is also called an IC (Integrated Circuit, IC) chip, which can be but is not limited to a SOC (System on Chip) chip or a SIP (system in package) chip.

[0101] Exemplarily, the chip 300 may be an EC (Embedded Controller) chip.

[0102] The chip of this embodiment divides the firmware into a first segmented firmware and one or more second segmented firmwares, configures a first storage area in an activated state for writing an execution object and a first storage area in an inactivated state for writing upgrade data for the first segmented firmware, and configures only a second storage area for writing an execution object for each second segmented firmware, which is beneficial to improving system resource utilization; when upgrading the firmware, the first segmented firmware or the second segmented firmware can be upgraded in segments, which is beneficial to improving the firmware upgrade efficiency.

[0103] The present application embodiment also provides an electronic device 400, see Fig.10 As shown, the electronic device 400 includes a device body and a chip 300 as described above, which is arranged in the device body. The electronic device can be, but is not limited to, a weight scale, a body fat scale, a nutrition scale, a pulse oximeter, a human body composition analyzer, a display, a USB (Universal Serial Bus) docking station, a car, a smart wearable device, a mobile terminal, and a smart home device. Smart wearable devices include, but are not limited to, smart watches, smart bracelets, and cervical massagers. Mobile terminals include, but are not limited to, smart phones, laptops, tablet computers, and POS (point of sales terminal). Smart home devices include, but are not limited to, smart sockets, smart rice cookers, smart sweepers, and smart lights.

[0104] The electronic device of this embodiment divides the firmware into a first segmented firmware and one or more second segmented firmwares, configures a first storage area in an activated state for writing an execution object and a first storage area in an inactivated state for writing upgrade data for the first segmented firmware, and configures only a second storage area for writing an execution object for each second segmented firmware, which is beneficial to improving system resource utilization; when upgrading the firmware, the first segmented firmware or the second segmented firmware can be upgraded in segments, which is beneficial to improving the firmware upgrade efficiency.

[0105] The above is only an implementation method of the present application. It should be pointed out that a person skilled in the art can make improvements without departing from the inventive concept of the present application, but these improvements are within the scope of protection of the present application.

Claims

1. A firmware upgrade method, characterized in that: Applied to a chip, the chip comprises two first storage areas and at least one second storage area, the two first storage areas are respectively a first storage area in an activated state and a first storage area in an inactivated state, the firmware comprises a first segment firmware and at least one second segment firmware, the first segment firmware is stored in the first storage area in an activated state, and the second segment firmware is stored in the corresponding second storage area; The firmware upgrade method comprises: receiving firmware upgrade data, wherein the firmware upgrade data includes a firmware upgrade program; When the upgrade object of the firmware upgrade program is the first segmented firmware, the firmware upgrade program is written to the first storage area in an inactive state; the first storage area in an active state is switched to an inactive state and the first storage area in an inactive state is switched to an active state; When the upgrade object of the firmware upgrade program is the second segmented firmware, writing the firmware upgrade program into the corresponding second storage area; The firmware is restarted by activating the first segment firmware stored in the first storage area.

2. The firmware upgrade method according to claim 1, characterized in that: The firmware upgrade data also includes upgrade configuration information, and the upgrade configuration information is used to characterize the firmware upgrade program; After receiving the firmware upgrade data, the method further includes: The upgrade object of the firmware upgrade program is determined according to the upgrade configuration information.

3. The firmware upgrade method according to claim 2, characterized in that: The firmware upgrade data also includes upgrade verification information, and the upgrade verification information is generated according to the upgrade configuration information and the firmware upgrade program; When the upgrade object of the firmware upgrade program is the first segmented firmware, before switching the first storage area in an activated state to an inactive state and switching the first storage area in an inactive state to an active state, the method further includes: The firmware upgrade data is verified according to the upgrade verification information.

4. The firmware upgrade method according to claim 2, characterized in that: The firmware upgrade data also includes upgrade verification information, and the upgrade verification information is generated according to the upgrade configuration information and the firmware upgrade program; When the upgrade object of the firmware upgrade program is the second segmented firmware, before the first segmented firmware stored in the first storage area in the reload activation state is reloaded, the method further includes: The firmware upgrade data is verified according to the upgrade verification information.

5. The firmware upgrade method according to claim 3 or 4, characterized in that: The verifying the firmware upgrade data according to the upgrade verification information includes: Performing calculations on the upgrade configuration information and the firmware upgrade program according to a first preset algorithm to obtain first calculation data; If the upgrade verification information matches the first operation data, the verification passes.

6. The firmware upgrade method according to claim 1, characterized in that: The first segment firmware includes a startup function code and a transmission function code; the second segment firmware includes a business function code.

7. The firmware upgrade method according to claim 6, characterized in that: The firmware also includes a third segment firmware, the third segment firmware includes a coupling function code, and the third segment firmware is used to couple two different second segment firmwares; the chip also includes a third storage area for storing the third segment firmware.

8. The firmware upgrade method according to claim 7, characterized in that: The firmware upgrade method further includes: When the upgrade object of the firmware upgrade program is the third segment firmware, the firmware upgrade program is written into the corresponding third storage area.

9. The firmware upgrade method according to claim 6, characterized in that: The step of restarting the firmware by using the first segmented firmware stored in the first storage area in an activated state comprises: The boot function code of the first segmented firmware stored in the first storage area in an activated state is reloaded to reload the firmware.

10. A chip, characterized in that: The chip stores firmware, the chip includes two first storage areas and at least one second storage area, the two first storage areas are respectively a first storage area in an activated state and a first storage area in an inactivated state, the firmware includes a first segmented firmware and at least one second segmented firmware, the first segmented firmware is stored in the first storage area in an activated state, and the second segmented firmware is stored in the corresponding second storage area; the chip is used to implement the firmware upgrade method according to any one of claims 1 to 9.

11. An electronic device, characterized in that: Comprising the chip as claimed in claim 10.