Firmware upgrading method and related device

By introducing EFI adaptation layer and kernel-state upgrade modules into the UEFI layer, the upgrade package is directly written into the firmware partition, which solves the disk space occupation and security risks caused by small system dependence, and achieves efficient and secure firmware upgrades.

CN120371359APending Publication Date: 2025-07-25HUAWEI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410094704.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-23
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

In the prior art, firmware upgrades of electronic devices need to rely on small systems, resulting in increased disk space usage and increased security risks, and the firmware upgrade process is not efficient and secure enough.

Method used

By adding an EFI adaptation layer to the unified extensible firmware interface (UEFI) layer, the kernel-state upgrade module and block device driver directly write the upgrade package in the firmware partition to avoid relying on small systems and realize the firmware upgrade process in the kernel state.

Benefits of technology

It improves the disk usable space of electronic devices, enhances the security and efficiency of firmware upgrades, and avoids the space occupation and security risks brought by small systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371359A_ABST
    Figure CN120371359A_ABST
Patent Text Reader

Abstract

The invention provides a firmware upgrading method and a related device, in the method, an electronic device can add an EFI adaptation layer in a unified extensible firmware interface (UEFI) layer, and then an upgrading module of the UEFI layer can call a block device driver to write an upgrading package of target firmware in a firmware partition through the EFI adaptation layer. Therefore, the electronic equipment can realize firmware upgrading through the UEFI layer without a small system. And moreover, the whole firmware upgrading process is completed in a kernel mode, so that the method is safer and more reliable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of terminals, and in particular, to a firmware upgrade method and related devices. Background Art

[0002] Currently, electronic devices can implement computing functions, image data processing functions, voice signal processing functions, etc. through chips. For example, there are system-on-chip (SOC; SOC can also be referred to as a system on a chip) in some electronic devices. Electronic devices can implement computing functions, image data processing functions, voice signal processing functions, etc. through the SOC.

[0003] There is one or more firmware in the chips of electronic devices, and the one or more firmware are used to drive the chips to implement corresponding functions. As the functions of the chips in electronic devices are continuously improved and developed, the firmware in the chips also needs to be upgraded and updated.

[0004] Therefore, how to upgrade the firmware in electronic devices safely and efficiently is an urgent problem to be solved. Summary of the Invention

[0005] This application provides a firmware upgrade method and related devices. Through this method, an electronic device can upgrade the firmware safely and efficiently, and does not need to pre-set a small system, which can increase the actual disk available space for users in the electronic device.

[0006] In a first aspect, this application provides a firmware upgrade method. This method can be applied to an electronic device, which can include a system layer, a kernel layer, and a firmware layer. The system layer can include an operating system, the kernel layer can include an upgrade module, an Extensible Firmware Interface (EFI) adaptation layer, and a block device driver, and the firmware layer can include a chip firmware partition. The method can include: the operating system obtains an upgrade package of the target firmware; the operating system provides the upgrade package to the upgrade module; the upgrade module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the chip firmware partition.

[0007] In this way, the electronic device does not need to pre-set an additional small system, and the firmware upgrade can be achieved through the upgrade module in the kernel layer. Thus, the actual disk available space for users in the electronic device can be increased. The upgrade module can directly complete the corresponding upgrade operation in the running environment in the kernel state, without having to start a small system additionally, and the process is more concise. And through the adaptation operation of the EFI adaptation layer, the upgrade module has the ability to read and write the firmware partition in the UEFI stage, so as to complete the firmware upgrade based on the kernel state. The entire firmware upgrade process is completed in the kernel state, which is more secure and reliable. Therefore, the electronic device can upgrade the firmware more safely and efficiently.

[0008] In combination with the first aspect, in a possible implementation, before the upgrade module writes the upgrade package of the target firmware to the chip firmware partition by calling the block device driver through the EFI adaptation layer, the method may further include: the upgrade module obtains the version number of the upgrade package and the version number of the installation number of the target firmware.

[0009] The upgrade module writes the upgrade package of the target firmware to the chip firmware partition by calling the block device driver through the EFI adaptation layer, which may specifically include: if the version number of the upgrade package is higher than the version number of the installation package of the target firmware, the upgrade module writes the upgrade package of the target firmware to the chip firmware partition by calling the block device driver through the EFI adaptation layer.

[0010] In this way, the upgrade module obtains the version number of the upgrade package and the version number of the installation package of the target firmware, and performs firmware upgrade after comparing the version numbers, which can avoid wasting the power consumption of the electronic device when the version number of the upgrade package is not higher than the version number of the installation package but still performing the upgrade.

[0011] In combination with the first aspect, in a possible implementation, the upgrade module includes a file reading and writing module and a firmware upgrade module. The upgrade module obtains the version number of the upgrade package and the version number of the installation number of the target firmware, which may specifically include: the firmware upgrade module sends a first instruction to the file reading and writing module, and the first instruction is used to instruct the file reading and writing module to obtain the version number of the upgrade package and the version number of the installation number of the target firmware; in response to the first instruction, the file reading and writing module reads the version number of the upgrade package by calling the block device driver through the EFI adaptation layer and reads the version number of the installation package of the target firmware in the chip firmware partition; the file reading and writing module sends the version number of the upgrade package and the version number of the installation package of the target firmware to the firmware upgrade module.

[0012] In this way, the file reading and writing module in the kernel layer has the ability to read data through the EFI adaptation layer. Thus, the firmware upgrade module can obtain the version number of the upgrade package and the version number of the installation package of the target firmware through the file reading and writing module.

[0013] In combination with the first aspect, in a possible implementation, the upgrade module includes a disk writing module. If the version number of the upgrade package is higher than the version number of the installation package of the target firmware, the upgrade module writes the upgrade package of the target firmware to the chip firmware partition by calling the block device driver through the EFI adaptation layer, which may specifically include: after the firmware upgrade module determines that the version number of the upgrade package is higher than the version number of the installation package of the target firmware, it sends a second instruction to the disk writing module, and the second instruction is used to instruct the disk writing module to write the upgrade package to the chip firmware partition; in response to the second instruction, the disk writing module writes the upgrade package of the target firmware to the chip firmware partition by calling the block device driver through the EFI adaptation layer.

[0014] In this way, since the disk writing module in the kernel layer is adapted through the EFI adaptation layer and has the ability to write data, the firmware upgrade module can write the upgrade package of the target firmware into the chip firmware partition through the disk writing module.

[0015] Combined with the first aspect, in a possible implementation, before the upgrade module obtains the version number of the upgrade package and the version number of the installation number of the target firmware, the method may further include: the upgrade module verifies the upgrade package to determine that the upgrade package is a complete upgrade package.

[0016] In this way, the legitimacy and integrity of the upgrade package can be confirmed.

[0017] Combined with the first aspect, in a possible implementation, the upgrade module may include a signature verification module. When the upgrade module verifies the upgrade package to determine the integrity of the upgrade package, it may specifically include: the firmware upgrade module instructs the file reading and writing module to send the read upgrade package to the signature verification module and instructs the signature verification module to verify the upgrade package; the signature verification module verifies the upgrade package to determine that the upgrade package is a complete upgrade package.

[0018] In this way, the upgrade can be verified through the signature verification module, so that the legitimacy and integrity of the upgrade package can be confirmed.

[0019] Combined with the first aspect, in a possible implementation, the chip firmware partition may include a main area and a backup area, and the target firmware exists in the main area and the backup area; when the disk writing module writes the upgrade package of the target firmware into the chip firmware partition by calling the block device driver through the EFI adaptation layer, it may specifically include: when the upgrade module determines that the main area is started, the disk writing module writes the upgrade package of the target firmware into the backup area by calling the block device driver through the EFI adaptation layer; when the upgrade module determines that the backup area is started, the disk writing module writes the upgrade package of the target firmware into the main area by calling the block device driver through the EFI adaptation layer.

[0020] In this way, upgrading the target firmware in the non-boot area (main area or backup area) does not affect the normal startup of the electronic device. Moreover, since the electronic device has a main area and a backup area, if the firmware in one of the main area or the backup area is damaged, the electronic device can start the other area without affecting the normal use of the electronic device.

[0021] Combined with the first aspect, in a possible implementation, after the disk writing module writes the upgrade package of the target firmware into the backup area by calling the block device driver through the EFI adaptation layer, the method may further include: the disk writing module updates the version number of the target firmware in the backup area by calling the block device driver through the EFI adaptation layer.

[0022] In this way, the electronic device can update the version number of the target firmware in the standby area through the write disk module, so that the version indicated by the version number in the standby area is consistent with the version of the upgrade package of the upgraded target firmware.

[0023] In combination with the first aspect, in a possible implementation, after the write disk module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the main area, the method may further include: the write disk module calls the block device driver through the EFI adaptation layer to update the version number of the target firmware in the main area.

[0024] In this way, the electronic device can update the version number of the target firmware in the main area through the write disk module, so that the version indicated by the version number in the main area is consistent with the version of the upgrade package of the upgraded target firmware.

