Method, electronic device and storage medium for upgrading non-system firmware

By generating an independent non-system firmware upgrade package and writing upgrade instructions into the boot communication partition, the risks and inefficiencies caused by upgrading non-system firmware together with system firmware are resolved, thus achieving safe and efficient non-system firmware updates.

CN115904438BActive Publication Date: 2026-03-17FUZHOU ROCKCHIP SEMICON
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211509660.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-29
Publication Date
2026-03-17
Estimated Expiration
2042-11-29

AI Technical Summary

Technical Problem

In existing technologies, non-system firmware upgrades are performed together with system firmware upgrades, which increases the size of the upgrade package and poses a risk of bricking the device. In addition, non-system firmware usually does not need to be updated after the device leaves the factory.

Method used

By generating an independent non-system firmware upgrade package, and using a version number binary image file to write special upgrade instructions and paths into the boot communication partition, the non-system firmware is upgraded independently, including version number comparison, encryption processing, and digital signature verification.

Benefits of technology

It enables separate upgrades for non-system firmware, reducing upgrade risks and improving update efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115904438B_ABST
    Figure CN115904438B_ABST
Patent Text Reader

Abstract

The application discloses a method, an electronic device and a storage medium for upgrading non-system firmware, wherein the method comprises the following steps: obtaining a current non-system firmware version from a version number area; obtaining a non-system firmware upgrade package to be upgraded according to the current non-system firmware version; and writing special upgrade instructions for non-system firmware upgrade and a non-system firmware upgrade package path into a preset position of a boot communication partition according to a non-system firmware version of a version number binary image file in the non-system firmware upgrade package. The application provides an execution logic for separately updating non-system firmware, so that the non-system firmware can be separately updated and does not need to be updated together with system firmware, thereby reducing the risk of non-system firmware upgrade and improving the update efficiency of the non-system firmware.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of firmware upgrades, and more particularly to methods, electronic devices, and storage media for upgrading non-system firmware. Background Technology

[0002] Firmware in a device can generally be divided into system firmware and non-system firmware. The firmware that boots after the last boot loader during the startup process is usually called system firmware. This includes the boot firmware and firmware further loaded and booted by the boot firmware, such as boot / recovery, system, vendor, ODM, OEM, etc. Other firmware besides system firmware is called non-system firmware, such as various levels of boot loader (e.g., loader, uboot).

[0003] Existing upgrade methods for non-system firmware essentially place the non-system firmware and system firmware in the same OTA upgrade package. The upgrade client then queries the server using the system firmware version number to check for new firmware updates. This method, in the case of a full package upgrade, upgrades both system and non-system firmware simultaneously. This increases the upgrade package size and the risk of device bricking in case of upgrade failure, as non-system firmware is often the core firmware related to the device's boot process (such as various bootloader levels). Furthermore, after the device leaves the factory, typically only the system firmware (including various applications and libraries) needs updating, while non-system firmware often does not require updates. Therefore, there is an urgent need for a method to generate separate upgrade packages for non-system firmware and perform independent upgrades. Summary of the Invention

[0004] This invention provides a method, electronic device, and storage medium for upgrading non-system firmware, which can upgrade non-system firmware in a system separately.

[0005] In a first aspect of the invention, a method for upgrading non-system firmware is provided. The method includes: obtaining a current non-system firmware version number from a version number region; obtaining a non-system firmware upgrade package to be upgraded based on the current non-system firmware version number; writing a special upgrade instruction for upgrading the non-system firmware and a non-system firmware upgrade package path to a preset location in a boot communication partition based on the non-system firmware version number of a version number binary image file in the non-system firmware upgrade package; upgrading the non-system firmware using the non-system firmware upgrade package under the non-system firmware upgrade package path according to the special upgrade instruction in the preset location of the boot communication partition; and writing the version number binary image file from the non-system firmware upgrade package into the version number region.

[0006] In some embodiments, obtaining the non-system firmware upgrade package to be upgraded based on the current non-system firmware version number includes: using the current non-system firmware version number to query in the firmware upgrade server whether there is a new version of non-system firmware that needs to be upgraded; and if there is a new version of non-system firmware that needs to be upgraded, obtaining the non-system firmware upgrade package as an independent upgrade package for non-system firmware, the non-system firmware upgrade package including the non-system firmware to be upgraded independently and an encrypted version number binary image file, wherein the non-system firmware version number in the version number binary image file is used as the version number of the non-system firmware upgrade package.

