Firmware upgrading method, firmware upgrading device and computer readable storage medium
Patent Information
- Application Number
- CN202611097756.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-16
AI Technical Summary
[0003]目前采用mmc-utils开源工具对eMMC做现场固件升级操作仅支持一次性全量写入或单扇区循环写入这两种模式,无法同时兼顾效率和可靠性,无法满足实际需求
[0012]本申请实施例还公开了一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上所述固件升级方法的步骤。
Smart Images

Figure CN122924829A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a firmware upgrade method, a firmware upgrade device, and a computer-readable storage medium. Background Technology
[0002] An embedded MultiMediaCard (eMMC) is a device capable of storing code and managing data. An eMMC typically includes at least a MultiMediaCard (MMC) interface, flash memory, and a flash memory controller, featuring a high-speed data interface, backward and forward compatibility, and high storage density. When performing firmware upgrades on an eMMC, the open-source tool mmc-utils is usually used under a Linux system to perform a FieldFirmwareUpdate (FFU) operation.
[0003] Currently, using the mmc-utils open-source tool to perform on-site firmware upgrades on eMMC only supports two modes: one-time full write or single-sector cyclic write. This cannot simultaneously balance efficiency and reliability, and therefore cannot meet actual needs. Summary of the Invention
[0004] The purpose of this application is to provide a firmware upgrade method, firmware upgrade device, and computer-readable storage medium to improve the efficiency and reliability of eMMC when performing field firmware upgrades.
[0005] This application discloses a firmware upgrade method, which includes the following steps: Obtain information on the firmware upgrade package data size, maximum segment transfer size, and memory fanout size; The firmware upgrade data writing mode is determined based on the firmware upgrade package data size information, the maximum segment transmission size information, and the memory fanout area size information; and The firmware upgrade data is written to the memory using the firmware upgrade data writing mode to complete the firmware upgrade.
[0006] Optionally, the firmware upgrade data writing mode includes a full write mode. When the result of the firmware upgrade package data size information is less than or equal to the result of the maximum segment transmission size information, the full write mode is used to write all firmware upgrade package data into the memory at once to complete the firmware upgrade.
[0007] Optionally, the firmware upgrade data writing mode includes a segmented writing mode. When the displayed result of the firmware upgrade package data size information is greater than the displayed result of the maximum segment transmission size information, the segmented writing mode is used to write all firmware upgrade package data into the memory in segments to complete the firmware upgrade. The segmented writing mode divides the firmware upgrade package data into n upgrade files, where the storage size of each upgrade file is less than or equal to the displayed result of the maximum segment transmission size information, and the storage size of each upgrade file is an integer multiple of the displayed result of the memory fan-out area size information; where n is a natural number greater than 1.
[0008] Optionally, each of the upgrade files has the same storage size.
[0009] Optionally, at least two of the upgrade files may have different storage sizes. Optionally, the result of the maximum segment transmission size information is less than the storage size of the two upgrade files.
[0010] Optionally, the firmware upgrade method is applicable to field firmware upgrades using the mmc-utils open-source tool.
[0011] This application also discloses a firmware upgrade device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the firmware upgrade method described above.
[0012] This application also discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the firmware upgrade method described above.
[0013] The beneficial effects of this application embodiment are as follows: This application embodiment can flexibly select a suitable writing mode for firmware upgrade data according to the actual size of the firmware upgrade package, the maximum segmented transmission capability of the platform, and the size of the memory fan-out area. This avoids the problem of low efficiency in single-sector cyclic writing and also avoids the risk of unreliable data writing caused by the limitation of the maximum segmented transmission capability of the platform when writing a full amount at once. While ensuring the reliability of firmware upgrade, it effectively improves the upgrade efficiency and better meets the actual needs of on-site firmware upgrade of embedded storage devices. Attached Figure Description
[0014] The accompanying drawings, which form part of the specification, are used to provide a further understanding of the embodiments of this application and illustrate the implementation methods of this application, together with the textual description, to explain the principles of this application. Obviously, the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without creative effort. In the drawings: Figure 1 This is a flowchart of a firmware upgrade method provided in the first embodiment of this application; Figure 2 This is a schematic diagram of a firmware upgrade device provided in the second embodiment of this application; Figure 3 This is a schematic diagram of a computer-readable storage medium provided in the third embodiment of this application.
[0015] Among them, 10 is a firmware upgrade device; 20 is a memory; 21 is a computer program; 30 is a processor; and 40 is a computer-readable storage medium. Detailed Implementation
[0016] It should be understood that the terminology, specific structural and functional details used herein are merely for describing particular embodiments and are representative. However, this application may be implemented in many alternative forms and should not be construed as being limited to the embodiments set forth herein.
[0017] Furthermore, unless otherwise explicitly specified and limited, "connected" or "linked" should be interpreted broadly. For example, it can refer to a fixed connection, a detachable connection, or an integral connection; it can refer to a mechanical connection or an electrical connection; it can refer to a direct connection or an indirect connection through an intermediate medium, or a connection within two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0018] Currently, the FFU upgrade for the general open-source tool mmc-utils under Linux systems only supports two firmware writing modes and lacks adaptive capability. The two firmware writing modes are: ① Full one-time write, directly writing the complete firmware (e.g., 512KB), but many embedded platforms have max_segment_size transmission segmentation limitations (e.g., 64KB), and forcing a full write will trigger ioctl failure, causing the eMMC to enter an abnormal state, resulting in firmware upgrade failure or chip bricking; ② Single sector loop write, writing 512 bytes at a time, with strong compatibility but extremely low efficiency (512KB firmware requires 1024 writes), and frequent writes will accelerate eMMC wear.
[0019] To address the inherent limitation of using the mmc-utils tool to perform the FFU process on eMMC, which only supports one-time full write or single-sector cyclic write, this application provides a firmware upgrade method that can dynamically segment and adaptively upgrade, thereby improving the efficiency and reliability of eMMC during field firmware upgrades.
[0020] like Figure 1 As shown, a firmware upgrade method provided in the first embodiment of this application includes the following steps: S1: Obtain information on the firmware upgrade package data size, maximum segment transmission size, and memory fanout size; S2: Determine the firmware upgrade data writing mode based on the firmware upgrade package data size information, the maximum segment transmission size information, and the memory fanout area size information; S3: Using the firmware upgrade data writing mode, write all firmware upgrade package data into the memory to complete the firmware upgrade.
[0021] This application embodiment can flexibly select a suitable writing mode for firmware upgrade data based on the actual size of the firmware upgrade package, the platform's maximum segmented transmission capability, and the size of the memory fan-out area. This avoids the problem of low efficiency in single-sector cyclic writing and also avoids the risk of unreliable data writing due to the limitation of the platform's maximum segmented transmission capability in one-time full writing. While ensuring the reliability of firmware upgrade, it effectively improves upgrade efficiency and better meets the actual needs of on-site firmware upgrades for embedded storage devices.
[0022] In some embodiments, the firmware upgrade method is for field firmware upgrades of eMMC using the mmc-utils open-source tool. The storage device can be eMMC or other storage devices, and the maximum segment transfer size information is the transmission segment limit (max_segment_size) existing on the platform.
[0023] In step S1, the firmware upgrade package data size information can be obtained by reading the firmware upgrade package file header to extract the complete data size of the firmware upgrade package. Alternatively, the size information can be obtained by counting the total number of bytes in the firmware upgrade package; there is no specific limitation on this. To obtain the maximum segment transmission size information, the corresponding sysfs path can be obtained by extracting the memory name and concatenating the corresponding path, then reading the platform's preset maximum transmission segment value. This method directly obtains accurate parameters from the system without additional configuration. The memory fan-out area size information refers to the storage size of a single fan-out area in the memory, which can be directly read from the eMMC's identification information. This parameter is usually a fixed value, and the acquisition method is simple and efficient.
[0024] To obtain the maximum segment transfer size information, the memory name can be extracted; then, the maximum segment transfer size can be obtained by concatenating the sysfs path / sys / block / mmcblk0 / queue / max_segment_size and reading the platform's maximum segment transfer value. This process can read the platform's maximum segment transfer value non-intrusively, without kernel modification or third-party dependencies, and is compatible with most Linux operating environments.
[0025] In this embodiment, the firmware upgrade data writing mode includes a full write mode. When the displayed result of the firmware upgrade package data size information is less than or equal to the displayed result of the maximum segment transmission size information, the full write mode is used to write all firmware upgrade package data into the memory at once, completing the firmware upgrade. When the displayed result of the firmware upgrade package data size information is less than or equal to the displayed result of the maximum segment transmission size information, it indicates that the overall size of the current firmware upgrade package meets the platform's single transmission requirements and there is no problem of exceeding the transmission limit. Therefore, the full write mode can be used directly to write all firmware upgrade package data into the memory at once to complete the firmware upgrade. This mode requires only one write operation, has the highest upgrade efficiency, and will not trigger transmission anomalies, ensuring upgrade reliability.
[0026] In this embodiment, the firmware upgrade data writing mode includes a segmented writing mode. When the displayed result of the firmware upgrade package data size information is greater than the displayed result of the maximum segment transmission size information, the segmented writing mode is used to write all firmware upgrade package data into the memory in segments to complete the firmware upgrade. The segmented writing mode divides the firmware upgrade package data into n upgrade files, where the storage size of each upgrade file is less than or equal to the displayed result of the maximum segment transmission size information, and the storage size of each upgrade file is an integer multiple of the displayed result of the memory fan-out area size information; where n is a natural number greater than 1.
[0027] When the size of the firmware upgrade package data is greater than the maximum segmented transmission size, it indicates that a full write would exceed the platform's maximum single transmission limit, potentially leading to upgrade failure. In this case, the segmented write mode is used to write all firmware upgrade package data into the memory in segments to complete the firmware upgrade. The segmented write mode divides the firmware upgrade package data into n upgrade files, each with a storage size less than or equal to the maximum segmented transmission size, ensuring that each segmented write does not exceed the platform's transmission limit and preventing upgrade failure or chip bricking. Furthermore, the storage size of each upgrade file is an integer multiple of the memory fan-out size, adapting to the memory's write alignment requirements and ensuring the reliability of the written data.
[0028] Furthermore, a single write operation is performed sequentially on each segmented upgrade file. After all upgrade files have been written, the written firmware data is integrated and verified. Once the data is confirmed to be complete and error-free, the upgrade is completed. This embodiment, by writing the segmented upgrade files sequentially, not only meets the platform's transmission limitations but also reduces unnecessary write operations, significantly improving upgrade efficiency compared to single-sector cyclic writing.
[0029] In some embodiments, each upgrade file has the same storage size. This application embodiment simplifies the segmentation logic and reduces processing complexity by evenly dividing the firmware upgrade package data, while also ensuring load balancing for each write operation, thus meeting the platform's stable operation requirements.
[0030] In some embodiments, at least two of the upgrade files have different storage sizes. Specifically, each upgrade file has a different storage size, or some upgrade files have different storage sizes. In this embodiment, as long as the storage size of each upgrade file is less than the maximum segmented transfer size and is an integer multiple of the memory fan-out size, the solution in this embodiment can adapt to different size partitioning requirements, meet various practical situations, and is more flexible.
[0031] In some embodiments, the result of the maximum segment transfer size information is less than the storage size of the two upgrade files. This application embodiment controls the size of the upgrade file written in a single segment to be less than the maximum segment transfer size, while ensuring that the size of the two upgrade files exceeds the maximum segment transfer limit. This minimizes the number of segmentations while meeting the transfer limit, further improving the write upgrade efficiency.
[0032] This application embodiment can obtain the `max_segment_size` core parameter, i.e., the maximum segment transfer size, by reading the standard sysfs node of the Linux MMC subsystem. Furthermore, it can dynamically calculate the optimal write segment size for compliance, improving the efficiency and reliability of eMMC FFU upgrades while ensuring full cross-platform compatibility.
[0033] During the eMMC upgrade and after-sales maintenance of embedded devices, the inventors discovered that the native mmc-utils tool yielded inconsistent upgrade results on different hardware platforms (different brands of controllers, different kernel versions): some platforms could perform full writes, some platforms reported errors directly, and some platforms could only perform low-speed writes. Upgrades could only be achieved by manually obtaining the single-write transfer limit, adjusting the code, and recompiling the tool. This application proposes an approach that first detects hardware transfer limits and then dynamically calculates write segments. By reading the max_segment_size parameter from the standard Linux system sysfs node, an adaptive segmentation decision logic is constructed. This achieves intelligent adaptation for mmc-utils FFU upgrades without modifying the kernel or disrupting the native tool framework, effectively solving the problem of simultaneously achieving cross-platform compatibility, upgrade efficiency, and upgrade reliability.
[0034] In some embodiments, the maximum segment transmission size information is read from the max_segment_size parameter of the corresponding block device under the Linux system sysfs node. Without the need for manual parameter configuration or tool recompilation, cross-platform parameter adaptation can be automatically completed, adapting to the transmission limitations of different hardware platforms and solving the problem of inconsistent results in cross-platform upgrades of native tools.
[0035] like Figure 2 As shown, as a firmware upgrade device provided in the second embodiment of this application, the firmware upgrade device 10 includes a memory 20 and a processor 30. The memory 20 stores a computer program 21, and the processor 30 executes the computer program 21 to implement the steps of the firmware upgrade method as described above.
[0036] like Figure 3 As shown, as a computer-readable storage medium provided in the third embodiment of this application, the computer-readable storage medium 40 stores a computer program 21, which, when executed by the processor 30, implements the steps of the firmware upgrade method as described above.
[0037] It should be noted that the limitations of each step involved in this solution are not considered as limiting the order of steps, provided that they do not affect the implementation of the specific solution. The steps listed first can be executed first, later, or even simultaneously. Solutions from different embodiments can be combined and applied without conflict. As long as this solution can be implemented, they should be considered to fall within the protection scope of this application.
[0038] The above description, in conjunction with specific optional embodiments, provides a further detailed explanation of this application and should not be construed as limiting the specific implementation of this application to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of this application, and all such modifications and substitutions should be considered within the scope of protection of this application.
Claims
1. A firmware upgrade method, characterized in that, Including the following steps: Obtain information on the firmware upgrade package data size, maximum segment transfer size, and memory fanout size; The firmware upgrade data writing mode is determined based on the firmware upgrade package data size information, the maximum segment transmission size information, and the memory fan-out area size information. as well as The firmware upgrade data is written to the memory using the firmware upgrade data writing mode to complete the firmware upgrade.
2. The firmware upgrade method as described in claim 1, characterized in that, The firmware upgrade data writing mode includes a full write mode. When the result of the firmware upgrade package data size information is less than or equal to the result of the maximum segment transmission size information, the full write mode is used to write all firmware upgrade package data into the memory at once to complete the firmware upgrade.
3. The firmware upgrade method as described in claim 1, characterized in that, The firmware upgrade data writing mode includes a segmented writing mode. When the result of the firmware upgrade package data size information is greater than the result of the maximum segment transmission size information, the segmented writing mode is used to write all firmware upgrade package data into the memory in segments to complete the firmware upgrade. The segmented writing mode divides the firmware upgrade package data into n upgrade files, the storage size of each upgrade file is less than or equal to the result displayed by the maximum segmented transmission size information, and the storage size of each upgrade file is an integer multiple of the result displayed by the memory fan-out area size information. Where n is a natural number greater than 1.
4. The firmware upgrade method as described in claim 3, characterized in that, Each of the upgrade files has the same storage size.
5. The firmware upgrade method as described in claim 3, characterized in that, At least the two upgrade files have different storage sizes.
6. The firmware upgrade method as described in claim 3, characterized in that, The result of the maximum segment transmission size information is less than the storage size of the two upgrade files.
7. The firmware upgrade method as described in claim 1, characterized in that, The step of obtaining firmware upgrade package data size information, maximum segment transfer size information, and memory fan-out area size information includes: Extract the memory name; The maximum segment size information of the platform is obtained by concatenating the sysfs path / sys / block / mmcblk0 / queue / max_segment_size.
8. The firmware upgrade method as described in claim 1, characterized in that, The firmware upgrade method described herein is applicable to field firmware upgrades using the mmc-utils open-source tool.
9. A firmware upgrade device, characterized in that, The firmware upgrade device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the firmware upgrade method according to any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the firmware upgrade method as described in any one of claims 1 to 8.