[0025] In combination with the first aspect, in a possible implementation, the target firmware may include one or more of the loading firmware Xloader, the ARM trusted firmware - boot firmware ATF - BL1 / 2, the ARM trusted firmware - secure mode running software ATF - BL 3 - 1, the hypervisor execution environment HEE, and the trusted execution environment TEEOS.

[0026] In combination with the first aspect, in a possible implementation, the small system is not included in the system layer, and the partition for storing the small system is not included in the disk partition of the electronic device; the small system is used to call the file system interface through the system library function to read the version number of the installation package of the target firmware in the chip firmware partition and write the upgrade package of the target firmware into the chip firmware partition.

[0027] In this way, the electronic device does not need to pre - install an additional small system, which can increase the actual available disk space for users in the electronic device.

[0028] In a second aspect, an electronic device is provided. The electronic device may include a display screen, one or more processors, and one or more memories; wherein, the display screen, one or more memories are coupled to one or more processors, and one or more memories are used to store computer program code. The computer program code includes computer instructions. When the one or more processors execute the computer instructions, the first electronic device executes the method in any possible implementation manner of the first aspect as described above.

[0029] In a third aspect, a chip system is provided. The chip system can be applied to an electronic device. The chip system may include a processing circuit and an interface circuit. The interface circuit is used to receive code instructions and transmit them to the processing circuit, and the processing circuit is used to run the code instructions to execute the method in any possible implementation manner of the first aspect as described above.

[0030] Fourthly, a computer-readable storage medium stores instructions, which, when running on a computer, cause the computer to execute the method in any possible implementation manner of any of the above aspects.

[0031] Fifthly, a computer program product is provided, which, when running on a computer, causes the computer to execute the method in any possible implementation manner of any of the above aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 FIG. is a schematic diagram of a firmware upgrade scenario provided by an embodiment of the present application;

[0033] Figure 2A FIG. is a schematic diagram of a software framework of an electronic device provided by an embodiment of the present application;

[0034] Figure 2B FIG. is a schematic diagram of related modules for firmware upgrade in the software framework of an electronic device provided by an embodiment of the present application;

[0035] Figure 3 FIG. is a schematic diagram of a user interface provided by an embodiment of the present application;

[0036] Figure 4 FIG. is a schematic diagram of a user interface provided by an embodiment of the present application;

[0037] Figure 5 FIG. is a schematic diagram of a firmware upgrade method flow provided by an embodiment of the present application;

[0038] Figure 6 FIG. is a schematic diagram of a user interface provided by an embodiment of the present application;

[0039] Figure 7 FIG. is a schematic diagram of a user interface provided by an embodiment of the present application;

[0040] Figure 8A FIG. is a schematic diagram of another software framework of an electronic device provided by an embodiment of the present application;

[0041] Figure 8B FIG. is a schematic diagram of another related module for firmware upgrade in the software framework of an electronic device provided by an embodiment of the present application;

[0042] Figure 9 FIG. is a schematic diagram of another firmware upgrade method flow provided by an embodiment of the present application;

[0043] Figure 10 FIG. is a schematic diagram of a firmware upgrade method interaction provided by an embodiment of the present application;

[0044] Figure 11It is a schematic diagram of the specific process for firmware upgrade of the UEFI layer of the electronic device 100 provided by the embodiments of the present application;

[0045] Figure 12 It is a schematic diagram of the startup and upgrade switching logic of the firmware in Area A and Area B provided by the embodiments of the present application;

[0046] Figure 13 It is a schematic diagram of the structure of the electronic device provided by the embodiments of the present application. Detailed implementation manners

[0047] Next, the technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0048] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. As used in the specification and claims of the present application, the singular forms "a", "an", "the", "above", "said", "this" are also intended to include the plural forms, unless the context clearly indicates otherwise. The terms "first" and "second" are only used for descriptive purposes, and cannot be understood as implying or suggesting relative importance or implicitly indicating the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. "First" and "second" etc. are used to distinguish different objects, rather than to describe the specific order of the objects. For example, the first object and the second object are used to distinguish different objects, rather than to describe the specific order of the objects.

[0049] In the description of the embodiments of the present application, unless otherwise specified, "a plurality of" means two or more. For example, a plurality of processing units means two or more processing units; a plurality of systems means two or more systems.

[0050] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or related solution described as "exemplary" or "for example" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0051] The term "and / or" in this application merely describes the relationship between associated objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, both A and B exist simultaneously, and B exists alone.

[0052] The term "user interface (UI)" in the following embodiments of this application is a media interface for interaction and information exchange between an application or an operating system and a user. It realizes the conversion between the internal form of information and the form acceptable to the user. The user interface is source code written in a specific computer language such as Java or Extensible Markup Language (XML). The interface source code is parsed and rendered on an electronic device and finally presented as content recognizable by the user. The common manifestation form of the user interface is the graphical user interface (GUI), which refers to the user interface related to computer operations displayed in a graphical manner. It can be visible interface elements such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and Widgets displayed on the display screen of an electronic device.

[0053] In the embodiments of this application, firmware is a software embedded in a hardware device (such as a chip or a system-on-chip). The firmware can be used to drive the hardware device to implement the basic functions in the hardware device. Usually, the firmware can be located in the flash memory, or the electrically erasable programmable read-only memory (EEPROM), or the programmable read-only memory (PROM) in an application-specific integrated circuit (or called an application-specific integrated circuit) (ASIC) or a programmable logic device (PLD). An electronic device can upgrade the firmware, that is, the electronic device can update the version of the firmware.

[0054] In the embodiments of this application, a chip or a system-on-chip (SOC) can be composed of an ASIC and / or a PLD.

[0055] In a possible implementation manner, when the firmware in the chip of an electronic device needs to be upgraded, a user (which can be understood as the person who disassembles the chip for firmware upgrade) can disassemble the chip from the electronic device and burn the new version of the firmware into the chip. Exemplarily, such as Figure 1As shown in the figure, when the firmware in the chip (e.g., CPU) in the laptop 103 needs to be upgraded, the user can disassemble the chip from the laptop 103 and then connect it to the host 102. The host 102 can be connected to the display 101. The user can select to burn the new version of the firmware into the chip of the laptop 103 through the display 101. In this way, the firmware in the chip can be updated and upgraded.

[0056] In this way, the firmware in the electronic device can be upgraded through this method. However, it is necessary to disassemble the electronic device, and the operation is relatively complex. If the user is not familiar with the hardware structure of the electronic device, it may damage the hardware or circuit connection in the electronic device during the disassembly process.

[0057] In another possible implementation, the electronic device does not need to be disassembled, and the firmware of the electronic device can be upgraded through a small system in the system layer of the electronic device. First, the software and hardware architecture of the electronic device will be described below, and then how to upgrade the firmware in the electronic device through the small system will be specifically described in combination with the software framework of the electronic device.

[0058] The software structure of the electronic device 100 will be described below. Before describing the software structure of the electronic device 100, first, the architecture that the software system of the electronic device 100 can adopt will be described.

[0059] Specifically, in practical applications, the software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture.

[0060] In addition, it can be understood that the software systems used in current mainstream electronic devices include but are not limited to the Windows system, the Linux system, the Android system, and the iOS system. For the convenience of description, in the embodiments of the present application, the Linux system with a layered architecture is taken as an example to exemplarily illustrate the software structure of the electronic device 100.

[0061] In addition, the subsequent firmware upgrade method provided in the embodiments of the present application is equally applicable to other systems in specific implementations.

[0062] Figure 2A An exemplary schematic diagram of the software framework of an electronic device 100 provided in the embodiments of the present application is shown.

[0063] As Figure 2AAs shown, the layered architecture can divide the software system of the electronic device 100 into several layers, each layer having a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the software system of the electronic device 100 can be divided into three layers, namely, the system layer, the unified extensible firmware interface (UEFI) layer, and the firmware layer.

[0064] Among them, as Figure 2A shown, the system layer can include a normal system and a small system.

[0065] In the embodiments of the present application, the normal system can be referred to as a normal operating system or an operating system, etc. The normal system is a set of related system software programs that can manage and control the operations, applications, and running of hardware and software resources of the electronic device. The normal system can also provide public services to achieve user interaction.

[0066] In the embodiments of the present application, the small system can be referred to as a small operating system. The small system is a simplified version of the operating system after being trimmed based on the normal system. The small system only retains the most basic system capabilities and is used as a space for backup, upgrade, and recovery.

[0067] Optionally, in some embodiments, the small system may further include an upgrade APP. The upgrade APP can be used to upgrade the firmware in the hardware layer.

[0068] In some embodiments, the system layer can also be referred to as the user state or user space. The system layer is the area where user processes / threads are located and can be used to execute user programs.

[0069] In some embodiments, the UEFI layer can also be referred to as the kernel state or kernel space. The UEFI layer is the area where kernel processes / threads are located and can be used to be responsible for running the system and hardware interaction.