[0007] In some embodiments, writing a special upgrade instruction for non-system firmware upgrade and the path of the non-system firmware upgrade package to a preset location in the boot communication partition based on the non-system firmware version number of the version number binary image file in the non-system firmware upgrade package includes: obtaining the version number binary image file from the non-system firmware upgrade package; reading the non-system firmware version number from the version number binary image file and comparing the non-system firmware version number with the current non-system firmware version number; based on the comparison result, writing the special upgrade instruction and the path of the non-system firmware upgrade package to a preset location in the boot communication partition; and restarting the device to guide the device into firmware upgrade mode.

[0008] In some embodiments, upgrading non-system firmware according to the special upgrade instruction in the preset location of the boot communication partition and the content of the non-system firmware upgrade package under the non-system firmware upgrade package path includes: checking whether the special upgrade instruction exists in the preset location of the boot communication partition by starting the boot program firmware; if it exists, booting the device into firmware upgrade mode, reading the non-system firmware upgrade package path from the preset location of the boot communication partition; and completing the upgrade of non-system firmware according to the content of the non-system firmware upgrade package.

[0009] In some embodiments, writing the version number binary image file from the non-system firmware upgrade package into the version number area includes: if the upgrade is successful, reading the encrypted version number binary image file from the non-system firmware upgrade package and writing the encrypted version number binary image file into the version number area; and setting the upgrade result to successful.

[0010] In some embodiments, the method further includes: writing the upgrade result and the non-system firmware upgrade package path into an upgrade result tag file under a preset path; clearing the special upgrade instruction and the non-system firmware upgrade package path from the preset location of the boot communication partition; and restarting the device to boot the device back into the system.

[0011] In some embodiments, the version number binary image file in the non-system firmware upgrade package includes a preset fixed-length magic number and a fixed-length non-system firmware version number; the encrypted version number binary image file obtained by encrypting the version number binary image file and the non-system firmware to be burned are packaged into the non-system firmware upgrade package; a pair of public and private keys are generated using a first digital signature algorithm, the non-system firmware upgrade package is signed using the private key, the signed non-system firmware upgrade package is uploaded to the firmware upgrade server for download, and the corresponding public key is simultaneously preset in the system firmware preset path and the upgrade mode firmware preset path.

[0012] In some embodiments, obtaining the current non-system firmware version number from the version number region includes: reading an encrypted current non-system firmware version number file from the version number region when the device starts up; decrypting the encrypted current non-system firmware version number file and determining whether the content of the initial fixed length in the decrypted current non-system firmware version number file is the same as the magic number of a preset version number binary image file; and if they are the same, obtaining the current non-system firmware version number from the decrypted current non-system firmware version number file.

[0013] In some embodiments, the method further includes: if the content of the decrypted current non-system firmware version number file with a fixed starting length is different from the magic number of the preset version number binary image file, then creating a temporary buffer and writing the magic number and the preset default non-system firmware version number of a fixed length at the beginning of the temporary buffer; and encrypting the temporary buffer using a preset encryption algorithm and key, and writing the encrypted content into the version number area.

[0014] In some embodiments, after obtaining the non-system firmware upgrade package to be upgraded, the method further includes: reading the encrypted version number binary image file in the non-system firmware upgrade package and decrypting it using a symmetric encryption algorithm and key; determining whether the fixed-length magic number in the decrypted version number binary image file is the same as a preset value; if they are different, an error is prompted and the firmware upgrade process is exited; if they are the same, the non-system firmware version number in the decrypted version number binary image file is obtained, and the non-system firmware version number is compared with the current non-system firmware version number; and if the non-system firmware version number is not greater than the current non-system firmware version number, an error is prompted that the version number is too low and the firmware upgrade process is exited.

[0015] In a second aspect of the invention, an electronic device is provided. The electronic device includes: a memory configured to store a computer program; and a processor configured to execute the computer program to perform the methods described above.

[0016] In a third aspect of the invention, a computer-readable storage medium is provided having a computer program stored thereon. The computer program is executed to implement the methods described above.

[0017] According to embodiments of the present invention, updates can be performed on underlying non-system firmware, providing an execution logic for updating non-system firmware separately. This allows non-system firmware to be updated independently without needing to be updated together with system firmware, reducing the risk of non-system firmware upgrades, improving the efficiency of non-system firmware updates, and enhancing the user experience.

[0018] The above description of the invention is merely an overview of the technical solution of this application. In order to enable those skilled in the art to better understand the technical solution of this application and to implement it based on the description and drawings, and to make the above-mentioned objectives and other objectives, features and advantages of this application easier to understand, the following description is provided in conjunction with the specific embodiments and drawings of this application. Attached Figure Description

[0019] The accompanying drawings are only used to illustrate the principles, implementation methods, applications, features, and effects of specific embodiments of this application and other related content, and should not be considered as limitations on this application.

