Firmware upgrade backup method and system based on external Flash and storage medium
By adopting a firmware upgrade backup method based on external Flash in embedded devices, the shortcomings of firmware upgrade solutions in the existing technology in terms of storage management, version control and upgrade processes are solved, and independent storage and backup of multi-version firmware is realized, which improves the reliability and flexibility of the upgrade process.
Patent Information
- Application Number
- CN202510661022.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2025-06-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The firmware upgrade solutions for existing embedded devices have shortcomings in storage management, version control and upgrade processes, especially in special application scenarios such as multi-version firmware management and offline upgrades, which are difficult to meet the needs of high reliability, security and flexibility.
The firmware upgrade and backup method based on external Flash is adopted. By dividing the built-in Flash on the device into a boot loader area and an application software program area, the external Flash is divided into multiple application software program backup areas, real-time firmware storage and backup, and the reliability of the upgrade process is improved through secure handshake, real-time data check-up and dynamic storage management.
It realizes independent storage and backup of multi-version firmware, improves the reliability and flexibility of the firmware upgrade process, avoids the waste of static partitioning of storage space, and provides developers with flexible version fallback and testing environment construction capabilities, improving development and debugging efficiency.
Smart Images

Figure CN120179272A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of embedded systems, and particularly to a firmware upgrade and backup method, system, and storage medium based on an external Flash. Background Art
[0002] With the rapid development of Internet of Things technology, the remote firmware upgrade function of embedded devices has become a standard function of modern intelligent devices. Traditional embedded systems mainly adopt a firmware storage solution based on the built-in Flash of the MCU, and its upgrade methods are usually divided into two typical implementations: The first is a single-area storage architecture, where the firmware is stored in a single Flash area of the MCU. The firmware upgrade technology of embedded devices usually uses methods such as serial port, USB, Bluetooth, or wireless communication to complete the firmware data transmission through the interaction between the host computer and the device-side MCU. Traditional upgrade schemes generally adopt a single-area architecture of "receive - verify - overwrite", that is, directly write the new firmware into the original program storage area of the MCU's built-in Flash. During this process, the device needs to first erase the old firmware and then write the new data. If an abnormal situation such as power failure occurs during transmission or writing, it will cause the system to fail to start, resulting in the risk of "bricking".
[0003] The second is a dual-area backup scheme, which divides the MCU's built-in Flash into two independent areas: a running area and a backup area. When upgrading, first write the new firmware into the backup area, and after verification, switch to the new firmware through address jump. Although this method can avoid the "bricking" risk of the single-area scheme, it is limited by the capacity of the MCU's built-in Flash and usually can only retain one backup version, unable to meet the storage requirements of multiple versions of firmware, and frequent erasing and writing will accelerate the aging of the built-in Flash.
[0004] With the wide application of embedded devices in fields such as industrial control and smart home, higher requirements are put forward for the reliability, security, and flexibility of firmware upgrade. Especially in special application scenarios that require support for multi-version firmware management and offline upgrade, there is still room for improvement in the existing technical solutions in terms of storage management, version control, and upgrade process. Summary of the Invention
[0005] To solve the above technical problems, this application proposes a firmware upgrade and backup method, system, and storage medium based on an external Flash.
[0006] According to the first aspect of this application, a firmware upgrade and backup method based on an external Flash is proposed, including: Dividing the built-in Flash of the device side into a bootloader area and an application software program area, and dividing the external Flash into at least two application software program backup areas; The device end obtains the firmware upgrade data packet sent by the control terminal and writes it into the backup area of the application software program, and performs a complete data verification after the writing is completed; In response to passing the verification, the bootloader area obtains the storage address of the firmware upgrade data packet in the backup area of the application software program, writes it into the application software area, and performs firmware upgrade; Repeat writing different versions of the firmware upgrade data packet backups to different backup areas of the application software program, and overwrite and write to the application software area to achieve multi-version firmware upgrade backup.
[0007] Preferably, before the control terminal sends the fixed upgrade data packet to the device end, it also includes a security handshake, which specifically includes: The control terminal sends a start frame to the device end, and the start frame includes the firmware size, device ID, and version number; The device end receives the start frame, verifies whether the firmware size is within the preset range, whether the device ID matches, and whether the version number format is correct; If the verification passes, the device end returns a response frame to the control terminal, and the control terminal starts data transmission.
[0008] Preferably, the control terminal and the device end communicate through the CAN protocol, and the method further includes: Before sending the firmware upgrade data packet of each version, the control terminal detects the load rate of the CAN bus, adjusts the size of the sub-packet data packet according to the load rate of the CAN bus, and then sequentially sends the sub-packet data packets to the device end.
[0009] Preferably, the external Flash is also divided into a reserved area, each sub-packet data packet includes a packet index, data length, and upgrade data, and the method further includes: The device end performs data length verification when receiving the sub-packet data packet; If the verification passes, the device end writes the sub-packet data packet into the backup area of the application software program and returns the write status code of the sub-packet data packet to the control terminal, and the control terminal sends the next sub-packet data packet according to the next status code of the write status code; If the verification fails, the device end writes the sub-packet data packet into the reserved area, and the control terminal resends the sub-packet data packet.
[0010] Preferably, the storage structure of the backup area of the application software program includes a version number, firmware size, CRC verification value, and upgrade data area. The device end obtains the firmware upgrade data packet sent by the control terminal and writes it into the backup area of the application software program, and performs a complete data verification after the writing is completed, including: After sending the firmware upgrade data packet, the control terminal sends an end frame to the device terminal, and the end frame includes the firmware size and the CRC check value; The device terminal receives the end frame and checks whether the firmware size and the CRC check value are consistent with the data in the application software program backup area.
[0011] Preferably, for different application software program backup areas, the length of the upgrade data area is dynamically adjusted according to the size of the firmware upgrade data packet written therein, and the space ratio of the reserved area is dynamically adjusted.
[0012] Preferably, the device terminal is equipped with a Bluetooth chip, and the method further includes: Sending an upgrade instruction via Bluetooth, where the upgrade instruction includes a version number, and selecting the corresponding firmware upgrade data packet for backup from multiple application software program backup areas according to the version number for upgrade.
[0013] Preferably, the application software program backup area is further divided into a log area and a system configuration area, where the log area is used to store the working data of the device terminal, and the system configuration area is used to store the system data of the device terminal.
[0014] According to the second aspect of the present application, a firmware upgrade backup system based on an external Flash is proposed, which is used to back up the firmware upgrade data packet sent by the control terminal to the external Flash of the device terminal and transfer it to the built-in Flash of the device terminal for upgrade. The built-in Flash is divided into a bootloader area and an application software program area, and the external Flash is divided into at least two application software program backup areas; The system includes: A data transmission module configured to enable the device terminal to obtain the firmware upgrade data packet sent by the control terminal and write it into the application software program backup area, and perform a complete data check after the writing is completed; An upgrade module configured to, in response to passing the check, the bootloader area obtains the storage address of the firmware upgrade data packet in the application software program backup area and writes it into the application software program area to perform firmware upgrade; A multi-version management module configured to repeatedly write different versions of firmware upgrade data packet backups to different application software program backup areas and overwrite the writing to the application software program area to implement multi-version firmware upgrade backup.
[0015] According to a third aspect of the present application, an embedded device is provided, including: one or more processors; a memory for storing one or more programs, which when executed by the one or more processors, cause the embedded device to implement the external Flash-based firmware upgrade and backup method provided in any implementation manner of the first aspect above.
[0016] According to a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, it implements the external Flash-based firmware upgrade and backup method provided in any implementation manner of the first aspect above.
[0017] The present application provides an external Flash-based firmware upgrade and backup method, system and storage medium. By introducing an external Flash and dividing the original built-in Flash on the device side into a bootloader area and an application software program area, and dividing the external Flash into a log area, a system configuration area, multiple application software program backup areas and a reserved area. Among them, the application software program backup area adopts a storage structure of version number + firmware size + CRC check value + upgrade data area, which realizes independent storage backup and upgrade of multiple firmware versions, and at the same time realizes dynamic management and efficient utilization of storage space, avoiding waste caused by static division of storage space.
[0018] During the process of the control terminal writing the firmware upgrade data packet to the application software program backup area of the external Flash, before data transmission, a security handshake is performed to verify the firmware size, device ID and version number. During data transmission, the data length of each sub-packet data packet is verified in real time. After data transmission is completed, the firmware size and CRC check value are verified. By implementing different-dimensional verifications in three stages respectively, the reliability of the upgrade process is significantly improved, effectively avoiding the problem of upgrade failure caused by data transmission errors.
[0019] During the data transmission stage of each version of the firmware upgrade data packet, by detecting the load rate of the CAN bus, the size of the sub-packet data packet is adaptively adjusted, thereby greatly improving the average transmission rate, and at the same time reducing the packet loss rate under low-quality communication channel conditions. And, by integrating a Bluetooth chip on the device side and sending upgrade instructions through Bluetooth, it is possible to select a specified version of the firmware upgrade data packet for upgrade, providing developers with the ability to flexibly roll back versions and build a test environment, greatly improving the development and debugging efficiency. Brief Description of the Drawings
[0020] The accompanying drawings are included to provide a further understanding of the embodiments and are incorporated in and constitute a part of this specification. The drawings illustrate the embodiments and, together with the description, are used to explain the principles of the invention. Other embodiments and many of the intended advantages of the embodiments will be readily apparent, as they become better understood by reference to the following detailed description. The elements of the drawings are not necessarily to scale with each other. The same reference numerals refer to corresponding like parts.
[0021] Figure 1 is a flowchart of a firmware upgrade backup method based on an external Flash according to a specific embodiment of the present application; Figure 2 is a schematic diagram of Flash area division according to a specific embodiment of the present application; Figure 3 is a schematic diagram of a firmware upgrade backup system based on an external Flash according to a specific embodiment of the present application; Figure 4 is a schematic diagram of an embedded device according to a specific embodiment of the present application. Detailed Description of the Specific Embodiments
[0022] The features and exemplary embodiments of various aspects of the present invention will be described in detail below. To make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present invention and are not configured to limit the present invention. For those skilled in the art, the present invention can be implemented without some of these specific details. The following description of the embodiments is only to provide a better understanding of the present invention by showing examples of the present invention.
[0023] It should be noted that, in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device including a series of elements not only includes those elements but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, the elements defined by the statement "including..." do not exclude the existence of additional identical elements in the process, method, article or device including the elements.
[0024] The present application proposes a firmware upgrade backup method based on an external Flash. Figure 1The flowchart of the firmware upgrade backup method based on an external Flash according to a specific embodiment of the present application is shown. As Figure 1 shown, the method includes the following steps: Step S101: Divide the built-in Flash of the device side into a bootloader area and an application software program area, and divide the external Flash into at least two application software program backup areas.
[0025] In a specific embodiment, the device side consists of a main control MCU and an external Flash to form a core hardware platform. Among them, the capacity of the external Flash can be flexibly configured according to application requirements and is connected to the main control MCU through an SPI interface.
[0026] Figure 2 The schematic diagram of Flash area division according to a specific embodiment of the present application is shown. As Figure 2 shown, in a specific embodiment, according to the functional responsibilities, the built-in Flash of the main control MCU is divided into a bootloader area (Bootloader area) and an application software program area (App area or Program area). Among them, the bootloader area is used to store the boot firmware of the loader, and the application software program area is used to store the program firmware of the device side. The external Flash is divided into a log area, a system configuration area, multiple application software program backup areas (App backup area or Program backup area), and a reserved area. Among them, the log area is used to store the working data of the device side, the system configuration area is used to store the system data of the device side, sensor parameters, etc., multiple application software program backup areas are respectively used to back up firmware upgrade data packets of different versions, and the reserved area is used for subsequent function development and other purposes.
[0027] In a specific embodiment, the storage structure of each application software program backup area includes a 4-byte version number, a 4-byte firmware size, a 4-byte CRC check value, and a variable-length upgrade data area, as shown in Table 1 below:
[0028] Since the sizes of firmware upgrade data packets of different versions are different, in this embodiment, for different application software program backup areas, the length of the upgrade data area is dynamically adjusted according to the size of the firmware upgrade data packet written into it, and the reserved area also dynamically adjusts the space ratio according to the sizes of all the application software program backup areas finally. Thus, the external Flash realizes the dynamic management and efficient utilization of the storage space, and avoids the waste of static division of the storage space.
[0029] In this embodiment, the external Flash stores firmware upgrade data packets of different versions in the form of dynamic overwrite, so the size of the entire application software program backup area will change dynamically with the writing of the new version firmware upgrade data packet.
[0030] In this embodiment, the version number uses semantic encoding (major version.minor version.revision number.build number), and the CRC check value covers the entire firmware upgrade data part.
[0031] Step S102: The device side obtains the firmware upgrade data packet sent by the control terminal and writes it into the application software program backup area, and performs a complete data check after the writing is completed.
[0032] In a specific embodiment, the host computer serves as the control terminal and supports communicating with the device side through interfaces such as USB, UART, or Bluetooth. In this embodiment, the control terminal and the device side communicate through the CAN protocol, and the control terminal and the device side use packet-by-packet transmission. The firmware upgrade data packet is divided into multiple sub-packet data packets, and the control terminal sequentially sends the sub-packet data packets to the device side through the CAN protocol.
[0033] In a specific embodiment, before the control terminal sends the firmware upgrade data packet of each version, the control terminal will first detect the load rate of the CAN bus, adjust the size of the sub-packet data packet according to the load rate of the CAN bus, and then sequentially send the sub-packet data packets to the device side. By adaptively adjusting the size of the sub-packet data packet, the average transmission rate can be greatly improved, and at the same time, the packet loss rate is reduced under the condition of a low-quality communication channel.
[0034] In a specific embodiment, before the control terminal sends the firmware upgrade data packet of each version to the device side, it also includes a security handshake, which specifically includes: The control terminal sends a start frame to the device side, and the start frame includes the firmware size, device ID, and version number; The device side receives the start frame and checks whether the firmware size is within the preset minimum and maximum ranges, whether the device ID matches, and whether the version number format is correct; If the check passes, the device side returns a response frame to the control terminal, and the control terminal starts data transmission.
[0035] By performing a security handshake with three-level checks at the beginning stage of data transmission, the reliability of the upgrade process is improved, and the problem of upgrade failure caused by data transmission errors is effectively avoided.
[0036] In a specific embodiment, each sub-packet data packet includes a packet index, data length, and upgrade data. During the process of the control terminal sequentially sending the sub-packet data packets to the device side, the device side performs a data length check every time it receives a sub-packet data packet, which specifically includes: 1. The device side performs a data length check when receiving the sub-packet data packet; 2. If the verification passes, the device side writes the sub-packet data packet into the upgrade data area of the application software program backup area, and returns the write status code of the sub-packet data packet to the control terminal. The control terminal sends the next sub-packet data packet according to the next status code of the write status code. 3. If the verification fails, the device side writes the sub-packet data packet into the reserved area, and the control terminal re-sends the sub-packet data packet.
[0037] By verifying the data length of each sub-packet data packet in real time during the data transmission process and adding a failure retransmission mechanism, the reliability of the upgrade process is improved, and the problem of upgrade failure caused by data transmission errors is effectively avoided. Moreover, the sub-packet data packets that fail the verification are stored in the reserved area, and subsequent developers can find the sub-packet data packets in the reserved area for comparison and analyze the reasons for the upgrade failure.
[0038] In a specific embodiment, after the control terminal sends the last sub-packet data packet of the firmware upgrade data packet of the current version to the device side, a complete data verification is required, specifically including: 1. After sending the firmware upgrade data packet, the control terminal sends an end frame to the device side. The end frame includes the firmware size and the CRC check value. 2. The device side receives the end frame and verifies whether the firmware size and the CRC check value are consistent with the firmware size and the actual CRC check value stored in the application software program backup area.
[0039] By performing a complete data verification after the data transmission is completed, the reliability of the upgrade process is improved, and the problem of upgrade failure caused by data transmission errors is effectively avoided.
[0040] Therefore, during the process of the control terminal writing the firmware upgrade data packet to the application software program backup area of the external Flash, by implementing different-dimensional verifications in three stages: before data transmission, during data transmission, and after data transmission is completed, the reliability of the upgrade process is significantly improved, and the problem of upgrade failure caused by data transmission errors is effectively avoided.
[0041] Step S103: In response to the verification passing, the bootloader area obtains the storage address of the firmware upgrade data packet in the application software program backup area, writes it into the application software area, and performs the firmware upgrade.
[0042] In a specific embodiment, after the complete data verification is completed, the bootloader area obtains the storage address of the firmware upgrade data packet in the application software program backup area, that is, the address of the upgrade data area, and then writes the packets one by one to the application software program area in the built-in Flash, executes the firmware upgrade process, and records the status flag in real time to support exception recovery. After all the data is written, the system is restarted, and the bootloader area jumps to the start address of the application software program area to execute the new version of the firmware program.
[0043] Step S104: Repeatedly write different versions of the firmware upgrade data packets to different application software program backup areas and overwrite and write them to the application software program area to achieve multi-version firmware upgrade backup.
[0044] In a specific embodiment, every time the control terminal writes a version of the firmware upgrade data packet to the application software program backup area of the external Flash, the device side will move it to the built-in Flash and execute an upgrade once, and the old version of the firmware upgrade data packet will be dynamically overwritten and saved in the external Flash. Thus, compared with the traditional solution which is limited by the capacity of the built-in Flash of the main control MCU and usually can only save 1-2 firmware versions and cannot meet the requirement of saving multiple historical versions during the development and debugging stage, the innovative design of the external Flash storage structure in this embodiment can realize independent storage backup and upgrade of multiple firmware versions.
[0045] Step S105: Send an upgrade instruction via Bluetooth. The upgrade instruction includes the version number, and the corresponding backup firmware upgrade data packet is selected from multiple application software program backup areas for upgrade according to the version number.
[0046] In a specific embodiment, the device side is equipped with a Bluetooth chip, and can be connected to the device side Bluetooth through an electronic device such as a mobile phone to send an upgrade instruction to complete the firmware upgrade of the specified version number, thus providing developers with the ability of flexible version switching / rollback and test environment setup, and greatly improving the development and debugging efficiency.
[0047] It should be noted that in other embodiments, it is also possible to set physical buttons on the device side. The device side detects the physical button operation and selects the corresponding backup firmware upgrade data packet from multiple application software program backup areas for firmware upgrade version switching; or an automatic rollback mechanism can be set. When it is detected that the new version of the firmware abnormally interrupts during the upgrade process, the previous version of the firmware upgrade data packet is selected from multiple application software program backup areas for firmware upgrade version switching.
[0048] In summary, the present application proposes a firmware upgrade backup method based on an external Flash, which at least has the following beneficial effects: 1. By introducing an external Flash, the built-in Flash of the original device-side main control MCU is divided into a bootloader area and an application software program area, and the external Flash is divided into a log area, a system configuration area, multiple application software program backup areas, and a reserved area. Among them, the application software program backup area adopts a storage structure of version number + firmware size + CRC check value + upgrade data area with variable length. While realizing the independent storage backup and upgrade of multiple firmware versions, it also realizes the dynamic management and efficient utilization of storage space, avoiding the waste of static division of storage space.
[0049] 2. During the process of the control terminal writing the firmware upgrade data packet to the application software program backup area of the external Flash, before data transmission, a security handshake is performed to verify the firmware size, device ID, and version number. During data transmission, the data length of each sub-packet is verified in real time. After data transmission is completed, a complete data verification is performed to verify the firmware size and CRC check value. By implementing different-dimensional verifications in three stages respectively, the reliability of the upgrade process is significantly improved, effectively avoiding the problem of upgrade failure caused by data transmission errors.
[0050] 3. During the data transmission stage of each version of the firmware upgrade data packet, by detecting the load rate of the CAN bus, the size of the sub-packet is adaptively adjusted, thus greatly improving the average transmission rate. At the same time, the packet loss rate is reduced under the condition of a low-quality communication channel. And, by integrating a Bluetooth chip on the device side, the upgrade instruction is sent via Bluetooth, and the firmware upgrade data packet of the specified version can be selected for upgrade, providing developers with the ability to flexibly roll back versions and build a test environment, greatly improving the development and debugging efficiency.
[0051] Based on the above firmware upgrade and backup method based on external Flash, and based on the same inventive concept, the present application also proposes a firmware upgrade and backup system based on external Flash, which is used to back up the firmware upgrade data packet sent by the control terminal to the external Flash on the device side and transfer it to the built-in Flash on the device side for upgrade. The built-in Flash is divided into a bootloader area and an application software program area, and the external Flash is divided into at least two application software program backup areas.
[0052] Figure 3 FIG. shows a schematic diagram of a firmware upgrade and backup system based on external Flash according to a specific embodiment of the present application, as Figure 3 shown, the system includes: A data transmission module 201, configured to enable the device side to obtain the firmware upgrade data packet sent by the control terminal and write it into the application software program backup area, and perform a complete data verification after the writing is completed.
[0053] The upgrade module 202 is configured to, in response to passing the verification, guide the bootloader area to obtain the storage address of the firmware upgrade data packet in the application software program backup area, write it into the application software program area, and perform firmware upgrade.
[0054] The multi-version management module 203 is configured to repeatedly write different versions of the firmware upgrade data packet backups to different application software program backup areas and overwrite and write them to the application software program area to implement multi-version firmware upgrade backup.
[0055] In a specific embodiment, the device board is equipped with a Bluetooth chip, and the system further includes: The version selection module 204 is configured to send an upgrade instruction through Bluetooth. The upgrade instruction includes a version number, and based on the version number, select the corresponding firmware upgrade data packet backup for upgrade from multiple application software program backup areas.
[0056] Based on the above firmware upgrade backup method based on an external Flash, based on the same inventive concept, the present application also proposes an embedded device.
[0057] Figure 4 The schematic diagram of the embedded device according to a specific embodiment of the present application is shown, as Figure 4 shown, the embedded device includes: one or more processors 301, a memory 302, a bus 303, and a communication interface 304. Among them, one or more processors 301, the memory 302, and the communication interface 304 are connected through the bus 303. The memory 302 is used to store one or more programs. When the one or more programs are executed by the one or more processors 301, the embedded device implements the firmware upgrade backup method based on an external Flash provided in any of the above embodiments.
[0058] Based on the above firmware upgrade backup method based on an external Flash, based on the same inventive concept, the present application also proposes a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the firmware upgrade backup method based on an external Flash provided in any of the above embodiments.
[0059] In the embodiments of the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the above-described device / system / method embodiments are merely illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the units or modules can be in an electrical or other form.
[0060] The unit described as a separating component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or distributed over multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0061] In addition, each functional unit in various embodiments of the present invention may be integrated in a processing unit, may exist separately as individual physical units, or two or more units may be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0062] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs and other various media that can store program codes.
[0063] Obviously, those skilled in the art can make various modifications and changes to the embodiments of the present invention without departing from the spirit and scope of the present invention. In this way, if these modifications and changes are within the scope of the claims of the present invention and their equivalent forms, the present invention also aims to cover these modifications and changes. The word "comprising" does not exclude the presence of other elements or steps not listed in the claims. The simple fact that certain measures are recited in mutually different dependent claims does not indicate that a combination of these measures cannot be used to advantage. Any reference signs in the claims should not be construed as limiting the scope.
Claims
1. An external Flash-based firmware upgrade and backup method, characterized in that, Including: The built-in Flash of the device side is divided into a bootloader area and an application software program area, and the external Flash is divided into at least two application software program backup areas; The device side obtains the firmware upgrade data packet sent by the control terminal and writes it into the application software program backup area, and performs a complete data verification after the writing is completed; In response to passing the verification, the bootloader area obtains the storage address of the firmware upgrade data packet in the application software program backup area, writes it into the application software program area, and performs firmware upgrade; Repeat writing different versions of the firmware upgrade data packet for backup to different application software program backup areas, and overwrite and write it into the application software program area to realize multi-version firmware upgrade backup.
2. The method according to claim 1, characterized in that, Before the control terminal sends a fixed upgrade data packet to the device side, it also includes a security handshake, specifically including: The control terminal sends a start frame to the device side, and the start frame includes the firmware size, device ID, and version number; The device side receives the start frame, and verifies whether the firmware size is within a preset range, whether the device ID matches, and whether the version number format is correct; If the verification passes, the device side returns a response frame to the control terminal, and the control terminal starts data transmission.
3. The method according to claim 1, characterized in that, The control terminal and the device side communicate through the CAN protocol, and the method further includes: Before sending the firmware upgrade data packet of each version, the control terminal detects the load rate of the CAN bus, adjusts the size of the sub-packet data packet according to the load rate of the CAN bus, and then sequentially sends the sub-packet data packets to the device side.
4. The method according to claim 3, characterized in that, The external Flash is also divided to include a reserved area, and each sub-packet data packet includes a packet index, data length, and upgrade data. The method further includes: The device side performs data length verification when receiving the sub-packet data packet; If the verification passes, the device side writes the sub-packet data packet into the application software program backup area and returns the write status code of the sub-packet data packet to the control terminal. The control terminal sends the next sub-packet data packet according to the next status code of the write status code; If the verification fails, the device side writes the sub-packet data packet into the reserved area, and the control terminal resends the sub-packet data packet.
5. The method according to claim 4, characterized in that, The storage structure of the application software program backup area includes a version number, firmware size, CRC verification value, and upgrade data area. The device side obtains the firmware upgrade data packet sent by the control terminal and writes it into the application software program backup area, and performs a complete data verification after the writing is completed, including: After sending the firmware upgrade data packet, the control terminal sends an end frame to the device side, and the end frame includes the firmware size and CRC verification value; The device side receives the end frame and verifies whether the firmware size and CRC verification value are consistent with the data in the application software program backup area.
6. The method according to claim 5, characterized in that, For different application software program backup areas, dynamically adjust the length of the upgrade data area according to the size of the firmware upgrade data packet written into it, and dynamically adjust the space occupancy ratio of the reserved area.
7. The method according to claim 5, characterized in that, The device side is equipped with a Bluetooth chip, and the method further includes: Send upgrade instructions via Bluetooth. The upgrade instructions include a version number, and a firmware upgrade data packet corresponding to the backup is selected from multiple application software program backup areas according to the version number for upgrade.
8. The method according to claim 1, characterized in that, The application software program backup area is further divided into a log area and a system configuration area. The log area is used to store the working data of the device end, and the system configuration area is used to store the system data of the device end.
9. An external Flash-based firmware upgrade and backup system, characterized in that, It is used to back up the firmware upgrade data packet sent by the control terminal to the external Flash of the device end and transfer it to the built-in Flash of the device end for upgrade. The built-in Flash is divided into a bootloader area and an application software program area, and the external Flash is divided into at least two application software program backup areas; The system includes: A data transmission module configured to cause the device end to obtain the firmware upgrade data packet sent by the control terminal and write it into the application software program backup area, and perform a complete data check after the writing is completed; An upgrade module configured to, in response to passing the check, the bootloader area obtains the storage address of the firmware upgrade data packet in the application software program backup area and writes it into the application software program area to perform firmware upgrade; A multi-version management module configured to repeatedly write backup firmware upgrade data packets of different versions to different application software program backup areas and overwrite and write them into the application software program area to implement multi-version firmware upgrade backup.
10. An embedded device, characterized in that, It includes: One or more processors; A memory for storing one or more programs, which when executed by the one or more processors cause the embedded device to implement the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, on which a computer program is stored, characterized in that, When the program is executed by the processor, it implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Remote upgrade method and remote upgrade device for wireless sensor network node
CN105573810A
Controller and software upgrading method and device thereof
CN110134415A
MCU firmware upgrading method of heterogeneous acceleration platform and related device
CN110389778A
Vehicle system upgrading method and device, computer equipment and storage medium
CN113672258A
ECU (Electronic Control Unit) non-inductive upgrade flashing method and device, electronic equipment and storage medium
CN116594660A
Cited By
Beverage equipment and firmware updating method thereof
CN120508308A
Beverage device and firmware update method thereof
CN120508308B