[0070] The firmware layer can include multiple firmware, etc. and a memory for storing multiple firmware. Exemplarily, as Figure 2AAs shown, the firmware layer may include on-chip read only memory (on-chip ROM), the loaded firmware Xloader, the ARM trusted firmware - boot loader stage 1 / 2 (ATF - BL1 / 2), the ARM trusted firmware - software running in the secure mode (ARM trusted firmware - boot loader stage 3 - 1, ATF - BL 3 - 1), the hypervisor execution environment (HEE), and the trusted execution environment operating system (TEEOS). In some examples, TEEOS may also be referred to as the secure OS area.

[0071] Among them, on-chip ROM is the ROM inside the chip (for example, the CPU chip), which is a non-volatile memory that can be read but not written. The data in this on-chip ROM cannot be updated, but it can be read. In the case of power failure, the data in this on-chip ROM can also be retained. In the embodiments of the present application, a bootloader is stored in this on-chip ROM. When the chip starts up, this bootloader can boot the Xloader in the chip. Xloader can be used to record the startup sequence, loading sequence, etc. of the modules (including hardware modules and software modules (such as firmware)) in the chip (for example, the CPU chip). Xloader can also be used to record the partition table of the firmware in the chip. The partition table of the firmware may include one or more of the name, function, memory size occupied, and whether it can be upgraded of the firmware.

[0072] ATF - BL1 / 2 can be used to complete the preparation of the corresponding functional capabilities in the chip when starting up the chip.

[0073] ATF - BL 3 - 1 can be used to complete the initialization of the software and hardware in the chip.

[0074] HEE can be used to provide a unified instruction execution environment.

[0075] TEEOS can be used to provide a secure execution environment.

[0076] In some embodiments, Xloader, ATF-BL1 / 2, ATF-BL 3-1, HEE, and TEEOS may be firmware in the CPU chip. The electronic device can also upgrade the firmware such as Xloader, ATF-BL1 / 2, ATF-BL 3-1, HEE, and TEEOS.

[0077] It can be understood that the firmware contained in different types of chips may be different. For example, the firmware contained in a CPU chip and the firmware contained in a memory chip may be different. For chips of the same type, but from different manufacturers and different batches, the firmware contained may be different. For example, the firmware contained in a CPU chip produced by manufacturer A and the firmware contained in a CPU chip produced by manufacturer B may be different. Also, for example, the firmware contained in batch A of the CPU chips produced by manufacturer A and the firmware contained in batch B of the CPU chips produced by manufacturer A may be different.

[0078] Figure 2A The marked serial numbers 1-8 refer to the startup sequence of the corresponding modules when the electronic device starts up. As Figure 2A shown, when the chip (such as a CPU chip) starts up, the on-chip ROM in the chip can first boot Xloader, then boot ATF-BL1 / 2, and then boot ATF-BL 3-1; when booting ATF-BL 3-1, TEEOS can be booted, and then, ATF-BL 3-1 can continue to be booted, and finally, the HEE can be booted. After the CPU chip starts up, the electronic device can start the Unified Extensible Firmware Interface (UEFI). Finally, the electronic device 100 can start the small system.

[0079] As Figure 2B shown, upgrading the APP in the small system can also include a file reading and writing module 201, a disk writing module 202, a signature verification module 203, and a firmware upgrade module 204.

[0080] Among them, there may be firmware upgrade logic in the firmware upgrade module 204. The firmware upgrade module 204 can also be used to control modules such as the file reading and writing module 201, the disk writing module 202, and the signature verification module 203 to execute the firmware upgrade task according to the firmware upgrade logic.

[0081] The file reading and writing module 201 can be used to read the local configuration file in the electronic device 100 and parse the upgrade package of the target firmware.

[0082] The signature verification module 203 can be used to verify the upgrade package of the target firmware.

[0083] The disk writing module 202 can be used to write the upgrade package of the target firmware into the chip where the target firmware is located.

[0084] As shown Figure 2B in the figure, the small system may further include Linux system library functions. The kernel state may include a Linux file system interface. The hardware layer may include a chip firmware partition. The file reading and writing module in the small system may call the Linux file system interface through the Linux system library functions to read the version number of the target firmware in the chip firmware partition. The disk writing module in the small system may also call the Linux file system interface through the Linux system library functions to write the upgrade package of the target firmware in the chip firmware partition according to the file format.

[0085] Optionally, in some embodiments, a part of the memory space in the disk space of the electronic device 100 may be partitioned to store the firmware in the electronic device (including the executable file of the firmware and the installation package of the firmware). This part of the memory space used to store the firmware in the electronic device may be referred to as a chip firmware partition. The chip firmware partition may be further partitioned into area A and area B, and both area A and area B contain a set of firmware in the chip. For example, a part of the memory space in the SDC disk of the electronic device 100 may be used as the chip firmware partition, and the chip firmware partition may include area A and area B. Among them, area A may include firmware such as Xloader, ATF-BL1 / 2, ATF-BL 3-1, HEE, and TEEOS, and area B may also include firmware such as Xloader, ATF-BL1 / 2, ATF-BL 3-1, HEE, and TEEOS. The version of the firmware in area A and the version number of the firmware in area B may be the same or different.

[0086] In a possible implementation manner, the electronic device 100 may swap the startup of area A and area B during startup. Exemplarily, if the electronic device 100 starts area A this time, then it will start area B the next time it starts.

[0087] In some embodiments, area A may also be referred to as the primary area, and area B may also be referred to as the backup area. The embodiments of the present application do not limit this.

[0088] In a possible implementation manner, the small system may further include a partition switching module 205. The partition switching module 205 may be used to switch the startup of area A or area B. Specifically, when area A is currently starting, after the target firmware in area B is upgraded to the latest version, the partition switching module 205 may be used to switch to area B to start. Similarly, when area B is currently starting, after the target firmware in area A is upgraded to the latest version, the partition switching module 205 may be used to switch to area A to start.

[0089] Exemplarily, when a small system is installed in the electronic device 100, the electronic device 100 can view the installation location of the small system and the memory size occupied by the small system in the electronic device 100. For example, when the Windows operating system is installed in the electronic device 100, the electronic device 100 can receive a command character input by the user for viewing the installation location of the small system. In response to this user operation, the electronic device 100 can display as Figure 3 shown in the user interface 300. In the area 301 of this user interface 300, the storage location of the small system, the type of file system (filesystem, FS), and the memory size occupied, etc. are shown. As Figure 3 shown, the storage location of the small system is volume 2 in the disk partition, the type of file system is file allocation table (FAT32), and the memory size occupied by the small system can be 512 MB (MB is a unit of memory capacity, representing "megabyte").

[0090] For another example, when the Linux operating system is installed in the electronic device 100, the electronic device 100 can receive a command character input by the user for viewing the installation location of the small system. In response to this user operation, the electronic device 100 can display as Figure 4 shown in the user interface 400. In the area 401 of this user interface 400, the storage location of the small system, the file system type (FSType), the partition label (partlabel), and the memory size occupied, etc. are shown. As Figure 4 shown, the storage location of the small system is partition sdc24 of disk sdc in the disk, FSType is VFAT (VFAT represents an extension of the FAT file system), the partition label is recovery, and the memory size occupied is 800M.

[0091] The above Figure 2A shown firmware is only an example, and the embodiments of the present application do not limit the types and quantities of the firmware included in the electronic device 100.

[0092] Based on Figure 2A the software and hardware architecture of the shown electronic device, the steps for the electronic device 100 to upgrade the firmware can include: when the electronic device 100 obtains an upgrade package of the target firmware, the small system in the electronic device 100 can read the installation package of the target firmware. When it is determined that the version of the upgrade package is newer than the version of the installation package, the small system in the electronic device 100 can write the upgrade package into the memory storing the target firmware.

[0093] Figure 5 Exemplarily shows a flowchart of the method for the electronic device 100 to upgrade the firmware through the small system. As Figure 5As shown, the steps for the electronic device 100 to upgrade the firmware through the small system may include the following:

[0094] S501. The normal system in the electronic device 100 downloads the upgrade package.

[0095] The normal system in the electronic device 100 may be an operating system installed in the electronic device 100, and this operating system may include, but is not limited to, Windows system, Linux system, Android system, HarmonyOS, etc.

[0096] The normal system of the electronic device 100 can download the upgrade package for the target firmware. The target firmware may be one or more firmwares to be upgraded in the electronic device 100. Exemplarily, the normal system in the electronic device 100 can download the upgrade package through over-the-air (OTA) technology.

[0097] In some instances, this normal system may also be referred to as the user system, and the embodiments of the present application do not make limitations in this regard.

[0098] S502. The normal system in the electronic device 100 releases the upgrade package.

[0099] The normal system in the electronic device 100 can release the upgrade package to the directory in the electronic device 100 for storing the firmware upgrade package. Exemplarily, the normal system in the electronic device 100 can release the upgrade package to the / opt directory. This / opt directory may be the directory in the electronic device 100 for installing third-party software (including firmware). Generally, the third-party software in this / opt directory is provided in the form of independent folders, including executable files, library files, documents, etc.

[0100] It can be understood that the third-party software is not included in the official software package of the normal system and does not belong to a part of the normal system. In the embodiments of the present application, the third-party software may be software provided by a third-party developer, and this third-party developer is not the developer of the normal system. The firmware may also be referred to as third-party software.