[0020] Figure 1 This is a flowchart of a method for upgrading non-system firmware according to an embodiment of the present invention;

[0021] Figure 2 This is a flowchart of a method for upgrading non-system firmware according to an embodiment of the present invention;

[0022] Figure 3 Flowchart of a method for setting a new version number according to an embodiment of the present invention;

[0023] Figure 4 A flowchart illustrating a method for creating a temporary buffer according to an embodiment of the present invention;

[0024] Figure 5 This is a flowchart of a version number verification method according to an embodiment of the present invention. Detailed Implementation

[0025] To explain in detail the technical content, structural features, objectives, and effects of the technical solution, the following description is provided in conjunction with specific embodiments and accompanying drawings.

[0026] In this document, the term "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The term "embodiment" appearing in various places throughout the specification does not necessarily refer to the same embodiment, nor does it specifically limit its independence or connection with other embodiments. In principle, in this application, as long as there are no technical contradictions or conflicts, the technical features mentioned in each embodiment can be combined in any way to form corresponding implementable technical solutions.

[0027] Unless otherwise defined, the technical terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the use of related terms herein is merely for the purpose of describing particular embodiments and is not intended to limit this application.

[0028] In the description of this application, the term "and / or" is used to describe the logical relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A exists, B exists, and A and B exist simultaneously. Additionally, the character " / " in this document generally indicates that the preceding and following objects have an "or" logical relationship.

[0029] In this application, terms such as “first” and “second” are used only to distinguish one entity or operation from another, and do not necessarily require or imply any actual quantity, hierarchy or order relationship between these entities or operations.

[0030] Unless otherwise specified, the use of terms such as “comprising,” “including,” “having,” or other similar expressions in this application is intended to cover non-exclusive inclusion, which does not exclude the presence of additional elements in a process, method, or product that includes the stated elements, such that a process, method, or product that includes a list of elements may include not only those defined elements but also other elements not expressly listed, or elements inherent to such a process, method, or product.

[0031] Similar to the understanding in the Examination Guidelines, in this application, expressions such as "greater than," "less than," and "exceeding" are understood to exclude the stated number; expressions such as "above," "below," and "within" are understood to include the stated number. Furthermore, in the description of the embodiments in this application, "multiple" means two or more (including two), and similar expressions related to "multiple" are also understood in this way, such as "multiple groups" and "multiple times," unless otherwise explicitly specified.

[0032] In the description of the embodiments of this application, the space-related expressions used, such as "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "vertical," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential," indicate the orientation or positional relationship based on the orientation or positional relationship shown in the specific embodiments or drawings. They are only for the purpose of describing the specific embodiments of this application or for the reader's understanding, and do not indicate or imply that the device or component referred to must have a specific position, a specific orientation, or be constructed or operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of this application.

[0033] Unless otherwise expressly specified or limited, the terms "installation," "connection," "linking," "fixing," and "setting," as used in the description of the embodiments of this application, should be interpreted broadly. For example, "connection" can be a fixed connection, a detachable connection, or an integral setting; it can be a mechanical connection, an electrical connection, or a communication connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be the internal connection of two components or the interaction between two components. For those skilled in the art to which this application pertains, the specific meaning of the above terms in the embodiments of this application can be understood according to the specific circumstances.

[0034] Firmware in a device can generally be divided into system firmware and non-system firmware. System firmware typically refers to the firmware that boots after the last boot loader during the boot process. This includes the boot firmware and firmware further loaded by the boot firmware, such as boot / recovery, system, vendor, ODM, OEM, etc. Other firmware besides system firmware, or firmware related to the boot loader, is called non-system firmware. Non-system firmware can include various levels of boot loader firmware, such as loader firmware, uboot firmware, etc. This definition will be used in the solution described in this article.

[0035] A key issue when performing independent upgrades to non-system firmware is that the firmware upgrade client located in the system firmware cannot obtain the version number of the non-system firmware. Since the version number of the non-system firmware is not transmitted to the system, the firmware upgrade client does not know how to detect independent non-system firmware upgrade packages, when to obtain and upgrade the corresponding independent non-system firmware upgrade package, or whether a certain non-system firmware upgrade package contains firmware that is newer than the firmware in the current device.

[0036] To address at least the aforementioned problems, this invention provides a method for upgrading non-system firmware. According to embodiments of this invention, by pre-setting version number two in the non-system firmware upgrade package as an image file, the problem of clients in the system firmware being unable to access the non-system firmware version number is solved. This allows for the generation and independent upgrading of non-system firmware through independent upgrade packages. In this way, non-system firmware can be upgraded only when updates are needed, while simultaneously reducing the size of the complete upgrade package during system firmware upgrades, facilitating independent maintenance and upgrades of non-system firmware.

