This application claims the priority benefit of Taiwan application serial no. 112135543, filed on Sep. 18, 2023. The entirety of the above-mentioned patent application is hereby incorporated by reference herein and made a part of this specification.
This disclosure relates to an electronic device and a method, and in particular to an electronic device and a method for updating firmware.
Existing firmware updating file in hardware platform management (HPM) format may include a byte that indicates the firmware component to which the firmware updating file applies, where the byte may be used to indicate up to eight different firmware components. However, the existing firmware updating file format is not suitable for situations where the number of firmware components exceeds eight. Normal firmware updating file format interpreters (e.g., ipmitool) do not accurately interpret firmware updating files to determine the firmware components to which the firmware updating file applies. In addition, different developers design different ways of updating firmware components. In cases where the format of the firmware updating file is not fixed, the firmware updating file may not be compatible with the instruction set used to update the firmware component.
The disclosure provides an electronic device and a method for updating a firmware, applicable when a quantity of firmware components is large.
The electronic device of the disclosure for updating a firmware including a processor, a storage medium, and a communication interface. The communication interface receives a firmware updating file, in which the firmware updating file includes boot data. The storage media stores multiple modules. The processor is coupled to the storage medium and the communication interface, and is adapted to access and execute multiple modules. The modules include a first application programming interface and a second application programming interface. The first application programming interface is adapted to detect a first field of the firmware updating file to determine whether the firmware updating file supports a first format. In response to the firmware updating file supporting the first format, the second application programming interface detects a second field to obtain an identifier. After obtaining the identifier, the second application interface transmits the boot data to a firmware component corresponding to the identifier through the communication interface to update the firmware component.
In an embodiment of the disclosure, the firmware updating file further includes a first header, and the first header includes the first field and the second field.
In an embodiment of the disclosure, in response to the firmware updating file not supporting the first format, the first application programming interface obtains the identifier from the first field. After obtaining the identifier, the first application programming interface transmits the boot data to the firmware component corresponding to the identifier through the communication interface to update the firmware component.
In an embodiment of the disclosure, the firmware updating file further includes a second header, and the second header includes the first field.
In an embodiment of the disclosure, a format of the firmware updating file includes a hardware platform management (HPM) format, and the second header corresponds to an action header in the hardware platform management format
In an embodiment of the disclosure, the firmware updating file further includes a third header. The first application programming interface detects a third field in the third header to determine whether the firmware updating file supports a second format. In response to the firmware updating file supporting the second format, the first application programming interface detects the first field to determine whether the firmware updating file supports the first format.
In an embodiment of the disclosure, a format of the firmware updating file includes a hardware platform management (HPM) format, and the third header corresponds to a hardware platform management header in the hardware platform management format.
In an embodiment of the disclosure, a format of the firmware updating file includes a hardware platform management (HPM) format, the first field corresponds to a component field in the hardware platform management format, the first field includes a reserved bit, and the first application programming interface determines whether the firmware updating file supports the first format according to the reserved bit.
In an embodiment of the disclosure, the second application obtains the identifier according to a byte in the second field.
In an embodiment of the disclosure, the communication interface supports at least one of a serial peripheral interface and an integrated bus circuit.
The method for updating a firmware of the disclosure includes the following. A firmware updating file is received through a communication interface, in which the firmware updating file includes boot data. A first field of the firmware updating file is detected to determine whether the firmware updating file supports a first format. In response to the firmware updating file supporting the first format, a second field is detected to obtain an identifier. The boot data is transmitted to a firmware component corresponding to the identifier through the communication interface to update the firmware component.
In an embodiment of the disclosure, the method for updating a firmware further includes the following. In response to the firmware updating file not supporting the first format, the identifier is obtained from the first field.
Based on the above, the electronic device of the disclosure may determine whether the firmware updating file supports the first format according to the first field of the firmware updating file, and detects the second field and obtains the identifier according to the second field when the firmware updating file supports the first format. In this way, more than 8 types of firmware components may be indicated to select the firmware component to which the firmware updating file applies, and thus the firmware component is updated according to the firmware updating file.
To make the aforementioned more comprehensible, several embodiments accompanied with drawings are described in detail as follows.
The accompanying drawings are included to provide a further understanding of the disclosure, and are incorporated in and constitute a part of this specification. The drawings illustrate example embodiments of the disclosure and, together with the description, serve to explain the principles of the disclosure.
The processor 110 is, for example, a central processing unit (CPU), or other programmable general-purpose or special-purpose micro control unit (MCU), microprocessor, digital signal processor (DSP), programmable controller, application specific integrated circuit (ASIC), graphics processing unit (GPU), image signal processor (ISP)), image processing unit (IPU), arithmetic logic unit (ALU), complex programmable logic device (CPLD), field programmable gate array (FPGA), or other similar components or a combination of the above components. The processor 110 may be coupled to the storage medium 120 and the communication interface 130, and access and execute multiple modules and various application programs stored in the storage medium 120.
The storage medium 120 is, for example, any type of static or dynamic random access memory (RAM), read-only memory (ROM), flash memory, hard disk drive (HDD), solid state drive (SSD), or similar components or a combination of the above components, configured to store multiple modules or various application programs that may be executed by the processor 110. In this embodiment, the storage medium 120 may store multiple modules including a hardware platform management (HPM) application programming interface (API) 121 and a dynamic detect image (DDI) application programming interface 122, the functions of which will be described later.
The communication interface 130 transmits or receives signals in a wireless or wired manner. The communication interface 130 may support communication protocols such as serial peripheral interface (SPI) or inter-integrated circuit (I2C). The electronic device 100 may communicate with an external device (e.g., a read-only memory configured to store firmware components in a hardware apparatus) through the communication interface 130.
The electronic device 100 may be configured to parse a firmware updating file and determine which firmware component the firmware updating file is applicable to.
In step S302, the HPM API 121 (or first API) detects a signature field (or third field) in the HPM header (or third header) in the firmware updating data to determine whether the firmware updating file supports the HPM format (or second format). If the signature field in the HPM header indicates that the firmware updating file supports the HPM format, proceed to step S303. If the signature field in the HPM header indicates that the firmware updating file does not support the HPM format, or the firmware updating data does not include the HPM header, the firmware update failed. The processor 110 may stop the firmware update process.
In step S303, the HPM API 121 may detect the component field (or first field) in the firmware updating data to determine whether the firmware updating file supports the DDI format (or first format). If the component field indicates that the firmware updating file supports the DDI format, which means that the firmware updating file includes the DDI header (or first header) as shown in
In this embodiment, if the firmware updating file is in a format including the DDI header (
In step S304, the DDI API 122 (or second API) may detect the board identifier (board ID) field (or second field) in the firmware updating data in the DDI header to obtain an identifier (i.e., obtain the identifier according to information in the board identifier field). Specifically, the board identifier field may include one (or more) bytes indicating one of multiple identifiers. For example, a byte may be used to indicate one of 128 identifiers. The DDI API 122 may select the corresponding identifier among the 128 identifiers according to the instruction of the byte in the board identifier field. The identifier is used to indicate the firmware component to which the firmware updating file applies. Table 1 shows examples of identifiers in the board identifier field.
In step S305, the DDI API 122 may determine whether the firmware updating file is damaged. If the firmware updating file is damaged, the process will be stopped. If the firmware updating file is not damaged, proceed to step S306. Specifically, the DDI API 122 may calculate a hash value corresponding to the firmware updating data in the DDI header, and determine whether the hash value matches a hash support field or a hash length field in the firmware updating data. If the hash value matches the hash support field or the hash length field, the DDI API 122 may determine that the firmware updating file is not damaged. If the hash value does not match the hash support field or the hash length field, the DDI API 122 may determine that the firmware updating file is damaged.
In step S306, the DDI API 122 may load boot data corresponding to the identifier from the firmware updating file according to the identifier indicated by the board identifier field in the DDI header.
In step S307, the HPM API 121 may detect the component field in the ACT header (or second header) to obtain the identifier (i.e., obtain the identifier according to the information in the component field). Specifically, the component field may include a byte indicating one of multiple identifiers. For example, a byte may be used to indicate one of seven identifiers. The HPM API 121 may select the corresponding identifier among the seven identifiers according to the instructions of the component field. The identifier is used to indicate the firmware component to which the firmware updating file applies. That is, in this embodiment, the identifier that the component field (first field) can indicate is less than the identifier that the board identifier field (second field) can indicate.
In step S308, the HPM API 121 may determine whether the firmware updating file is damaged. If the firmware updating file is damaged, the process will be stopped. If the firmware updating file is not damaged, proceed to step S309. Specifically, the HPM API 121 may calculate a hash value corresponding to the firmware updating data in the boot data (not shown in
In step S309, the HPM API 121 may load boot data corresponding to the identifier from the firmware updating file according to the identifier indicated by the component field in the ACT header.
In step S310, the HPM API 121 or the DDI API 122 transmits the boot data to the firmware component corresponding to the identifier through the communication interface 130 to update the firmware component. For example, the HPM API 121 or the DDI API 122 may transmit the boot data to the read-only memory configured to store the firmware component in the external device, thereby updating the firmware component in the read-only memory. Specifically, after completing step S306, the DDI API 122 may transmit the boot data to the firmware component corresponding to the identifier indicated by the DDI header through the communication interface 130 to update the firmware component. On the other hand, after completing step S309, the HPM API 121 may transmit the boot data to the firmware component corresponding to the identifier indicated by the HPM header through the communication interface 130 to update the firmware component.
In summary, the electronic device of the disclosure may determine whether the firmware updating file supports the HPM format, and then determine whether the firmware updating file is available. If the firmware updating file is available, the electronic device may further detect the reserved bit of the first field in the firmware updating file to determine whether the firmware updating file includes the DDI header. If the firmware updating file includes the DDI header, the electronic device may select one of more than 8 identifiers according to content of the board identifier field in the DDI header, and update the firmware component to which the firmware updating file applies according to the identifiers. On the other hand, if the firmware updating file does not include the DDI header, the electronic device may select one of up to eight identifiers according to content of the component field in the ACT header, and update the firmware component to which the firmware updating file applies according to the identifiers. Thus, the disclosure may not only cooperate with the firmware updating file of traditional HPM format to select the firmware component to which the firmware updating file applies to update from within 8 types of firmware components, but also cooperate with the firmware updating file including the DDI header to select the firmware component to which the firmware updating file applies to update from more than 8 types of firmware components.
It will be apparent to those skilled in the art that various modifications and variations can be made to the disclosed embodiments without departing from the scope or spirit of the disclosure. In view of the foregoing, it is intended that the disclosure covers modifications and variations provided that they fall within the scope of the following claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
112135543 | Sep 2023 | TW | national |