[0101] Optionally, in a possible implementation manner, the normal system of the electronic device 100 may include software 1 for obtaining the firmware upgrade package. The electronic device 100 can obtain the downloaded firmware upgrade package through this software 1. Then, this software 1 can release the downloaded firmware upgrade package to the / opt directory.

[0102] S503. The normal system in the electronic device 100 gives an upgrade reminder.

[0103] In a possible implementation, the electronic device 100 can read the firmware upgrade package and determine whether the firmware upgrade package is the latest version based on the version number of the firmware upgrade package. If the firmware upgrade package is the latest version, the electronic device 100 can give an upgrade reminder. If the firmware upgrade package is not the latest version, the electronic device 100 can skip steps S503 - S509.

[0104] In a possible implementation, when the firmware upgrade package is the latest version, the electronic device 100 can give an upgrade reminder by displaying a pop-up window or a notification message.

[0105] Optionally, in a possible implementation, the user can choose to upgrade immediately or after a preset time interval based on the pop-up window or the notification message, or the user can also specify the upgrade time based on the pop-up window or the notification message. For example, the user can choose to upgrade immediately in the pop-up window or the notification message, or upgrade after 2 hours, or specify to start the upgrade at midnight. It can be understood that the preset time interval can be 2 hours, or 3 hours, etc. The specified upgrade time can be midnight, or 8 pm, or 5 am, etc. The embodiments of the present application do not limit the preset time interval and the specified upgrade time.

[0106] Optionally, in a possible implementation, after the electronic device 100 displays a pop-up window or a notification message, if no upgrade instruction is received from the user, the electronic device 100 can perform the upgrade according to the default upgrade time. The default upgrade time can be configured by the system of the electronic device 100, or the default upgrade time can also be determined by the electronic device 100 based on the historical data of the user using the electronic device 100. For example, the default upgrade time can be 22:00 at night. The embodiments of the present application do not limit the default upgrade time.

[0107] S504. The electronic device 100 performs firmware loading.

[0108] During the firmware upgrade process of the electronic device 100, the electronic device 100 needs to shut down first and then restart. The electronic device 100 can upgrade the firmware to be upgraded, that is, the target firmware, during the restart process.

[0109] It can be understood that during the restart process of the electronic device 100, the electronic device 100 can perform firmware loading. Exemplarily, the electronic device 100 can load (or start) the firmware in the CPU in the loading order shown in Figure 2A in sequence.

[0110] S505. The UEFI layer in the electronic device 100 starts the BIOS.

[0111] After the firmware in the electronic device 100 is loaded, the UEFI layer in the electronic device 100 can start the basic input output system (BIOS).

[0112] The BIOS can be a program for booting the operating system in the electronic device 100. The BIOS can be stored in the UEFI chip of the electronic device 100. In some examples, the UEFI chip can also be referred to as a UEFI BIOS chip, and the embodiments of the present application do not limit this.

[0113] The electronic device 100 can start the BIOS, and then, through the BIOS, boot the operating system and provide input / output (I / O) for the hardware in the electronic device 100.

[0114] S506. The UEFI layer in the electronic device 100 boots the small system.

[0115] The BIOS in the UEFI layer of the electronic device 100 can boot the small system.

[0116] S507. The small system in the electronic device 100 loads the upgrade program.

[0117] The small system in the electronic device 100 can load the upgrade program during the startup process.

[0118] In a possible implementation, the upgrade program may include modules such as Figure 2B the file reading and writing module 201, the disk writing module 202, the signature verification module 203, the firmware upgrade module 204, and the partition switching module 205 shown in. The small system of the electronic device 100 can load the file reading and writing module 201, the disk writing module 202, the signature verification module 203, the firmware upgrade module 204, the partition switching module 205, and other modules in sequence during the process of loading the upgrade program.

[0119] S508. The small system in the electronic device 100 starts to upgrade.

[0120] After the small system in the electronic device 100 is started, it can start to upgrade the firmware. In a possible implementation, the firmware upgrade module 204 in the upgrade program APP of the small system can send instruction 1 to the file read / write module 201, and this instruction 1 can be used to instruct the file read / write module 201 to read the upgrade package of the firmware to be upgraded. Then, the firmware upgrade module can also send instruction 2 to the signature verification module 203, and this instruction 2 can be used to instruct the signature verification module 203 to verify the integrity and signature of the upgrade package of the firmware to be upgraded. When the signature verification module 203 determines that the upgrade package is complete and legal, the disk writing module 202 in the small system can call the Linux file system interface through the Linux system library function and write the upgrade package of the target firmware into the chip firmware partition in accordance with the file format.

[0121] S509. The upgrade of the small system in the electronic device 100 is completed.

[0122] After the disk writing module 202 in the small system writes the upgrade package of the target firmware into the chip firmware partition, the small system of the electronic device 100 can end the upgrade.

[0123] In a possible implementation, when the electronic device 100 is performing firmware upgrade, it can display the upgrade progress and upgrade reminder in the user interface. Exemplarily, as Figure 6 shown, when the electronic device 100 is performing firmware upgrade, it can display the user interface 600. The user interface 600 can include an upgrade progress prompt message 601, an upgrade progress bar 602, and an upgrade reminder 603. The upgrade progress prompt message 601 can prompt that the current upgrade progress is 22%. The upgrade progress bar 602 can be used to prompt the current upgrade progress. The upgrade reminder 603 can be used to remind the user not to turn off the power during the upgrade to avoid system damage.

[0124] In a possible implementation, when the update of the target firmware fails, the electronic device 100 can prompt the user that the firmware upgrade fails in the user interface. Exemplarily, as Figure 7 shown, after the firmware upgrade of the electronic device 100 fails, it can display the user interface 700. The user interface 700 can include a prompt message 701. The prompt message 701 can be used to prompt the user that the electronic device 100 fails to install the required firmware update.

[0125] In this way, the electronic device 100 can perform firmware upgrade through the small system. However, in the above Figure 5In the illustrated firmware upgrade method, firmware upgrade depends on the small system. The electronic device 100 needs to additionally install the small system, and the small system will occupy the disk space of the electronic device 100. In this way, the disk space available to the user will be reduced. Moreover, since the small system is a simplified version trimmed from the normal version of the operating system, for the small system of the same version as the operating system, it will be released after a period of time (for example, about one month) after the normal operating system is released. In this way, the release rhythm of the small system will affect the release rhythm of the products of device manufacturers (such as computers, tablets, etc.). In addition, when the electronic device 100 upgrades the firmware through the small system, the kernel state in the electronic device 100 needs to expose an interface for firmware reading and writing to the outside. In this way, the security risk is increased.

[0126] In order not to rely on the small system for firmware upgrade, an embodiment of the present application provides another software framework for the electronic device 100. Figure 8A Exemplarily, another schematic diagram of the software framework of the electronic device 100 is shown. As Figure 8A shown, the software framework of the electronic device 100 may include a system layer, a UEFI layer, and a firmware layer.

[0127] Among them, the system layer includes a normal system and does not include a small system.

[0128] The UEFI layer, that is, the kernel state, may include the Unified Extensible Firmware Interface UEFI. Among them, the Unified Extensible Firmware Interface UEFI may include an upgrade module, and this upgrade module can be used to upgrade the firmware.

[0129] As Figure 8A shown, the firmware layer of the electronic device 100 may include on-chip ROM, Xloader, ATF-BL1 / 2, ATF-BL 3-1, HEE, TEEOS. Here, reference may be made to the description in the above Figure 2A , and details will not be repeated here.

[0130] As Figure 8B shown, the upgrade module may include a file reading and writing module 801, a disk writing module 802, a signature verification module 803, a firmware upgrade module 804, a partition switching module 805, and an Extensible Firmware Interface (EFI) adaptation layer.

[0131] As Figure 8B shown, the UEFI layer, that is, the kernel state, may also include a block device driver.

[0132] Among them, the signature verification module 803 may refer to the description of the signature verification module 203 in the above Figure 2B , and the firmware upgrade module 804 may refer to the aboveFigure 2B Description of the firmware upgrade module 204. The partition switching module 805 may refer to the above Figure 2B description of the partition switching module 205, which will not be elaborated here.

[0133] In some examples, when receiving an instruction from the firmware upgrade module 804 to instruct the file reading and writing module 801 to read a file (for example, reading the version number of the target firmware installation package), the file reading and writing module 801 may read the file in the chip firmware partition by calling the block device driver through the EFI adaptation layer. When receiving an instruction from the firmware upgrade module 804 to instruct the disk writing module 802 to write the upgrade package, the disk writing module 802 writes the upgrade package in the chip firmware partition by calling the block device driver through the EFI adaptation layer.

[0134] Among them, the EFI adaptation layer may adapt to the extensible firmware interface development kit (EDK) environment of the UEFI layer.

[0135] What the file reading and writing module 801 has in common with the file reading and writing module 201 is that the file reading and writing module 801 can read the version number of the target firmware installation package in the chip firmware partition based on the instruction of the firmware upgrade module 804. The file reading and writing module 201 can read the version number of the target firmware installation package in the chip firmware partition based on the instruction of the firmware upgrade module 204.