[0037] In relevant sections of this article, unless otherwise stated, most write locations / storage locations / paths generally need to be storage areas that cannot be deleted after a factory reset and that can be accessed by both system firmware and upgrade mode firmware. For example, a version number partition represents a storage location containing version numbers, a boot communication partition represents a storage location containing boot communication function code, and other specific locations or vendor storage, etc.

[0038] Hereinafter, specific embodiments of the present invention will be described with reference to the accompanying drawings through exemplary embodiments.

[0039] Figure 1 This is a flowchart illustrating a method for upgrading non-system firmware according to an embodiment of the present invention. Figure 1 As shown, the method includes the following steps S01 to S05.

[0040] In step S01, the current non-system firmware version number is obtained from the version number area.

[0041] In step S02, the non-system firmware upgrade package to be upgraded is obtained based on the current non-system firmware version number. In some embodiments, the current non-system firmware version number is used to query the firmware upgrade server to see if there is a new version of non-system firmware that needs to be upgraded. If there is a new version of non-system firmware that needs to be upgraded, the non-system firmware upgrade package is obtained as an independent upgrade package for the non-system firmware. The non-system firmware upgrade package includes the non-system firmware to be upgraded independently and an encrypted version number binary image file, wherein the non-system firmware version number in the version number binary image file serves as the version number of the non-system firmware upgrade package.

[0042] In step S03, based on the non-system firmware version number of the version number binary image file in the non-system firmware upgrade package, a special upgrade instruction for non-system firmware upgrade and the path of the non-system firmware upgrade package are written to a preset location in the boot communication partition. In some embodiments, the version number binary image file is obtained from the non-system firmware upgrade package. Next, the non-system firmware version number is read from the version number binary image file and compared with the current non-system firmware version number. Based on the comparison result, the special upgrade instruction and the path of the non-system firmware upgrade package are written to a preset location in the boot communication partition. Subsequently, the device is restarted to boot the device into firmware upgrade mode.

[0043] In step S04, the non-system firmware is upgraded using the non-system firmware upgrade package under the non-system firmware upgrade package path, based on the special upgrade instruction in the preset location of the boot communication partition. In some embodiments, the bootloader firmware checks whether the special upgrade instruction exists in the preset location of the boot communication partition. If it exists, the boot device enters firmware upgrade mode and reads the non-system firmware upgrade package path from the preset location of the boot communication partition. Subsequently, the non-system firmware upgrade is completed according to the contents of the non-system firmware upgrade package.

[0044] In step S05, the version number binary image file from the non-system firmware upgrade package is written into the version number area. In some embodiments, if the upgrade is successful, the encrypted version number binary image file is read from the non-system firmware upgrade package and written into the version number area. Then, the upgrade result is set to successful.

[0045] In some embodiments, after a successful upgrade, the upgrade result and the path to the non-system firmware upgrade package are written to an upgrade result tag file in a preset path. Then, the special upgrade instruction and the path to the non-system firmware upgrade package are cleared from a preset location in the boot communication partition. Subsequently, the device is restarted, booting the device back into the system.

[0046] The above steps enable updates to underlying non-system firmware, providing a separate execution logic for updating non-system firmware. This allows non-system firmware to be updated independently, without needing to be updated alongside system firmware, reducing the risk of non-system firmware upgrades and improving update efficiency. This also enhances the user experience.

[0047] Figure 2 This is a flowchart illustrating a method for upgrading non-system firmware according to an embodiment of the present invention. Figure 2 As shown, the method includes the following steps S10 to S14.

[0048] In step S10, when the device starts up, the first non-system firmware version number ciphertext is read from the first storage location and parsed. It is then determined whether the content with the starting fixed length in the first non-system firmware version number ciphertext is the same as the preset version number magic number.

[0049] If the determination is yes, S11 obtains the current non-system firmware version number from the decrypted content; uses the current non-system firmware version number to query the cloud server for a new version and obtains the non-system firmware upgrade package to be upgraded.

[0050] In step S12, a special upgrade instruction for non-system firmware upgrade and the path to the non-system firmware upgrade package are written to the second storage location.

[0051] In step S13, the bootloader is started to restart the device and check whether the special upgrade instruction exists in the second storage location. If it is found to be yes, the firmware upgrade mode is entered.

