Firmware flashing method and device processing method
By introducing a feature value verification mechanism during the firmware flashing process, the security issues of flashing firmware between different versions are resolved, thereby improving the security and stability of device firmware upgrades and avoiding device failures and wasted debugging time.
Patent Information
- Application Number
- CN202610773868.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-29
- Publication Date
- 2026-08-25
AI Technical Summary
Existing technologies cannot achieve secure firmware flashing between different versions, resulting in illegal and incorrect firmware versions being accidentally flashed onto the storage medium, causing device failures and increased development and debugging time and costs.
By introducing a firmware feature value verification mechanism on the host computer and the device, the flashing action is only performed after the feature value of the firmware to be flashed is consistent with the feature value in the target upgrade package. This includes binding firmware feature values, storage address and version information in the upgrade package, and the device performs comparison and verification and sends back a flashing failure signal.
It improves the security and stability of firmware upgrades, avoids device failures caused by unauthorized firmware flashing, and reduces development and debugging time and costs.
Smart Images

Figure CN122633209A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of firmware flashing technology, and more particularly to a firmware flashing method and a device processing method. Background Technology
[0002] Different software versions on the same hardware environment may have different definitions for firmware storage addresses. In this case, the conventional OTA A / B zone upgrade strategy cannot achieve cross-version flashing. Furthermore, during the research and development and debugging of multiple versions, there is a possibility of illegal firmware and incorrect firmware versions being accidentally flashed to the storage medium, resulting in the scrapping of the board and greatly consuming development and debugging time and costs. Summary of the Invention
[0003] This application provides a firmware flashing method and a device processing method, aiming to solve the problem that conventional firmware upgrade methods cannot achieve secure flashing of software between different versions, and that during the research and development and debugging of multiple versions, there is a situation where illegal firmware and incorrect firmware versions are accidentally flashed to the storage medium, resulting in the scrapping of the board.
[0004] This application proposes a firmware flashing method applied to a host computer, comprising: responding to receiving a firmware flashing request, determining the firmware to be flashed and a target upgrade version of the firmware to be flashed based on the firmware flashing request; obtaining a target upgrade package based on the target upgrade version, wherein the target upgrade package includes a first firmware feature value corresponding to the target upgrade version; sending the target upgrade package to the device corresponding to the firmware to be flashed, so that if the second firmware feature value obtained by the device corresponding to the firmware to be flashed from parsing the target upgrade package is consistent with the first firmware feature value, a corresponding flashing action is performed.
[0005] Therefore, the host computer locates the firmware to be flashed and the target upgrade version based on the flashing request. The upgrade package contains the first firmware feature value. The device will parse and generate the second firmware feature value and compare it with the first feature value in the upgrade package. Only if the two match will the flashing be performed, thus preventing device failures caused by illegal firmware flashing and greatly improving the security and stability of device firmware upgrades.
[0006] This application also proposes a data processing method for a device, comprising: receiving a target upgrade package corresponding to a target upgrade version of the firmware to be flashed, sent by a host computer, wherein the target upgrade package includes a first firmware feature value corresponding to the target upgrade version; parsing the target upgrade package to obtain a second firmware feature value; comparing whether the second firmware feature value is consistent with the first firmware feature value; if the second firmware feature value is consistent with the first firmware feature value, then flashing the firmware to be flashed according to the target upgrade package; otherwise, sending a flashing failure signal to the host computer.
[0007] Therefore, the device receives the target upgrade package carrying the first firmware feature value from the host computer, performs local parsing of the target upgrade package to generate the second firmware feature value, and compares it with the first firmware feature value carried in the upgrade package. The firmware to be flashed is only written when the firmware feature values match, to avoid flashing illegal firmware. If the verification is inconsistent, the device actively sends a flashing failure signal to the host computer, so that the host computer can detect the device upgrade anomaly in real time and quickly locate the fault node.
[0008] This application also proposes a firmware flashing system, comprising: a version determination module, configured to, in response to receiving a firmware flashing request, determine the firmware to be flashed and the target upgrade version of the firmware to be flashed based on the firmware flashing request; an acquisition module, configured to acquire a target upgrade package based on the target upgrade version, wherein the target upgrade package includes a first firmware feature value corresponding to the target upgrade version; and a sending module, configured to send the target upgrade package to the device corresponding to the firmware to be flashed, so that if the second firmware feature value obtained by the device corresponding to the firmware to be flashed from parsing the target upgrade package is consistent with the first firmware feature value, a corresponding flashing action is performed.
[0009] This application also proposes a data processing system for a device, comprising: a receiving module, configured to receive a target upgrade package corresponding to a target upgrade version of the firmware to be flashed, sent by a host computer, wherein the target upgrade package includes a first firmware feature value corresponding to the target upgrade version; a comparison module, configured to parse the target upgrade package to obtain a second firmware feature value, and compare whether the second firmware feature value is consistent with the first firmware feature value; and a flashing module, configured to flash the firmware to be flashed according to the target upgrade package if the second firmware feature value is consistent with the first firmware feature value, otherwise, send a flashing failure signal to the host computer.
[0010] This application also proposes an electronic device, including a processor and a memory, wherein the memory is used to store computer programs; the processor is used to execute the programs stored in the memory to implement the firmware flashing method and the device data processing method.
[0011] This application also proposes a vehicle that includes the aforementioned electronic equipment.
[0012] This application also proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the firmware flashing method and device data processing method described in any embodiment of this application. Attached Figure Description
[0013] Figure 1This is a flowchart of a firmware flashing method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the software construction process provided in an embodiment of this application; Figure 3 This is a schematic diagram of the firmware flashing process provided in one embodiment of this application; Figure 4 This is a flowchart of data processing of a device provided in an embodiment of this application; Figure 5 This is a structural diagram of the firmware flashing system provided in the embodiments of this application; Figure 6 This is a structural diagram of the data processing system of the device provided in the embodiments of this application; Figure 7 This is a structural diagram of the electronic device provided in the embodiments of this application; Figure 8 This is a vehicle structure diagram provided in one embodiment of this application. Detailed Implementation
[0014] To make the technical problems, technical solutions, and beneficial effects solved by this application clearer, the following detailed description is provided in conjunction with embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0015] In actual development and mass production, different vehicle models require different storage address ranges to meet corresponding functional requirements. However, the current OTA A / B upgrade method cannot achieve upgrade switching and debugging between different versions.
[0016] During the development and debugging of multiple versions, the software was directly written to the storage medium according to the firmware name. This could lead to different versions of the software being written to the storage medium incorrectly, resulting in abnormal software startup after the upgrade and failure to start and debug normally, which greatly consumed development and debugging time and costs.
[0017] To address the above issues, this application provides a firmware flashing method. Please refer to the following embodiments. Figure 1 This includes the following steps: In step S101, in response to receiving a firmware flashing request, the firmware to be flashed and the target upgrade version of the firmware to be flashed are determined according to the firmware flashing request.
[0018] Among them, firmware flashing requests come from developers or testers who initiate a one-click flashing operation through a host computer, or from the host computer triggering firmware flashing when it detects that the device's firmware version is outdated.
[0019] The firmware flashing request includes the unique identifier of the multi-core SoC device, the firmware to be flashed (such as mass-produced firmware for A-cores, such as uboot image, kernel image, squashfs read-only file system image, and / or mass-produced firmware for M-cores, such as Bootloader, app firmware), and the target upgrade version of the firmware to be flashed.
[0020] In step S102, a target upgrade package is obtained based on the target upgrade version, wherein the target upgrade package includes the first firmware feature value corresponding to the target upgrade version.
[0021] Specifically, after determining the firmware to be flashed and the target upgrade version of the firmware in the firmware flashing request, the host computer obtains the target upgrade package based on the target upgrade version. The target upgrade package includes a first firmware feature value corresponding to the target upgrade version. Specifically, the target upgrade package refers to a mapping file that is bound to the firmware name, storage address, and upgrade version through the first feature value.
[0022] Optionally, in some embodiments, before obtaining the target upgrade package based on the target upgrade version, the method further includes: in response to the firmware to be flashed meeting preset upgrade conditions, constructing an upgrade system software image and mass-produced firmware for the first core in the device corresponding to the firmware to be flashed, and constructing mass-produced firmware for the second core in the device corresponding to the firmware to be flashed; updating the upgrade system software image of the first core based on the feature values of the mass-produced firmware of the first core and the feature values of the mass-produced firmware of the second core to obtain a new upgrade system software image containing the feature values of the first firmware; and packaging the new upgrade system software image, the mass-produced firmware of the first core, and the mass-produced firmware of the second core to obtain the target upgrade package.
[0023] Specifically, before obtaining the target upgrade package based on the target upgrade version, the host computer first determines whether the firmware to be flashed meets the preset upgrade conditions (such as incompatibility between the device's hardware model and firmware, or the device's current version being lower than the target version). Only after the conditions are met will the upgrade package construction begin. The specific process for building the software package is as follows: Figure 2 As shown.
[0024] First, build an independent upgrade system software image (specifically a ramdisk memory file system image) for the device's first core (core A in a multi-core system-on-a-chip device). This image contains firmware storage address information and upgrade instruction scripts corresponding to the target version. At the same time, build the mass production firmware (uboot, kernel, squashfs image) for core A.
[0025] Build the mass production firmware (Bootloader, app firmware) for the second core (M core in a multi-core system-on-a-chip device).
[0026] Furthermore, the feature values (such as MD5 values) of the mass-produced firmware for core A and core M are calculated separately to ensure that the feature values of each firmware are unique.
[0027] The target upgrade version, firmware names of A-core and M-core, storage addresses corresponding to each firmware, and firmware feature values (i.e. first firmware feature values) of A-core and M-core are summarized to generate a binding mapping file, realizing one-to-one binding of "upgrade version-firmware name-storage address-firmware feature value".
[0028] Furthermore, the constructed A-core ramdisk image is decompressed, the mapping files are filled into a specific location in the decompressed directory, and then the decompressed directory is compressed a second time to generate a new ramdisk memory file system image (i.e., a new upgrade system software image).
[0029] The updated ramdisk image, the mass-produced firmware for the A-core, and the mass-produced firmware for the M-core are collected according to a preset directory structure, packaged and encapsulated as a whole, and finally generated into the target upgrade package. This ensures that the upgrade system software image and the dual-core firmware correspond one-to-one, avoiding version mixing.
[0030] Therefore, during the upgrade package construction process, the feature values, storage addresses, and other information of the mass-produced firmware of the A core and M core are bound to the A core upgrade system (ramdisk image), and then packaged together with the firmware of the dual cores. This ensures that the "upgrade system-A core firmware-M core firmware" in each target upgrade package correspond one-to-one, avoiding the problem of flashing different versions of firmware and causing the board to become unusable.
[0031] Optionally, in some embodiments, updating the upgrade system software image of the first core based on the feature values of the mass-produced firmware of the first core and the feature values of the mass-produced firmware of the second core to obtain a new upgrade system software image containing the feature values of the first firmware includes: generating a mapping file containing the first feature values bound to an upgrade version, firmware name, and storage address based on the feature values of the mass-produced firmware of the first core and the mass-produced firmware of the second core; and updating the upgrade system software image of the first core using the mapping file to obtain a new upgrade system software image containing the feature values of the first firmware.
[0032] When building a new upgrade system software image, the feature values of the mass-produced firmware of the A core and M core are used as the core, and the corresponding upgrade version, firmware name, and storage address are associated to ensure that each feature value can correspond to a unique firmware, upgrade version, and storage address.
[0033] The mapping file is placed in a specific directory (such as / upgrade / config / ) in the upgrade system software image to obtain a new upgrade system software image, which ensures that the upgrade system software image can quickly read the first firmware feature value in the mapping file after startup.
[0034] Therefore, by taking the feature values of the mass-produced firmware of A-core and M-core as the core, and associating them with the upgrade version, firmware name, and storage address, it is ensured that each feature value can accurately correspond to a unique firmware, a unique upgrade version, and a unique storage address. This completely avoids various flashing errors caused by chaotic information association, and ensures the security and reliability of multi-core SoC firmware upgrades. The mapping file is placed in a specific directory preset by the upgrade system. No additional search path is required. After the upgrade system starts, it can quickly locate and read the first firmware feature value in the mapping file.
[0035] Optionally, in some embodiments, after obtaining the target upgrade package by packaging the new upgrade system software image, the mass-produced firmware of the first core, and the mass-produced firmware of the second core, the method further includes: generating a flashing reminder for the firmware to be flashed based on the target upgrade package; sending the flashing reminder to the device corresponding to the firmware to be flashed, so as to determine that a firmware flashing request has been received when a flashing request is received from the device corresponding to the firmware to be flashed based on the flashing reminder.
[0036] Understandably, after the host computer completes the packaging of the target upgrade package, it generates a flashing reminder based on the target upgrade version (such as "The device's XX firmware can be upgraded to version V1.1, do you confirm flashing?"). The reminder content includes the device identifier, the current version of XX firmware, the target version, and the firmware name (XX firmware for A core and / or M core).
[0037] The host computer sends the flashing reminder to the device corresponding to the firmware to be flashed. After receiving the message, the device can provide feedback to inform the developers or testers that the upgrade is possible. If the developers or testers receive the upgrade feedback from the device, they will determine that the firmware flashing request has been received.
[0038] Therefore, after obtaining the target upgrade package, a flashing reminder for the firmware to be flashed is generated based on the target upgrade package and sent to the device to be flashed. When the host computer receives the flashing request from the device based on the flashing reminder, it determines that the firmware flashing request has been received, ensuring that the flashing operation accurately corresponds to the target device and the target firmware.
[0039] In step S103, the target upgrade package is sent to the device corresponding to the firmware to be flashed, so that if the second firmware feature value obtained by the device corresponding to the firmware to be flashed from the target upgrade package is consistent with the first firmware feature value, the corresponding flashing action is performed.
[0040] Specifically, such as Figure 3 As shown, the host computer establishes communication with the device (e.g., the host computer sends a special mode start command through the serial port to put the device into upgrade mode, and then transmits the target upgrade package through the network) to ensure that the device can receive the upgrade package.
[0041] After receiving the target upgrade package, the device will parse the upgrade package and extract the feature values (such as MD5 values) of the mass-produced firmware of the A core and M core. These feature values are the second firmware feature values.
[0042] The device will compare the second firmware feature value obtained by parsing with the first firmware feature value embedded in the target upgrade package before transmission. If the two are completely consistent, it means that the firmware to be flashed is legal and the version matches, and the device will perform the flashing action. If they are inconsistent, it means that the firmware has been tampered with or the version is wrong, and the device will refuse to flash and send a failure signal to the host computer.
[0043] Optionally, in some embodiments, when sending the target upgrade package to the device corresponding to the firmware to be flashed, the process includes: segmenting the target upgrade package into fragments, transmitting each fragment sequentially to the device corresponding to the firmware to be flashed, and monitoring the transmission status of each fragment and the upgrade progress of the target upgrade package.
[0044] Specifically, when transmitting the target upgrade package, the host computer splits the target upgrade package into several fixed-size data fragments (e.g., each fragment is 1024KB), and each fragment is numbered (e.g., 001, 002...). The total number of fragments and the offset position of each fragment are recorded to ensure that the fragment order is traceable.
[0045] The host computer transmits data fragments to the device one by one according to the fragment number sequence. At the same time, it monitors the transmission status of each fragment in real time (such as whether the transmission was successful, whether there was packet loss, and whether there was a timeout). It also calculates the proportion of the transmitted fragments to the total fragments, updates the upgrade progress in real time (such as "transmission progress 30%)", and synchronizes it with the development and testing personnel.
[0046] If a transmission interruption occurs due to network fluctuations, link disconnection, or device offline, the host computer immediately stops the transmission, records the successfully transmitted fragment number and offset position, and saves the transmission progress. When the communication link is restored, the host computer does not need to retransmit the full upgrade package, but only resumes the transmission from the next incomplete fragment at the interruption position, thus achieving breakpoint resumption.
[0047] Therefore, by splitting the complete target upgrade package into fixed-size data fragments, transmitting each fragment one by one, and monitoring the transmission status of each fragment in real time, transmission anomalies can be quickly detected. When transmission interruptions occur, such as network fluctuations, link disconnections, or device offline, the host computer promptly stops transmission and records the information of successfully transmitted fragments. Once communication is restored, there is no need to retransmit the full upgrade package; only the incomplete fragments are continued to be sent. This effectively saves network bandwidth, avoids the time wasted by repeated transmissions, calculates the percentage of transmitted fragments in real time, updates the upgrade progress, and synchronizes it with development and testing personnel, allowing staff to clearly understand the upgrade package transmission progress of each device, facilitating subsequent troubleshooting of transmission anomalies.
[0048] Optionally, in some embodiments, before sending the target upgrade package and the first firmware to the device corresponding to the firmware to be flashed, the method includes: reading the current firmware version of the first core and the current firmware version of the second core of the device corresponding to the firmware to be flashed; comparing whether the current firmware version of the first core and / or the current firmware version of the second core meet preset upgrade conditions based on the target upgrade package; and if the current firmware version of the first core and / or the current firmware version of the second core meet the preset upgrade conditions, sending the target upgrade package to the device corresponding to the firmware to be flashed.
[0049] Specifically, after the host computer establishes communication with the device via the serial port, it reads the firmware version of the A core and the firmware version of the M core currently running on the device (i.e., the current firmware version of the device).
[0050] If the current firmware version of core A is lower than the target version, and the current firmware version of core M is also lower than the target version, it is determined that the firmware of core A and core M meet the preset upgrade conditions, and an upgrade package can be sent to upgrade the firmware of both cores.
[0051] If only the current firmware version of core A is lower than the target version, while the current firmware version of core M is the latest, then the firmware of core A is determined to meet the upgrade conditions, and the firmware of core A is upgraded.
[0052] If only the current firmware version of core M is lower than the target version, while the current firmware version of core A is the latest, core M is deemed to meet the upgrade conditions, and the firmware of core M is then upgraded.
[0053] If the current firmware versions of both core A and core M are equal to the target version, the device's firmware is determined not to meet the upgrade requirements, and the upgrade package will not be sent to avoid invalid flashing.
[0054] Therefore, by comparing the current firmware version of the A core and the M core with the target version, the firmware that meets the upgrade conditions is determined. Firmware that does not meet the upgrade conditions is not flashed, while firmware that meets the upgrade conditions is flashed. This avoids meaningless repeated flashing, reduces the communication load between the host computer and the device, saves network bandwidth, device storage resources and upgrade time, and improves upgrade efficiency.
[0055] This application also proposes a data processing method for a device, such as... Figure 4 As shown, the method includes the following steps: In step S401, the host computer sends a target upgrade package corresponding to the target upgrade version of the firmware to be flashed. The target upgrade package includes the first firmware feature value corresponding to the target upgrade version.
[0056] In step S402, the target upgrade package is parsed to obtain the second firmware feature value, and the second firmware feature value is compared with the first firmware feature value to see if they are consistent.
[0057] In step S403, if the second firmware feature value is consistent with the first firmware feature value, then the firmware to be flashed is flashed according to the target upgrade package; otherwise, a flashing failure signal is sent to the host computer.
[0058] Specifically, the device receives a special upgrade mode start command sent by the host computer and receives the target upgrade package transmitted by the host computer.
[0059] After receiving the target upgrade package sent by the host computer, the device parses the target upgrade package to obtain the mass production firmware of the A core and the M core. Then, it calculates the second firmware feature value by using the hash calculation tool (such as the MD5 calculation tool) built into the upgrade system software image.
[0060] The device compares the calculated second firmware feature value with the first firmware feature value in the target upgrade package before transmission. If the second firmware feature value matches the first firmware feature value in the target upgrade package before transmission, it means that the firmware to be flashed is a legitimate firmware that matches the target version and can be flashed. If they do not match, it means that the firmware to be flashed has been tampered with, has an incorrect version, or has been damaged during the transmission of the upgrade package. The device determines that the verification has failed, refuses to perform the flashing action, and sends a flashing failure signal to the host computer.
[0061] Optionally, in some embodiments, when flashing the firmware to be flashed according to the target upgrade package, the process includes: stopping the flashing process in response to an interruption in communication between the host computer and the device, and continuing the flashing operation from the interrupted position after a successful communication connection between the host computer and the device.
[0062] If communication between the device and the host computer is interrupted during the flashing process (such as network disconnection or serial port disconnection), the current flashing action is stopped immediately (erasure and writing are stopped), and the current flashing progress is saved (such as the firmware fragments that have been flashed, the address locations that have been written, and the fragment information that has been transmitted) to avoid device failure due to incomplete firmware writing.
[0063] Once the device re-establishes communication with the host computer, it will continue the flashing process from the point of interruption, without needing to re-flash the already completed parts.
[0064] Therefore, when communication is interrupted, the erasing, writing and other flashing operations are stopped immediately, while the flashing progress is saved. This can effectively prevent problems such as incomplete firmware writing and incorrect storage addresses, avoid firmware damage and device boot failure caused by interruption, and further ensure the security of firmware flashing for multi-core SoCs. After communication is restored, there is no need to re-flash the completed part. The flashing is only resumed from the interrupted position, avoiding a full re-flash due to communication interruption, and greatly saving flashing time and device resources.
[0065] Optionally, in some embodiments, when flashing the firmware to be flashed according to the target upgrade package, the method includes: if there are multiple firmwares to be flashed, then flashing the firmwares in descending order of priority.
[0066] Understandably, when there are multiple firmware files to be flashed (such as the uboot image, kernel image, and squashfs image for the A core, and the Bootloader and app firmware for the M core, totaling 5 firmware files to be flashed), the system software image upgrade will be performed in order of priority from high to low.
[0067] For example, the priority of each firmware from high to low is as follows: uboot image of core A > Bootloader of core M > kernel image of core A > squashfs image of core A > app firmware of core M.
[0068] The upgrade system software image first identifies the priority of all firmware to be flashed, and performs the flashing one by one in a preset order. After the flashing and verification of each high-priority firmware is completed, the flashing of the next low-priority firmware is started. If the flashing of a certain priority firmware fails, the entire flashing process is terminated immediately, and a failure signal is sent to the host computer to avoid invalid flashing of low-priority firmware and to facilitate the location of faulty firmware.
[0069] Therefore, by setting the priority of each firmware and flashing them in descending order, the risk of flashing order disorder is avoided, ensuring the safety of device startup. If a high-priority firmware fails to flash, the entire flashing process is terminated immediately, avoiding meaningless and invalid flashing of low-priority firmware, saving device storage and flashing resources and flashing time. The process is terminated immediately and a failure signal is fed back when firmware flashing fails, making it easier for developers and testers to locate the firmware that failed to flash.
[0070] Optionally, in some embodiments, when flashing the firmware to be flashed according to the target upgrade package, the method further includes: dividing the firmware to be flashed into multiple data blocks and writing them to the device block by block; after each data block is written, comparing the data block already written in the device with the corresponding data block before writing; if the data block already written is inconsistent with the corresponding data block before writing, then a flashing error is determined, and the data block already written is erased and rewritten.
[0071] Specifically, after receiving the target upgrade package sent by the host computer, the device parses out the firmware to be flashed (including the uboot, kernel, and squashfs image of the A core and the bootloader and app firmware of the M core). Based on the page size and partition granularity of the device's storage medium (such as Flash), the firmware to be flashed is independently divided into multiple fixed-size data blocks (such as 1024KB per block, which can be flexibly configured according to the storage characteristics of the device). Each data block is uniquely numbered, and the total number of data blocks, the offset position of each data block, and the corresponding original data are recorded. This avoids problems such as cache overflow, write timeout, and data transmission interruption caused by writing too much data at once, and adapts to scenarios where the firmware size of multi-core SoCs is large.
[0072] The upgrade system software image in the target upgrade package writes the divided data blocks to be flashed to the corresponding storage partition of the device one by one according to the data block number order (writing to the corresponding location according to the storage address of the firmware to be flashed, following the storage address binding rules in the mapping file). During the writing process, the writing status of the data blocks is monitored in real time to ensure that each data block is accurately written to the corresponding storage location, avoiding basic anomalies such as address confusion and write interruption.
[0073] After each data block write operation is completed, the upgraded system software image reads back the written data block from the device's storage medium. The actual data block read back is then compared with the original data block before it was partitioned and written. The comparison method can be a feature value (such as MD5) comparison to ensure the consistency between the written data and the original data.
[0074] If the characteristic value of the written data block read back is inconsistent with the characteristic value of the data block before writing, the data block is immediately determined to have been written incorrectly. In this case, the upgrade system will first erase the storage area containing the erroneous data block, then reread the storage address of the data block and perform the write operation again; after writing is complete, a readback verification is performed again until the data block is written correctly. If multiple retries (e.g., 3 times) still fail to write correctly, the data block is determined to have failed to be written, the entire writing process is terminated, and a writing failure signal is sent to the host computer to facilitate troubleshooting by development and testing personnel.
[0075] Therefore, the firmware to be flashed is divided into multiple small data blocks and written one block at a time, reducing the amount of data written in a single operation. This effectively avoids problems such as buffer overflow, write timeout, and communication interruption caused by writing large amounts of data at once, adapting to the large firmware flashing requirements of multi-core SoCs and improving overall flashing stability. Each completed data block is compared to the previous one, allowing for timely detection of write anomalies in individual data blocks, preventing the accumulation of erroneous data blocks and the spread of errors to the entire firmware, thus reducing the probability of firmware flashing failure from the source. When a flashing error occurs, only the erroneous data block is erased and rewritten, without needing to erase and re-flash the entire firmware to be flashed, significantly saving flashing time and reducing the number of times the device's storage medium (Flash) is erased and written, reducing hardware wear and extending the device's lifespan.
[0076] This application also proposes a firmware flashing system 10, such as... Figure 5 As shown, it includes: a version determination module 100, used to determine the firmware to be flashed and the target upgrade version of the firmware to be flashed in response to receiving a firmware flashing request; an acquisition module 200, used to acquire a target upgrade package based on the target upgrade version, wherein the target upgrade package includes a first firmware feature value corresponding to the target upgrade version; and a sending module 300, used to send the target upgrade package to the device corresponding to the firmware to be flashed, so that if the second firmware feature value obtained by the device corresponding to the firmware to be flashed from parsing the target upgrade package is consistent with the first firmware feature value, the corresponding flashing action is performed.
[0077] Optionally, in some embodiments, before obtaining the target upgrade package based on the target upgrade version, the acquisition module 200 is configured to: in response to the firmware to be flashed meeting preset upgrade conditions, construct an upgrade system software image and mass-produced firmware for the first core in the device corresponding to the firmware to be flashed, and construct a mass-produced firmware for the second core in the device corresponding to the firmware to be flashed; update the upgrade system software image of the first core based on the feature values of the mass-produced firmware of the first core and the feature values of the mass-produced firmware of the second core, to obtain a new upgrade system software image containing the feature values of the first firmware; and encapsulate the new upgrade system software image, the mass-produced firmware of the first core, and the mass-produced firmware of the second core to obtain the target upgrade package.
[0078] Optionally, in some embodiments, the acquisition module 200 is configured to: generate a mapping file containing the first feature value bound to the upgrade version, firmware name, and storage address based on the feature value of the mass-produced firmware of the first core and the feature value of the mass-produced firmware of the second core; and update the upgrade system software image of the first core using the mapping file to obtain a new upgrade system software image containing the first firmware feature value.
[0079] Optionally, in some embodiments, before sending the target upgrade package and the first firmware to the device corresponding to the firmware to be flashed, the sending module 300 is configured to: read the current firmware version of the first core and the current firmware version of the second core of the device corresponding to the firmware to be flashed; compare whether the current firmware version of the first core and / or the current firmware version of the second core meet preset upgrade conditions based on the target upgrade package; and if the current firmware version of the first core and / or the current firmware version of the second core meet the preset upgrade conditions, send the target upgrade package to the device corresponding to the firmware to be flashed.
[0080] Optionally, in some embodiments, after obtaining the target upgrade package by packaging the new upgrade system software image, the mass-produced firmware of the first core, and the mass-produced firmware of the second core, the acquisition module 200 is further configured to: generate a flashing reminder for the firmware to be flashed based on the target upgrade package; and send the flashing reminder to the device corresponding to the firmware to be flashed, so as to determine that a firmware flashing request has been received when a flashing request is received from the device corresponding to the firmware to be flashed based on the flashing reminder.
[0081] Optionally, in some embodiments, when sending the target upgrade package to the device corresponding to the firmware to be flashed, the sending module 300 is further configured to: perform fragment processing on the target upgrade package, transmit the fragments one by one to the device corresponding to the firmware to be flashed in the order of the fragments, and monitor the transmission status of each fragment and the upgrade progress of the target upgrade package.
[0082] It should be noted that the explanation of the firmware flashing method embodiment described above also applies to the firmware flashing system of this embodiment, and will not be repeated here.
[0083] This application also proposes a data processing system 20 for a device, such as... Figure 6 As shown, it includes: a receiving module 400, used to receive a target upgrade package corresponding to the target upgrade version of the firmware to be flashed sent by a host computer, the target upgrade package including a first firmware feature value corresponding to the target upgrade version; a comparison module 500, used to parse the target upgrade package to obtain a second firmware feature value, and compare whether the second firmware feature value is consistent with the first firmware feature value; and a flashing module 600, used to flash the firmware to be flashed according to the target upgrade package if the second firmware feature value is consistent with the first firmware feature value, otherwise, send a flashing failure signal to the host computer.
[0084] Optionally, in some embodiments, when flashing the firmware to be flashed according to the target upgrade package, the flashing module 600 is configured to: stop flashing in response to an interruption in communication between the host computer and the device, and continue the flashing operation from the interruption point after a successful communication connection between the host computer and the device.
[0085] Optionally, in some embodiments, when flashing the firmware to be flashed according to the target upgrade package, the flashing module 600 is further configured to: if there are multiple firmwares to be flashed, flash the firmwares to be flashed in descending order of priority.
[0086] Optionally, in some embodiments, when flashing the firmware to be flashed according to the target upgrade package, the flashing module 600 is further configured to: divide the firmware to be flashed into multiple data blocks and write them to the device block by block; after each data block is written, compare the data block already written in the device with the corresponding data block before writing; if the data block already written is inconsistent with the corresponding data block before writing, then determine that a flashing error has occurred, and perform an erase and rewrite operation on the data block already written.
[0087] It should be noted that the foregoing explanation of the data processing method embodiment of the device also applies to the data processing system of the device in this embodiment, and will not be repeated here.
[0088] This application also provides an electronic device, please refer to... Figure 7 The electronic device 30 includes a processor 702 and a memory 701. The memory 701 is used to store computer programs. The processor 702 is used to execute the programs stored in the memory 701 to implement the firmware flashing method and the device data processing method described in any embodiment of this application.
[0089] This application also provides a vehicle, please refer to the embodiments thereof. Figure 8 The vehicle 40 includes the aforementioned electronic equipment 30.
[0090] This application also proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the firmware flashing method and device data processing method described in any embodiment of this application.
[0091] In this application, "multiple" refers to two or more.
[0092] In this application, unless otherwise expressly defined, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection between two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0093] The terms “first,” “second,” “third,” “fourth,” etc., in this application (if present) are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0094] In this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, in this application, the character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0095] Unless otherwise specified, all steps in this application may be performed sequentially or randomly. For example, if a method includes steps A and B, it means that the method may include steps A and B performed sequentially, or it may include steps B and A performed sequentially. For example, if a method may also include step C, it means that step C may be added to the method in any order. For example, the method may include steps A, B, and C, or it may include steps A, C, and B, or it may include steps C, A, and B, etc.
[0096] The above are merely preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A firmware flashing method, characterized in that, The method is applied to a host computer and includes the following steps: In response to receiving a firmware flashing request, determine the firmware to be flashed and the target upgrade version of the firmware to be flashed based on the firmware flashing request; Based on the target upgrade version, a target upgrade package is obtained, wherein the target upgrade package includes a first firmware feature value corresponding to the target upgrade version; The target upgrade package is sent to the device corresponding to the firmware to be flashed, so that if the second firmware feature value obtained by the device corresponding to the firmware to be flashed from the target upgrade package is consistent with the first firmware feature value, the corresponding flashing action is performed.
2. The firmware flashing method according to claim 1, characterized in that, Before obtaining the target upgrade package based on the target upgrade version, the process also includes: In response to the firmware to be flashed meeting the preset upgrade conditions, the upgrade system software image and mass production firmware of the first core in the device corresponding to the firmware to be flashed are constructed, and the mass production firmware of the second core in the device corresponding to the firmware to be flashed is constructed. The upgrade system software image of the first core is updated based on the feature values of the mass-produced firmware of the first core and the feature values of the mass-produced firmware of the second core to obtain a new upgrade system software image containing the feature values of the first firmware. The target upgrade package is obtained by packaging the new upgrade system software image, the mass-produced firmware of the first core, and the mass-produced firmware of the second core.
3. The firmware flashing method according to claim 2, characterized in that, The upgrade system software image of the first core is updated based on the feature values of the mass-produced firmware of the first core and the feature values of the mass-produced firmware of the second core, resulting in a new upgrade system software image containing the feature values of the first firmware, including: A mapping file containing the first feature value and the upgrade version, firmware name, and storage address is generated based on the feature values of the mass-produced firmware of the first core and the mass-produced firmware of the second core. The first core's upgrade system software image is updated using the mapping file to obtain a new upgrade system software image containing the first firmware feature value.
4. The firmware flashing method according to claim 2, characterized in that, Before sending the target upgrade package and the first firmware to the device corresponding to the firmware to be flashed, the process includes: Read the current firmware version of the first core and the current firmware version of the second core of the device corresponding to the firmware to be flashed; Based on the target upgrade package, compare whether the current firmware version of the first core and / or the current firmware version of the second core meet the preset upgrade conditions; If the current firmware version of the first core and / or the current firmware version of the second core meet the preset upgrade conditions, the target upgrade package is sent to the device corresponding to the firmware to be flashed.
5. The firmware flashing method according to claim 2 or 3, characterized in that, After packaging the new upgrade system software image, the mass-production firmware of the first core, and the mass-production firmware of the second core to obtain the target upgrade package, the method further includes: Based on the target upgrade package, a flashing reminder for the firmware to be flashed is generated; Send the flashing reminder to the device corresponding to the firmware to be flashed, so that when the device corresponding to the firmware to be flashed sends a flashing request based on the flashing reminder, it is determined that the firmware flashing request has been received.
6. The firmware flashing method according to claim 1, characterized in that, When sending the target upgrade package to the device corresponding to the firmware to be flashed, the following steps are included: The target upgrade package is segmented and transmitted to the device corresponding to the firmware to be flashed in the order of the segments. The transmission status of each segment and the upgrade progress of the target upgrade package are monitored.
7. A data processing method for a device, characterized in that, The method is applied to the device where the firmware resides, including: Receives a target upgrade package corresponding to the target upgrade version of the firmware to be flashed from the host computer, wherein the target upgrade package includes a first firmware feature value corresponding to the target upgrade version; The target upgrade package is parsed to obtain a second firmware feature value, and the second firmware feature value is compared with the first firmware feature value to see if they are consistent. If the second firmware feature value is consistent with the first firmware feature value, then the firmware to be flashed is flashed according to the target upgrade package; otherwise, a flashing failure signal is sent to the host computer.
8. The data processing method of the device according to claim 7, characterized in that, When flashing the firmware to be flashed according to the target upgrade package, the following steps are included: In response to an interruption in communication between the host computer and the device, the flashing process is stopped, and the flashing operation resumes from the interrupted position after a successful communication connection between the host computer and the device.
9. The data processing method of the device according to claim 7, characterized in that, When flashing the firmware to be flashed according to the target upgrade package, the following steps are included: If there are multiple firmware files to be flashed, they will be flashed in descending order of priority.
10. The data processing method of the device according to claim 7, characterized in that, When flashing the firmware to be flashed according to the target upgrade package, the process also includes: The firmware to be flashed is divided into multiple data blocks and written to the device block by block; After each data block write operation is completed, the data block already written in the device is compared with the corresponding data block before the write operation. If the written data block is inconsistent with the corresponding data block before writing, a write error is determined, and the written data block is erased and rewritten.