[0136] What the file reading and writing module 801 is different from the file reading and writing module 201 is that the file reading and writing module 801 is located in the UEFI layer and reads the version number of the target firmware installation package in the chip firmware partition through the block device driver. The file reading and writing module 201 is located in the small system and reads the version number of the target firmware installation package in the chip firmware partition through the file system.

[0137] Based on the above Figure 8A and Figure 8B software framework of the electronic device 100 shown in, an embodiment of the present application provides a firmware upgrade method. Figure 9 Exemplarily shows a schematic flow chart of a firmware upgrade method provided by an embodiment of the present application. As Figure 9 shown, a firmware upgrade method provided by an embodiment of the present application may include the following steps:

[0138] S901. The normal system in the electronic device 100 downloads the upgrade package.

[0139] Step S901 may refer to the description in the above step S501, which will not be elaborated here.

[0140] S902. The normal system in the electronic device 100 releases the upgrade package.

[0141] Step S902 can refer to the description in the above Step S502 and will not be elaborated here.

[0142] S903. The normal system in the electronic device 100 gives an upgrade reminder.

[0143] Step S903 can refer to the description in the above Step S503 and will not be elaborated here.

[0144] S904. The electronic device 100 loads the firmware.

[0145] Step S904 can refer to the description in the above Step S504 and will not be elaborated here.

[0146] S905. The UEFI layer in the electronic device 100 starts the BIOS.

[0147] Step S905 can refer to the description in the above Step S505 and will not be elaborated here.

[0148] S906. The electronic device 100 loads the upgrade module in the UEFI layer.

[0149] The electronic device can load the upgrade module in the UEFI layer. As Figure 8B shown, the upgrade module includes a file reading and writing module 801, a disk writing module 802, a signature verification module 803, a firmware upgrade module 804, a partition switching module 805, and an EFI adaptation layer. When the electronic device 100 loads the upgrade module, it can start the firmware upgrade module 804. Then, the firmware upgrade module 804 can sequentially call up modules such as the file reading and writing module 801, the signature verification module 803, the partition switching module 805, and the disk writing module 802 according to the firmware upgrade logic. Then, the file reading and writing module 801 can call up the EFI adaptation layer to read the version number of the target firmware in the chip firmware partition through the block device driver. The disk writing module 802 can call up the EFI adaptation layer to write the upgrade package of the target firmware in the chip firmware partition through the block device driver.

[0150] S907. The upgrade module in the UEFI layer of the electronic device 100 starts to upgrade.

[0151] The upgrade module in the UEFI layer of the electronic device 100 can start upgrading the target firmware. Exemplarily, in a possible implementation, the firmware upgrade module 804 in the upgrade module can instruct the file reading and writing module 801 to read the upgrade package of the target firmware. Then, the firmware upgrade module 804 can instruct the signature verification module 803 to verify the integrity and legality of the upgrade package of the target firmware. The firmware upgrade module 804 can also instruct the file reading and writing module 801 to read the version number of the installation package of the target firmware and send the version number to the signature verification module 803. The signature verification module 803 can also compare the version number of the upgrade package of the target firmware with the version number of the installation package of the target firmware. When the version number of the upgrade package of the target firmware is newer than the version number of the installation package of the target firmware, the firmware upgrade module 804 can instruct the disk writing module 802 to write the upgrade package of the target firmware into the chip firmware partition.

[0152] For how the upgrade module specifically upgrades the firmware, refer to the description of Figure 11 below, which will not be elaborated here.

[0153] S908. The upgrade module in the UEFI layer of the electronic device 100 ends the upgrade.

[0154] After the disk writing module 202 in the upgrade module of the UEFI layer successfully writes the upgrade package of the target firmware into the chip firmware partition, the upgrade module can end the upgrade.

[0155] Figure 10 This is an interaction schematic diagram of a firmware upgrade method provided by an embodiment of the present application. As Figure 10 shown, the electronic device 100 can include a normal system and a UEFI layer. A firmware upgrade method provided by an embodiment of the present application can include the following steps:

[0156] S1001. The normal system of the electronic device 100 obtains an upgrade package.

[0157] The normal system of the electronic device 100 can obtain the upgrade package of the target firmware. This step S1001 can refer to the description in the above step S501 and will not be elaborated here.

[0158] Optionally, in a possible implementation, the normal system can include a program 1 for downloading firmware. The program 1 can download the upgrade package of the target firmware. Then, the program 1 can also release the upgrade package of the target firmware to the / opt directory.

[0159] S1002. The normal system of the electronic device 100 reads the version of the upgrade package and determines that there is an update.

[0160] The normal system of the electronic device 100 can read the version number of the upgrade package and determine that the upgrade package is the latest version based on this version number. Then, the electronic device 100 can determine that the firmware needs to be updated.

[0161] Optionally, in a possible implementation, the normal system may further include a program 2 for detecting upgrades. This program 2 can read the version number of the upgrade package in the / opt directory and determine that the upgrade is the latest version based on this version number.

[0162] S1003. The normal system of the electronic device 100 gives an upgrade reminder.

[0163] When the firmware upgrade package is the latest version, the normal system of the electronic device 100 can give an upgrade reminder by displaying a pop-up window or a notification message. Regarding how the normal system gives an upgrade reminder, reference can be specifically made to the description in step S503 above, and details will not be elaborated here.

[0164] S1004. The normal system of the electronic device 100 receives the operation of the user selecting to upgrade.

[0165] Optionally, the normal system of the electronic device 100 can receive the operation of the user selecting to upgrade.

[0166] In a possible implementation, the user can select to upgrade immediately or after a preset time interval based on the pop-up window or the notification message, or the user can also specify the upgrade time based on the pop-up window or the notification message. Here, reference can be made to the description in step S503 above, and details will not be elaborated here.

[0167] S1005. The normal system of the electronic device 100 releases the upgrade package to the EFI directory.

[0168] Exemplarily, when the user selects to upgrade immediately, the normal system of the electronic device 100 can, in response to this user operation, immediately release the upgrade package of the target firmware to the EFI directory. The EFI directory can be in the disk partition of the electronic device 100 for system startup. For example, when the user selects to upgrade after 2 hours, the normal system of the electronic device 100 can, in response to this user operation, release the upgrade package of the target firmware to the EFI directory after 2 hours.

[0169] In a possible implementation, this step S1005 is an optional step.

[0170] S1006. The normal system of the electronic device 100 instructs the UEFI layer to restart the electronic device 100.

[0171] The normal system of the electronic device 100 instructs the UEFI layer that the electronic device 100 starts to restart.

[0172] S1007. The UEFI layer of the electronic device 100 checks the upgrade package and starts the firmware upgrade.

[0173] The UEFI layer of the electronic device 100 can check the upgrade package. When the upgrade package is complete and legal, it can start the firmware upgrade. For the specific method of how the electronic device 100 checks the upgrade package and upgrades the firmware, reference can be made to Figure 11 the description in it, which will not be elaborated here.

[0174] S1008. The UEFI layer of the electronic device 100 upgrades the BIOS.

[0175] Optionally, the UEFI layer of the electronic device 100 can also upgrade the BIOS.

[0176] S1009. The UEFI layer of the electronic device 100 switches the A / B partition.

[0177] After the firmware upgrade is successful, the UEFI layer of the electronic device 100 can also switch the A and B partitions. For the specific method of how to switch the A and B partitions, reference can be made to Figure 12 the description in it, which will not be elaborated here.

[0178] Figure 11 shows a specific flowchart of the UEFI layer of the electronic device 100 performing firmware upgrade. As Figure 11 shown, the specific steps for the UEFI layer of the electronic device 100 to perform firmware upgrade can include the following:

[0179] S1101. Verify the upgrade package of the target firmware.

[0180] When the electronic device 100 starts the firmware upgrade, it can first perform firmware verification, that is, verify whether the upgrade package of the target firmware is complete and legal. Specifically, in one possible implementation, Figure 8B when the firmware upgrade module 804 shown in

[0181] starts the upgrade, it invokes the signature verification module 203 to verify the upgrade package of the target firmware. Exemplarily, in one possible implementation, the developer of the firmware upgrade package can sign the upgrade package with a private key. Then, the upgrade package downloaded by the electronic device 100 has the data and signature of the upgrade package itself. The signature verification module 803 can use the public key for signature authentication. If the authentication passes, the signature verification module 803 determines that the upgrade package is complete and legal. If the authentication fails, the signature verification module 803 can determine that the upgrade package is incomplete. It can be understood that different encryption methods of the upgrade package will result in relatively different verification methods by the signature verification module 803. The embodiments of the present application do not limit the encryption method and verification method of the upgrade package of the target firmware.

[0182] When the upgrade package is complete and legal, the electronic device 100 may perform the following steps S1102 - S1111. When the upgrade package is incomplete, the electronic device 100 may end the upgrade and no longer perform the following steps S1102 - S1111.