[0052] In step S14, the storage path of the non-system firmware upgrade package to be upgraded is obtained, the non-system firmware upgrade package to be upgraded is obtained, the non-system firmware upgrade package to be upgraded is verified, if the verification is successful, the non-system firmware upgrade package to be upgraded is parsed to obtain the non-system firmware and the encrypted version number of the second non-system firmware, the non-system firmware in the non-system firmware upgrade package to be upgraded is burned, and the encrypted version number of the second non-system firmware is burned to the first storage location.

[0053] The first storage location can be a functional partition divided from a storage area that cannot be deleted after factory reset and can be accessed by both system firmware and upgrade mode firmware, such as a version number partition. The magic number is a unique identifier for a specific file, and the validity of the version number associated with it can be verified by checking the magic number.

[0054] Steps S10 and S11 described above can be executed during the initial device startup, or each time the device starts up. Alternatively, the upgrade package can be downloaded via an app within the system while the device is running. Steps S10 and S11 achieve the effect of default initialization of the non-system firmware version number. In other embodiments, the method may begin at step S12. When a system upgrade command is received, a special upgrade command for the non-system firmware upgrade and the path to the non-system firmware upgrade package are written to the second storage location. The second storage location can be the boot communication partition, any location that cannot be deleted during a reboot or factory reset. By marking the second storage location with a special upgrade command, the upgrade program can be started upon reboot, solving the boot problem when updating non-system firmware (i.e., bootable firmware). By executing the above steps, a solution is provided that allows the independent operation of the subsystem firmware upgrade program, solving the problem of non-system firmware not being able to update independently.

[0055] In some embodiments of this application, the non-system firmware upgrade package is verified. If the verification fails, the firmware upgrade process exits and proceeds to the post-upgrade steps. By designing an exit procedure for verification failure, the practicality of this solution is improved.

[0056] In some embodiments of this application, after the second non-system firmware version number is burned into the first storage location, an upgrade step is performed, which includes step S15.

[0057] In step S15, the upgrade result and the path to the non-system firmware upgrade package are written to the upgrade result marker file in the third storage location. The special upgrade instructions and the path to the non-system firmware upgrade package in the second storage location are cleared. Then, the device restarts, guiding it back into the system. The third storage location can be a general area in the system storage, which can be refreshed during system restore because it records the upgrade result. After entering the upgraded system, the APP can read the upgrade result marker file to display any problems encountered during the upgrade or a message indicating a successful upgrade. By clearing the records of special upgrade instructions and upgrade package paths, the device can enter the system normally; otherwise, the presence of special upgrade instructions would continue to guide the device into the bootloader. This scheme makes the non-system firmware update process more efficient.

[0058] In other cases, such as Figure 3 In the illustrated embodiment, when updating or distributing non-system firmware, a new version number also needs to be set. Therefore, the method further includes steps S30 to S32.

[0059] In step S30, a version number file is created, which includes a version number magic number of preset length and a non-system firmware version number of fixed length.

[0060] In step S31, the version number file is encrypted to obtain encrypted version number ciphertext, and the encrypted version number ciphertext and the non-system firmware to be burned are packaged into a non-system firmware upgrade package.

[0061] In step S32, a public key and the private key are generated using the first digital signature algorithm; the non-system firmware upgrade package is signed using the private key; the signed non-system firmware upgrade package is uploaded to the firmware upgrade server for download; and the corresponding public key is simultaneously preset in the system firmware preset path and the upgrade mode firmware preset path.

[0062] The version number file in the above scheme can refer to a version number binary image file (such as version.bin). The version number binary image file consists of two parts: a preset fixed-length magic number + a fixed-length non-system firmware version number. File encryption can be a uniformly set preset encryption algorithm. The preset path for the system firmware here refers to the storage location on the terminal device when installed, such as the system\ folder. The preset path for the upgrade mode firmware here refers to the storage location on the terminal device when installed, such as the recovery\ folder. This scheme generates independent non-system firmware upgrade packages. The device communicates with the firmware upgrade server to download these upgrade packages and stores them on the device, further improving the convenience of this scheme.

[0063] In some further embodiments, the verification of the non-system firmware upgrade package in step S14 specifically involves verifying the non-system firmware upgrade package using a public key located in the preset path of the upgrade mode firmware. Here, the preset path of the system firmware refers to the storage location on the terminal device when installed on a specific terminal device, such as the folder named "system\". By verifying the firmware upgrade package, the legitimacy of the upgrade package is determined, thereby improving the security of file transfer.