[0183] In a possible implementation, when starting the upgrade, the firmware upgrade module 804 may first call the file reading and writing module 801 to read the upgrade package of the target firmware. Then, the firmware upgrade module 804 may instruct the file reading and writing module 801 to send the upgrade package to the signature verification module 803. Next, the firmware upgrade module 804 may instruct the signature verification module 803 to verify the upgrade package.

[0184] S1102. Read the version number of the upgrade package of the target firmware.

[0185] The electronic device 100 may read the version number in the upgrade package of the target firmware. Exemplarily, in a possible implementation, after determining that the upgrade package of the target firmware is complete and legal, the firmware upgrade module 804 may instruct the file reading and writing module 801 to read the version number of the upgrade package. Specifically, the file reading and writing module 801 may invoke the EFI adaptation layer, and then read the version number of the upgrade package from the disk space storing the upgrade package through the block device driver.

[0186] After downloading the upgrade package, the electronic device 100 will read and record the version number of the upgrade package. Reading the version number of the upgrade package again during the upgrade can prevent the version number of the previously recorded upgrade package from being tampered with during the restart process of the electronic device 100.

[0187] S1103. Determine whether to start from Area A; if so, perform step S1104a; if not, perform step S1104b.

[0188] When there are Area A and Area B in the chip firmware partition of the electronic device 100, the electronic device 100 may determine whether to start from Area A or Area B. Exemplarily, the firmware upgrade module 804 may determine whether to start from Area A or Area B. The firmware upgrade module 804 may obtain whether the electronic device 100 started from Area A or Area B during the previous startup. If the electronic device 100 started from Area A during the previous startup, then the firmware upgrade module 804 may determine that it will start from Area B during this startup. If the electronic device 100 started from Area B during the previous startup, then the firmware upgrade module 804 may determine that it will start from Area A during this startup. If starting from Area A this time, then the electronic device 100 may write the upgrade package of the target firmware in Area A. If starting from Area B this time, then the electronic device 100 may write the upgrade package of the target firmware in Area B. It can be understood that the installation packages of the target firmware are stored in both Area A and Area B.

[0189] When the firmware upgrade module 804 determines that the device is booted from Area A, the electronic device 100 may execute the following step S1104a. When the firmware upgrade module 804 determines that the device is not booted from Area A, i.e., it is booted from Area B, the electronic device 100 may execute the following step S1104b.

[0190] S1104a. Obtain the version number of the installation package of the target firmware in Area A.

[0191] When it is determined that the device is booted from Area A, the firmware upgrade module 804 may instruct the file reading and writing module 801 to read the version number of the installation package of the target firmware in Area A. Specifically, the file reading and writing module 801 may invoke the EFI adaptation layer and then read the version number of the installation package of the target firmware in Area A through the block device driver.

[0192] S1104b. Obtain the version number of the installation package of the target firmware in Area B.

[0193] When it is determined that the device is booted from Area B, the firmware upgrade module 804 may instruct the file reading and writing module 801 to read the version number of the installation package of the target firmware in Area B. Specifically, the file reading and writing module 801 may invoke the EFI adaptation layer and then read the version number of the installation package of the target firmware in Area B through the block device driver.

[0194] S1105. Determine whether an upgrade is required; if yes, execute step S1106; if no, execute step S1112.

[0195] The firmware upgrade module 804 may determine whether to upgrade based on the version number of the installation package of the target firmware read by the file reading and writing module 801. Generally, the version number of the target firmware in the partition where the electronic device 100 is currently booted is the highest among the version numbers of the two partitions of the electronic device 100. Therefore, the electronic device 100 may compare the version number of the target firmware in the booted partition with the version number of the upgrade package. When the version number of the installation package of the target firmware in the booted partition is lower than the version number of the target firmware upgrade package, the firmware upgrade module 804 may determine that an upgrade is required. When the version number of the installation package of the target firmware in the booted partition is higher than the version number of the target firmware upgrade package, or when the version number of the installation package of the target firmware is the same as the version number of the target firmware upgrade package, the firmware upgrade module 804 may determine that an upgrade is not required. For example, if the device is currently booted from Area A, then the electronic device 100 may read the version number of the installation package of the target firmware in Area A, and then compare the version number of the installation package of the target firmware in Area A with the version number of the upgrade package.

[0196] When the firmware upgrade module 804 determines that the target firmware needs to be upgraded, the electronic device 100 may execute the following step S1106. When the firmware upgrade module 804 determines that the target firmware does not need to be upgraded, the electronic device 100 may execute the following step S1112.

[0197] S1106. Upgrade the target firmware.

[0198] The firmware upgrade module 804 may upgrade the target firmware. When upgrading the firmware, the firmware upgrade module 804 will upgrade the firmware in the non-boot partition. That is, when the B area boots, the firmware upgrade module 804 may determine to upgrade the target firmware in the A area. The firmware upgrade module 804 may instruct the disk writing module 802 to write the upgrade package of the target firmware into the A area. When the A area boots, the firmware upgrade module 804 may determine to upgrade the target firmware in the B area. The firmware upgrade module 804 may instruct the disk writing module 802 to write the upgrade package of the target firmware into the B area.

[0199] Specifically, when it is determined to upgrade the target firmware in the A area, the disk writing module 802 may invoke the EFI adaptation layer, and then write the upgrade package of the target firmware into the A area through the block device driver. Exemplarily, in a possible implementation manner, when the disk writing module 802 writes the upgrade package of the target firmware into the A area, it may overwrite the installation package of the target firmware in the A area. Or, the upgrade package may be stored in another storage space (or referred to as a partition) in the A area.

[0200] Similarly, when it is determined to upgrade the target firmware in the B area, the disk writing module 802 may invoke the EFI adaptation layer, and then write the upgrade package of the target firmware into the B area through the block device driver. Exemplarily, in a possible implementation manner, when the disk writing module 802 writes the upgrade package of the target firmware into the B area, it may overwrite the installation package of the target firmware in the B area. Or, the upgrade package may be stored in another storage space (or referred to as a partition) in the B area.

[0201] S1107. Determine whether the upgrade is successful; if so, execute step S1108; if not, execute step S1112.

[0202] The electronic device 100 may determine whether the upgrade is successful through the firmware upgrade module 804. If the upgrade is successful, the electronic device 100 may execute step S1108; if the upgrade fails, the electronic device 100 may execute step S1112.

[0203] In a possible implementation, after the write disk module 802 successfully writes the upgrade package of the target firmware in area A or area B, it can send a read-back result to the firmware upgrade module 804. This read-back result is used to indicate whether the upgrade is successful or failed. The firmware upgrade module 804 can determine whether the upgrade is successful or failed based on this read-back result.

[0204] S1108. Determine whether it is area A that is booted; if so, execute step S1109a; if not, execute step S1109b.

[0205] The electronic device 100 can determine whether the target firmware in area A or area B has been upgraded based on whether it is area A that is booted during the restart process of the electronic device 100 this time. If area A is booted during this restart, then the electronic device 100 can determine that the target firmware in area B has been upgraded. Then the electronic device 100 can execute the following steps S1109a and S1110a. If area B is booted during this restart, then the electronic device 100 can determine that the target firmware in area A has been upgraded, and then the electronic device 100 can execute the following steps S1109b and S1110b.

[0206] It can be understood that the above-mentioned booting of area A means booting multiple firmwares in area A. Booting area B means booting multiple firmwares in area B.

[0207] S1109a. Update the version number of the target firmware in area B.

[0208] S1110a. Switch to boot from area B.

[0209] In the case where the target firmware in area B is upgraded this time and the write disk module 802 successfully writes the upgrade package of the target firmware to area B, the firmware upgrade module 804 can instruct the write disk module 802 to update the version number of the target firmware in area B. The write disk module 802 can invoke the EFI adaptation layer and then write the new version number of the target firmware (i.e., the version number of the upgrade package) to area B through the block device driver.

[0210] After the version number of the target firmware in area B is updated, the firmware upgrade module 804 can instruct the partition switching module 805 to switch partitions, that is, switch to boot from area B.

[0211] S1109b. Update the version number of the target firmware in area A.

[0212] S1110b. Switch to boot from area A.

[0213] During this upgrade, the target firmware in Area A is being upgraded. When the write disk module 802 successfully writes the upgrade package of the target firmware to Area A, the firmware upgrade module 804 can instruct the write disk module 802 to update the version number of the target firmware in Area A. The write disk module 802 can invoke the EFI adaptation layer and then write the new version number of the target firmware (i.e., the version number of the upgrade package) to Area A through the block device driver.

[0214] After the version number of the target firmware in Area A is updated, the firmware upgrade module 804 can instruct the partition switching module 805 to switch partitions, that is, switch to boot from Area A.

[0215] S1111. Refresh the firmware version number.

[0216] The electronic device 100 can update the version number of the updated target firmware to the BIOS according to the system management BIOS (SMBIOS) standard.

[0217] S1112. End the upgrade.

[0218] The electronic device 100 can end the upgrade.

[0219] Take Figure 8A the firmware included in the CPU chip shown above as an example. When there is a chip firmware partition in the disk space of the electronic device 100 and the chip firmware partition includes Area A and Area B, the specific steps for the electronic device 100 to start the firmware in the chip firmware partition and upgrade the firmware in the chip firmware partition can be referred to Figure 12 .