[0064] In some embodiments of this application, such as Figure 4As shown, in step S10, if the determination of whether the starting fixed-length content in the first non-system firmware version number ciphertext is the same as the preset version number magic number is negative, then step S101 is performed: a temporary buffer is created, the version number magic number and the default non-system firmware version number are written at the beginning of the temporary buffer, and then the temporary buffer is encrypted using a preset encryption algorithm and key. The encrypted content is then written to the first storage location. The temporary buffer, also called a temporary cache, can be arbitrarily planned in the device's storage components, as long as its size allows for writing. Planning a temporary buffer can act as temporary memory, saving system computing resources. The preset encryption algorithm can be a symmetric encryption algorithm, and the default non-system firmware version number can be the initial version number to avoid the problem of devices using this scheme for the first time being unable to perform version number comparison and updates. This scheme enables non-system firmware updates even on older target devices that have not previously had the non-system firmware installation package pre-installed.

[0065] Some of the things in this application, such as Figure 5 In the embodiment shown, after obtaining the non-system firmware upgrade package to be upgraded, the following steps are also included.

[0066] S111 reads the encrypted version number from the non-system firmware upgrade package to be upgraded, decrypts it using a symmetric encryption algorithm, and then determines whether the fixed-length magic number in the decrypted version number binary image file is the same as the preset value. If not, S1111 prompts an error and exits the firmware upgrade process.

[0067] If so, S1112 retrieves the third non-system firmware version number from the non-system firmware upgrade package to be upgraded, and compares the third version number with the current non-system firmware version number. If the third version number is not greater than the current non-system firmware version number, a message indicating that the version number is too low is displayed, and the firmware upgrade process is exited. If it is greater, the non-system firmware upgrade proceeds. By setting the above verification steps, verification can be performed again before the firmware upgrade installation, improving the security of this solution.

[0068] In another aspect of the invention, a computer-readable storage medium is also provided, on which a computer program is stored, the computer program being executed to implement the method described above. This storage medium enables updates to underlying non-system firmware, providing execution logic for separately updating non-system firmware. This allows non-system firmware to be updated independently, without needing to be updated together with system firmware, reducing the risk of non-system firmware upgrades and improving the efficiency of non-system firmware updates. This also enhances the user experience.

[0069] In another aspect of the invention, an electronic device is also provided. This electronic device includes a memory and a processor. The memory is configured to store a computer program. The processor is configured to execute the computer program to perform the methods described above. The aforementioned electronic device is capable of updating underlying non-system firmware, providing an execution logic for separately updating non-system firmware. This allows non-system firmware to be updated independently without needing to be updated along with system firmware, reducing the risk of non-system firmware upgrades and improving the efficiency of non-system firmware updates. This also enhances the user experience.

[0070] In some comprehensive embodiments of this application, the following steps are also performed to achieve the effect of independent upgrade of non-system firmware. The details are as follows: Part One, Generation of Independent Upgrade Package for Non-System Firmware:

[0071] The S30 determines the new non-system firmware version number and generates a version number binary image file (e.g., version.bin). The version number binary image file consists of two parts: a preset fixed-length magic number + a fixed-length non-system firmware version number.

[0072] S31 encrypts the generated version number binary image file using a preset symmetric encryption algorithm and key, generating an encrypted version number binary image file (e.g., version_encry.bin). It then combines all non-system firmware that needs to be upgraded independently (e.g., primary bootloader, ddr bin firmware) and the encrypted version number binary image file (e.g., version_encry.bin) into an independent non-system firmware upgrade package, using the non-system firmware version number in the version number binary image file as the version number of the non-system firmware upgrade package.

[0073] S32 generates a public and private key pair using a preset digital signature algorithm. The private key is used to sign the generated non-system firmware upgrade package, which is then placed on the firmware upgrade server. The corresponding public key is simultaneously preset to a preset path in both the system firmware (e.g., system) and the upgrade mode firmware (e.g., recovery).

[0074] Part Two: Device startup, execution of the non-system firmware upgrade client included in the system firmware. It first checks if a non-system firmware upgrade result tag file exists in the preset path; if not, it executes the following step S10. : If it exists, the system will indicate to the user whether the non-system firmware upgrade was successful or failed based on the upgrade result in the non-system firmware upgrade result marker file. The system will then delete the corresponding non-system firmware upgrade package based on the non-system firmware upgrade package path in the marker file. Finally, the system will delete the non-system firmware upgrade result marker file and continue with the following steps.

[0075] S10. Read the current non-system firmware version number ciphertext from the preset version number area (the preset version number area must be a storage area that cannot be deleted after factory reset and can be accessed by both system firmware and upgrade mode firmware, such as a specific location in the version number partition, boot communication partition, or vendor storage), and then decrypt it using the preset symmetric encryption algorithm and key. Determine whether the content with the fixed starting length in the decrypted content is the same as the magic number of the preset version number binary image file:

[0076] If S101 is different, create a temporary buffer, write the magic number of the preset version number binary image file and the preset default non-system firmware version number of a fixed length at the beginning of the temporary buffer, then encrypt the temporary buffer using the preset symmetric encryption algorithm and key, write the encrypted content into the preset version number area, and use the preset default non-system firmware version number as the current non-system firmware version number.

[0077] S11: If they are the same, the current non-system firmware version number is further obtained from the decrypted content. Finally, the current non-system firmware version number is used to query the firmware upgrade server to see if there is a new firmware version that needs to be upgraded. When there is a new firmware version that needs to be upgraded, it first obtains the non-system firmware upgrade package to be upgraded, and then performs the following verification steps.

[0078] Part Three: Verification and Upgrade.

[0079] S111 uses the public key file located in the system firmware's preset path to verify the non-system firmware upgrade package. If verification fails, an error message is displayed, and the firmware upgrade process exits. If verification succeeds, the encrypted version number binary image file (e.g., version_encry.bin) in the non-system firmware upgrade package is read and decrypted using a preset symmetric encryption algorithm and key. Then, it checks whether the fixed-length magic number in the decrypted version number binary image file matches the preset value: verifying the upgrade package's validity.

[0080] If S1111 is different, an error message will be displayed, and the firmware upgrade process will be exited.

[0081] If S1112 is the same, read the non-system firmware version number from the decrypted version number binary image file, and compare the version number with the current non-system firmware version number. If the version number is greater than the current non-system firmware version number, execute the following step S12; otherwise, prompt that the version number is too low and upgrade is not allowed, and exit the firmware upgrade process.

[0082] S12 writes special upgrade instructions for non-system firmware upgrades and the path to the non-system firmware upgrade package to a preset location in the boot communication partition.

[0083] When the S13 device restarts, the bootloader firmware checks if there are any special upgrade instructions for non-system firmware upgrades in the preset location of the boot communication partition. If so, it boots the device into firmware upgrade mode.

[0084] Part Four, in Firmware Upgrade Mode:

[0085] S14 reads the special upgrade instructions for non-system firmware upgrades and the path to the non-system firmware upgrade package from the preset location of the boot communication partition. It uses the public key file under the preset path of the upgrade mode to verify the non-system firmware upgrade package. If the verification fails, the upgrade result is set to failure, the firmware upgrade process exits, and the process jumps to step S15. If the verification succeeds, the non-system firmware upgrade is completed according to the contents of the non-system firmware upgrade package. If the upgrade fails, the upgrade result is set to failure, the firmware upgrade process exits, and the process jumps to step S15. Otherwise, the upgrade succeeds, the encrypted version number binary image file (e.g., version_encry.bin) in the non-system firmware upgrade package is read, and the encrypted version number binary image file is written to the preset version number area. The upgrade result is set to success, and then step S15 is executed. The preset version number area must be a storage area that cannot be deleted during factory reset and can be accessed by both system firmware and upgrade mode firmware, such as the version number partition, a specific location in the boot communication partition, or vendor storage.

[0086] S15 writes the upgrade result and the path to the non-system firmware upgrade package to a non-system firmware upgrade result flag file (e.g., / cache / plat_standalone_flag) in a preset path. It then clears the special upgrade instructions and the path to the non-system firmware upgrade package from the preset location in the boot communication partition. Finally, the device restarts and boots into the upgraded system.

[0087] It should be noted that although the above embodiments have been described herein, this does not limit the scope of patent protection for this invention. Therefore, any changes and modifications made to the embodiments described herein based on the innovative concept of this invention, or equivalent structural or procedural transformations made using the description and drawings of this invention, directly or indirectly applying the above technical solutions to other related technical fields, are all included within the scope of patent protection for this invention.

Claims