[0220] Figure 12 Exemplarily shows a schematic diagram of the startup and upgrade switching logic of the firmware in Area A and Area B. As Figure 12 shown, the process of starting and upgrading the firmware in Area A and Area B can include the following steps:

[0221] S1201a. The electronic device 100 starts the firmware.

[0222] S1202a. Determine whether to start from Area A; if so, start the firmware in Area A according to steps S1203a - S1207a; if not, start the firmware in Area B according to steps S1203b - S1207b.

[0223] When there are partitions A and B in the chip firmware partition of the electronic device 100, the electronic device 100 can determine whether to start from partition A or partition B. Exemplarily, the firmware upgrade module 804 can determine whether to start from partition A or partition B. The firmware upgrade module 804 can obtain whether the electronic device 100 started from partition A or partition B during the last startup. If the electronic device 100 started from partition A during the last startup, then the firmware upgrade module 804 can determine to start from partition B during this startup. If the electronic device 100 started from partition B during the last startup, then the firmware upgrade module 804 can determine to start from partition A during this startup. If it is partition A that starts this time, then the electronic device 100 can write the upgrade package of the target firmware in partition A. If it is partition B that starts this time, then the electronic device 100 can write the upgrade package of the target firmware in partition B. It can be understood that the installation packages of the target firmware are stored in both partition A and partition B.

[0224] When the firmware upgrade module 804 determines that it is partition A that starts, the electronic device 100 can execute the following steps S1203a - step S1207a. When the firmware upgrade module 804 determines that it is partition B that starts, the electronic device 100 can execute the following S1203b - step S1207b.

[0225] S1201b. The electronic device 100 upgrades the firmware.

[0226] S1202b. Determine whether it is partition A that starts; if not, then upgrade the firmware in partition A according to steps S1203a - step S1207a; if so, then upgrade the firmware in partition B according to steps S1203b - step S1207b.

[0227] When the electronic device 100 upgrades the firmware, the electronic device 100 can determine whether it is partition A or partition B that starts currently. If it is partition A that starts, then the electronic device 100 can upgrade the firmware in partition B according to steps S1203a - step S1207a. If it is partition B that starts, then the electronic device 100 upgrades the firmware in partition A according to steps S1203b - step S1207b.

[0228] Steps S1203a - step S1207a: Start or upgrade the firmware in partition A.

[0229] S1203a. Xloader.

[0230] S1204a. ATF - BL1 / 2.

[0231] S1205a. ATF - BL31.

[0232] S1206a. TEEOS.

[0233] S1207a, HEE.

[0234] When the electronic device 100 determines that Area A starts, the electronic device 100 starts firmware such as Xloader, ATF - BL1 / 2, ATF - BL31, TEEOS, and HEE in sequence according to the above steps S1203a - step S1207a.

[0235] When the electronic device 100 is performing firmware upgrade, when any one of the firmware such as Xloader, ATF - BL1 / 2, ATF - BL31, TEEOS, and HEE in Area A needs to be upgraded, the write disk module 802 can write the upgrade package of this firmware in Area A. For example, if Xloader needs to be upgraded, the write disk module 802 can write the upgrade package of this Xloader in Area A. If all of the firmware such as Xloader, ATF - BL1 / 2, ATF - BL31, TEEOS, and HEE need to be upgraded, the write disk module 802 can write the upgrade packages of Xloader, ATF - BL1 / 2, ATF - BL31, TEEOS, and HEE in Area A in sequence.

[0236] S1208, Start UEFI.

[0237] S1209, Start the kernel.

[0238] When the electronic device 100 starts, after the electronic device 100 starts the firmware, it can start the UEFI interface and start the kernel.

[0239] Steps S1203b - step S1207b: Start or upgrade the firmware in Area B.

[0240] S1203b, Xloader.

[0241] S1204b, ATF - BL1 / 2.

[0242] S1205b, ATF - BL31.

[0243] S1206b, TEEOS.

[0244] S1207b, HEE.

[0245] When the electronic device 100 determines that Area B starts, the electronic device 100 starts firmware such as Xloader, ATF - BL1 / 2, ATF - BL31, TEEOS, and HEE in sequence according to the above steps S1203b - step S1207b.

[0246] When the electronic device 100 is performing firmware upgrade, when any one of the firmware such as Xloader, ATF-BL1 / 2, ATF-BL31, TEEOS, and HEE in area B needs to be upgraded, the disk writing module 802 can write the upgrade package of the firmware in area B. For example, if Xloader needs to be upgraded, the disk writing module 802 can write the upgrade package of the Xloader in area B. If all of the firmware such as Xloader, ATF-BL1 / 2, ATF-BL31, TEEOS, and HEE need to be upgraded, the disk writing module 802 can sequentially write the upgrade packages of the firmware such as Xloader, ATF-BL1 / 2, ATF-BL31, TEEOS, and HEE in area B.

[0247] In the UEFI stage, the electronic device 100 provides the hardware information and the original design manufacturer (OEM) information to the operating system. After the operating system is started, the electronic device 100 displays the trademark (logo) information in the OEM information. When the electronic device 100 upgrades the firmware through the small system, the electronic device 100 will first display the logo information and then display the progress bar of the firmware upgrade (such as Figure 6 the upgrade progress bar 602 shown in). In the firmware upgrade method provided by the embodiments of the present application, the electronic device 100 performs firmware upgrade in the UEFI stage. Therefore, the electronic device 100 will first display the progress bar of the firmware upgrade, and after the firmware upgrade is completed, the electronic device 100 can display the logo information.

[0248] Through the firmware upgrade method provided by the embodiments of the present application, the electronic device 100 does not need to pre-set an additional small system, which can increase the actual available disk space of the user by approximately 512M to 1G. The electronic device 100 can implement firmware upgrade through the UEFI layer. When a task to be upgraded is detected, the UEFI layer in the electronic device 100 can complete the corresponding upgrade operation without starting an additional small system, and the process is more concise. In the firmware upgrade method provided by the embodiments of the present application, the upgrade module loaded in the UEFI stage is directly in the running environment of the kernel state. Through the adaptation operation of the EFU interface adaptation layer, the upgrade module has the ability to read and write the firmware partition in the UEFI stage, so as to complete the firmware upgrade based on the kernel state. The entire firmware upgrade process is completed in the kernel state, which is more secure and reliable. Thus, the electronic device 100 can perform firmware upgrade more safely and efficiently.

[0249] Next, an exemplary electronic device 100 provided by the embodiments of the present application will be introduced.

[0250] Figure 13It is a schematic structural diagram of the electronic device 100 provided by an embodiment of the present application.

[0251] Hereinafter, the embodiments will be specifically described by taking the electronic device 100 as an example. It should be understood that the electronic device 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations. The various components shown in the figure may be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0252] The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna, a wireless communication module 150, an audio module 160, keys 170, a display screen 180, etc.

[0253] It can be understood that the structure schematically shown in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than those shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0254] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or may be integrated in one or more processors.

[0255] Among them, the controller may be the nerve center and command center of the electronic device 100. The controller may generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching instructions and executing instructions.

[0256] A memory can also be set in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can save the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0257] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0258] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL).

[0259] The I2S interface can be used for audio communication. In some embodiments, the processor 110 may include multiple groups of I2S buses. The processor 110 can be coupled to the audio module 160 through the I2S bus to achieve communication between the processor 110 and the audio module 160. In some embodiments, the audio module 160 can transmit an audio signal to the wireless communication module 150 through the I2S interface to achieve the function of answering a call through a Bluetooth headset.

[0260] The PCM interface can also be used for audio communication to sample, quantize, and encode analog signals. In some embodiments, the audio module 160 and the wireless communication module 150 can be coupled through the PCM bus interface. In some embodiments, the audio module 160 can also transmit audio signals to the wireless communication module 150 through the PCM interface to implement the function of answering calls through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0261] The UART interface is a general-purpose serial data bus for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is typically used to connect the processor 110 and the wireless communication module 150. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 150 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 160 can transmit audio signals to the wireless communication module 150 through the UART interface to implement the function of playing music through a Bluetooth headset.

[0262] The MIPI interface can be used to connect the processor 110 and the display screen 180. The MIPI interface includes a display serial interface (DSI), etc. In some embodiments, the processor 110 and the display screen 180 communicate through the DSI interface to implement the display function of the electronic device 100.

[0263] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the display screen 180, the wireless communication module 150, the audio module 160, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0264] The USB interface 130 is an interface that complies with the USB standard specification, and can specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used for data transmission between the electronic device 100 and peripheral devices. It can also be used to connect a headset to play audio. This interface can also be used to connect other electronic devices, such as AR devices, etc.

[0265] In some embodiments, the USB interface 130 can also be used to connect devices such as a mouse and a keyboard.

[0266] It can be understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are only illustrative descriptions and do not constitute a structural limitation on the electronic device 100. In some other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0267] The charging management module 140 is configured to receive a charging input from a charger. Wherein, the charger may be a wireless charger or a wired charger.