1. A method of upgrading non-system firmware, the method comprising: The method comprises: obtaining a current non-system firmware version number from a version number area; obtaining a non-system firmware upgrade package to be upgraded according to the current non-system firmware version number; writing special upgrade instructions for non-system firmware upgrade and a non-system firmware upgrade package path into a preset position of a boot communication partition according to a non-system firmware version number of a version number binary image file in the non-system firmware upgrade package; upgrading non-system firmware through a non-system firmware upgrade package under the non-system firmware upgrade package path according to the special upgrade instructions in the preset position of the boot communication partition; writing the version number binary image file in the non-system firmware upgrade package into the version number area; writing an upgrade result and the non-system firmware upgrade package path into an upgrade result marker file under a preset path; clearing the special upgrade instructions and the non-system firmware upgrade package path in the preset position of the boot communication partition; and restarting the device to boot the device into the system again, wherein upgrading non-system firmware through a non-system firmware upgrade package under the non-system firmware upgrade package path according to the special upgrade instructions in the preset position of the boot communication partition comprises: checking whether the special upgrade instructions exist in the preset position of the boot communication partition through starting a boot program firmware; if the special upgrade instructions exist, booting the device into a firmware upgrade mode, reading the non-system firmware upgrade package path from the preset position of the boot communication partition; and completing the upgrade of non-system firmware according to the content of the non-system firmware upgrade package, wherein writing the version number binary image file in the non-system firmware upgrade package into the version number area comprises: if the upgrade is successful, reading the encrypted version number binary image file from the non-system firmware upgrade package and writing the encrypted version number binary image file into the version number area; and setting the upgrade result as successful. Obtaining a non-system firmware upgrade package to be upgraded according to the current non-system firmware version number comprises:

2. The method of claim 1, wherein, querying whether there is a new version of non-system firmware to be upgraded in a firmware upgrade server using the current non-system firmware version number; and if there is a new version of non-system firmware to be upgraded, obtaining the non-system firmware upgrade package as an independent non-system firmware upgrade package, the non-system firmware upgrade package comprising non-system firmware to be independently upgraded and an encrypted version number binary image file, the non-system firmware version number in the version number binary image file serving as the version number of the non-system firmware upgrade package. Writing special upgrade instructions for non-system firmware upgrade and a non-system firmware upgrade package path into a preset position of a boot communication partition according to a non-system firmware version number of a version number binary image file in the non-system firmware upgrade package comprises:

3. The method of claim 1, wherein, obtaining the version number binary image file from the non-system firmware upgrade package; reading the non-system firmware version number from the version number binary image file and comparing the non-system firmware version number with the current non-system firmware version number; and if the non-system firmware version number is different from the current non-system firmware version number, writing the special upgrade instructions and the non-system firmware upgrade package path into the preset position of the boot communication partition. write the special upgrade instruction and the non-system firmware upgrade package path at a preset location of a boot communication partition based on a result of the comparison; and cause the device to restart to boot the device into a firmware upgrade mode.

4. The method of claim 1, wherein, The version number binary image file in the non-system firmware upgrade package includes a preset fixed-length magic number and a fixed-length non-system firmware version number; The encrypted version number binary image file obtained by encrypting the version number binary image file and the non-system firmware to be burned are packaged as the non-system firmware upgrade package; A pair of public and private keys are generated using a first digital signature algorithm, the non-system firmware upgrade package is signed using the private key, the signed non-system firmware upgrade package is recorded into a firmware upgrade server for downloading, and the corresponding public key is simultaneously preset to a system firmware preset path and an upgrade mode firmware preset path.

5. The method of claim 1, wherein, Obtaining a current non-system firmware version number from a version number area includes: reading an encrypted current non-system firmware version number file from the version number area when the device starts; decrypting the encrypted current non-system firmware version number file, and determining whether a starting fixed-length content in the decrypted current non-system firmware version number file is the same as a magic number of a preset version number binary image file; and if the same, obtaining the current non-system firmware version number from the decrypted current non-system firmware version number file.

6. The method of claim 5, wherein, Further includes: if the starting fixed-length content in the decrypted current non-system firmware version number file is not the same as the magic number of the preset version number binary image file, creating a temporary buffer area, and writing the magic number and a fixed-length preset default non-system firmware version number at a start position of the temporary buffer area; and encrypting the temporary buffer area using a preset encryption algorithm and a key, and writing the encrypted content to the version number area. After obtaining the non-system firmware upgrade package to be upgraded, further includes:

7. The method of claim 1, wherein, reading an encrypted version number binary image file in the non-system firmware upgrade package, and decrypting using a symmetric encryption algorithm and a key; determining whether a fixed-length magic number in the decrypted version number binary image file is the same as a preset value; if not the same, prompting an error and exiting a firmware upgrade process; if the same, obtaining a non-system firmware version number in the decrypted version number binary image file, and comparing the non-system firmware version number with the current non-system firmware version number; and if the non-system firmware version number is not greater than the current non-system firmware version number, prompting that the version number is too low, and exiting the firmware upgrade process. includes:

8. An electronic device, comprising: a memory configured to store a computer program; and a processor configured to execute the computer program to perform the method according to any one of claims 1 to 7. The computer program is executed to implement the method according to any one of claims 1 to 7.

9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed to implement the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Fast-charging firmware upgrading method and device, mobile terminal and storage medium

    CN112214235A

  • Method for upgrading firmware, electronic equipment and computer readable medium

    CN114895939A