[0268] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives inputs from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 180, the wireless communication module 150, etc.

[0269] The wireless communication function of the electronic device 100 can be implemented by an antenna, a wireless communication module 150, a modulation and demodulation processor, a baseband processor, etc.

[0270] The antenna is used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example: the antenna can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0271] The wireless communication module 150 can provide solutions for wireless communications applied to the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. The wireless communication module 150 can be one or more devices integrating at least one communication processing module. The wireless communication module 150 receives electromagnetic waves via the antenna, performs frequency modulation and filtering processing on the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 150 can also receive signals to be sent from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna for radiation.

[0272] In some embodiments, the antenna of the electronic device 100 is coupled to the wireless communication module 150, enabling the electronic device 100 to communicate with a network and other devices via wireless communication technologies. The wireless communication technologies may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Synchronous Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS may include Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), BeiDou Navigation Satellite System (BDS), Quasi-Zenith Satellite System (QZSS), and / or Satellite Based Augmentation Systems (SBAS).

[0273] The electronic device 100 implements a display function through a GPU, a display screen 180, and an application processor, etc. The GPU is a microprocessor for image processing, connected to the display screen 180 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.

[0274] The display screen 180 is used to display images, videos, etc. The display screen 180 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 180, where N is a positive integer greater than 1.

[0275] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement the data storage function. For example, files such as music and videos are saved in the external memory card.

[0276] The internal memory 121 can be used to store computer-executable program code, and the executable program code includes instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. Among them, the program storage area can store an operating system, applications required for at least one function (such as face recognition function, fingerprint recognition function, mobile payment function, etc.). The data storage area can store data created during the use of the electronic device 100 (such as face information template data, fingerprint information template, etc.). In addition, the internal memory 121 can include high-speed random access memory, and can also include non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0277] The electronic device 100 can implement audio functions through the audio module 160 and the application processor, etc. For example, music playback, recording, etc.

[0278] The audio module 160 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal. The audio module 160 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 160 can be disposed in the processor 110, or some functional modules of the audio module 160 can be disposed in the processor 110.

[0279] Optionally, in a possible implementation, the electronic device 100 may further include a speaker, a receiver, a microphone, and a headphone jack.

[0280] Among them, the speaker, also known as the "loudspeaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or a hands-free call through the speaker.

[0281] The receiver, also known as the "earpiece", is used to convert an audio electrical signal into a sound signal. When the electronic device 100 answers a call or a voice message, the voice can be listened to by holding the receiver close to the ear.

[0282] The microphone, also known as the "microphone" or "transmitter", is used to convert a sound signal into an electrical signal. When making a voice call or sending a voice message, the user can speak by bringing the mouth close to the microphone to input the sound signal into the microphone. The electronic device 100 can be provided with at least one microphone. In some other embodiments, the electronic device 100 can be provided with two microphones, which can not only collect sound signals but also implement a noise reduction function. In some other embodiments, the electronic device 100 can also be provided with three, four or more microphones to implement functions such as collecting sound signals, noise reduction, identifying the sound source, and implementing a directional recording function.

[0283] The headphone jack is used to connect a wired headphone. The headphone jack can be a USB interface 130, or a 3.5 mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0284] The keys 170 include a power-on key, volume keys, etc. The keys 170 can be mechanical keys or touch keys. The electronic device 100 can receive key inputs to generate key signal inputs related to the user settings and function controls of the electronic device 100.

[0285] In the embodiments of the present application, the above may exist in the processor 110 Figure 8AThe on-chip ROM shown in [figure reference] and multiple firmware (such as firmware like Xloader, ATF-BL1 / 2, ATF-BL31, TEEOS, HEE, etc.). The internal memory 121 may include a chip firmware partition. The chip firmware partition may store the installation packages and version numbers of firmware such as Xloader, ATF-BL1 / 2, ATF-BL31, TEEOS, HEE, etc.

[0286] As described above, the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

[0287] As used in the above embodiments, depending on the context, the term "when..." can be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if detecting (the stated condition or event)" can be interpreted to mean "if determining..." or "in response to determining..." or "when detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)".

[0288] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that the computer can access or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state drive), etc.

[0289] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by relevant hardware instructed by a computer program. This program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The foregoing storage medium includes various media that can store program codes, such as ROM or random access memory (RAM), magnetic disks, or optical discs.

Claims

1. A firmware upgrade method, characterized in that, The method is applied to an electronic device, which includes a system layer, a kernel layer, and a firmware layer. The system layer includes an operating system. The kernel layer includes an upgrade module, an Extensible Firmware Interface (EFI) adaptation layer, and a block device driver. The firmware layer includes a chip firmware partition. The method includes: The operating system obtains an upgrade package of a target firmware; The operating system provides the upgrade package to the upgrade module; The upgrade module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the chip firmware partition.

2. The method according to claim 1, wherein Before the upgrade module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the chip firmware partition, the method further includes: The upgrade module obtains the version number of the upgrade package and the version number of the installation number of the target firmware; The upgrade module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the chip firmware partition, which specifically includes: If the version number of the upgrade package is higher than the version number of the installation package of the target firmware, the upgrade module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the chip firmware partition.

3. The method according to claim 2, wherein The upgrade module includes a file read / write module and a firmware upgrade module. The upgrade module obtains the version number of the upgrade package and the version number of the installation number of the target firmware, which specifically includes: The firmware upgrade module sends a first instruction to the file read / write module. The first instruction is used to instruct the file read / write module to obtain the version number of the upgrade package and the version number of the installation package of the target firmware; In response to the first instruction, the file read / write module calls the block device driver through the EFI adaptation layer to read the version number of the upgrade package and read the version number of the installation package of the target firmware in the chip firmware partition; The file read / write module sends the version number of the upgrade package and the version number of the installation package of the target firmware to the firmware upgrade module.

4. The method according to claim 3, wherein The upgrade module includes a disk write module. If the version number of the upgrade package is higher than the version number of the installation package of the target firmware, the upgrade module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the chip firmware partition, which specifically includes: After the firmware upgrade module determines that the version number of the upgrade package is higher than the version number of the installation package of the target firmware, it sends a second instruction to the disk write module. The second instruction is used to instruct the disk write module to write the upgrade package into the chip firmware partition; In response to the second instruction, the disk write module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the chip firmware partition.

5. The method according to claim 4, wherein Before the upgrade module obtains the version number of the upgrade package and the version number of the installation number of the target firmware, the method further includes: The upgrade module verifies the upgrade package to determine that the upgrade package is a complete upgrade package.

6. The method according to claim 5, characterized in that The upgrade module includes a signature verification module. The upgrade module verifies the upgrade package to determine the integrity of the upgrade package, specifically including: The firmware upgrade module instructs the file reading and writing module to send the read upgrade package to the signature verification module, and instructs the signature verification module to verify the upgrade package; The signature verification module verifies the upgrade package to determine that the upgrade package is a complete upgrade package.

7. The method according to claim 6, wherein The chip firmware partition includes a main area and a backup area, and the target firmware exists in the main area and the backup area; The disk writing module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the chip firmware partition, specifically including: When the upgrade module determines that the main area starts, the disk writing module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the backup area; When the upgrade module determines that the backup area starts, the disk writing module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the main area.

8. The method according to claim 7, characterized in that, After the disk writing module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the backup area, the method further includes: The disk writing module calls the block device driver through the EFI adaptation layer to update the version number of the target firmware in the backup area; After the disk writing module calls the block device driver through the EFI adaptation layer to write the upgrade package of the target firmware into the main area, the method further includes: The disk writing module calls the block device driver through the EFI adaptation layer to update the version number of the target firmware in the main area.

9. The method according to any one of claims 1-8, characterized in that, The target firmware includes one or more of the loading firmware Xloader, the ARM trusted firmware - boot firmware ATF - BL1 / 2, the ARM trusted firmware - secure mode running software ATF - BL 3 - 1, the hypervisor execution environment HEE, and the trusted execution environment TEEOS.

10. The method according to claim 9, characterized in that, The small system is not included in the system layer, and the electronic device disk partition does not include a partition for storing the small system; the small system is used to call the file system interface through the system library function to read the version number of the installation package of the target firmware in the chip firmware partition and write the upgrade package of the target firmware into the chip firmware partition.

11. An electronic device, characterized in that, Including a display screen, one or more processors, and one or more memories; wherein, the display screen, the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, and the computer program code includes computer instructions. When the one or more processors execute the computer instructions, the method according to any one of claims 1 - 10 is performed.

12. A chip system, which is applied to an electronic device, and the chip system includes one or more processors, characterized in that, The processor is used to call computer instructions to cause the execution of the method according to any one of claims 1 - 10.

13. A computer-readable storage medium, comprising instructions, characterized in that, When the instruction runs on an electronic device, it causes the execution of the method according to any one of claims 1-10.

Citation Information

Cited By

  • Universal OTA architecture and OTA upgrading method and device

    CN121957644A

  • Uefi boot based drone payload adaptive fitting and protection method

    CN122691662A