Embedded device software hot update method and system
By receiving and parsing update packets, building a hash collision table, determining the location of the update function, and using data buffer memory to achieve hot updates, it solves the problems of cumbersome and inflexible traditional embedded software update methods, and realizes the embedded device's Dynamic update capability.
Patent Information
- Application Number
- CN202411212849.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-08
AI Technical Summary
Traditional embedded software update methods are cumbersome and lack flexibility. Especially for some embedded products, subsequent updates and upgrades cannot be made, and minor changes require recompilation of all code, limiting the flexibility of the device.
By receiving update packets transmitted by the host computer, parsing and performing security and integrity tests, building a hash collision table, determining the location of the update function, and implementing hot updates through the data buffer memory to avoid relying on other tools.
It realizes dynamic updates of embedded device software, solves the problems of update difficulties and lack of flexibility, and can self-modify and update software without relying on other tools.
Smart Images

Figure CN118916061A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software updating, and in particular to a method and system for hot updating software of an embedded device. Background Art
[0002] There are two traditional embedded software update methods. One is direct download and installation. When the software needs to be updated, the source code is first compiled to generate the corresponding execution file, and then the burning tool is used to burn the file into the main control of the embedded system. The other method is to use a bootloder as a springboard. The embedded system always runs the bootloader program first. When an update is required, the above-mentioned execution file is transferred to the bootloder to implement the software update, such as the bootloader upgrade method, device, computer equipment and storage medium disclosed in the invention with publication number CN114546454A.
[0003] Both methods have various limitations. The first method makes software updates cumbersome and requires frequent use of hardware ports. For some embedded products, the interface is not exposed, which will make subsequent updates and upgrades impossible. The second method requires recompiling and linking all the codes to form a new executable file and transmit it to the target device for any minor changes, which limits the flexibility of the device. Summary of the invention
[0004] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a method and system for hot updating software of an embedded device, which can realize dynamic updating of software by self-modification without relying on other tools.
[0005] The purpose of the present invention can be achieved by the following technical solutions:
[0006] A method for hot updating software of an embedded device comprises the following steps:
[0007] Receive the update data packet transmitted by the host computer, parse the update data packet, and obtain the identification hash value, update address data and verification data;
[0008] Calculate the hash value of the identification and the hash value of the update address data, and compare them with the verification data to perform security and integrity verification. If the verification passes, obtain the size of the update address data;
[0009] Search for fixed feature codes and corresponding labels of each function in the embedded device software to obtain the corresponding function addresses; use a hash function to obtain a function table of corresponding hash values for searching the function addresses in the embedded device software;
[0010] According to the identification hash value, the corresponding function address in the embedded device software is determined through the function table, and it is judged whether the length of the update address data is greater than the data length of the corresponding function in the embedded device software. If it is less, the update address data is overwritten on the data of the corresponding function address; if it is greater, the update address data is stored through the data buffer address. If it cannot be stored, the hot update fails.
[0011] Furthermore, the process of storing the updated address data through the data buffer address is specifically as follows:
[0012] If the length of the unused data of the data buffer address is greater than the length of the update address data, the update address data is written to the data buffer address, and a command to jump to the data buffer address is written at the corresponding function position;
[0013] If the length of the unused data in the data buffer address is smaller than the length of the update address data, the hot update fails.
[0014] Furthermore, the fixed feature code and the label are used to locate the entry address of the function in the embedded device software.
[0015] Furthermore, the host computer transmits the update data packet via the CAN network.
[0016] Furthermore, the transmission communication rate of the CAN network ranges from 50 kbps to 1 Mbps.
[0017] The present invention also provides an embedded device software hot update system, comprising a host computer and an embedded device end, wherein the host computer is provided with a first CAN network communication module for transmitting an update data packet to the embedded device end via the CAN network;
[0018] The embedded device terminal includes:
[0019] A second CAN network communication module, used for receiving the update data packet transmitted by the first CAN network communication module;
[0020] The data parsing module is used to parse the update data packet to obtain the identification hash value, update address data and verification data;
[0021] A self-verification module, used to calculate the hash value of the identification and the hash value of the update address data, and compare them with the verification data to perform security and integrity verification. If the verification passes, the size of the update address data is obtained;
[0022] The identification and identification hash table module is used to search for the fixed feature code and the corresponding label of each function in the embedded device software to obtain the corresponding function address; the fixed feature code and the corresponding label are used to obtain the function table of the corresponding hash value by using the hash function, which is used to search for the function address in the embedded device software;
[0023] The update module is used to determine the corresponding function address in the embedded device software through the function table according to the identification hash value, and judge whether the length of the update address data is greater than the data length of the corresponding function in the embedded device software. If it is less, the update address data is overwritten on the data of the function address corresponding to the main memory; if it is greater, the update address data is stored in the data buffer memory through the data buffer address. If it cannot be stored, the hot update fails;
[0024] Main memory, used for data storage on the embedded device side;
[0025] Data buffer memory, used for buffer data storage on the embedded device side.
[0026] Furthermore, the process of storing the updated address data through the data buffer address is specifically as follows:
[0027] If the length of the unused data of the data buffer address is greater than the length of the update address data, the update address data is written to the data buffer address, and a command to jump to the data buffer address is written at the corresponding function position;
[0028] If the length of the unused data in the data buffer address is smaller than the length of the update address data, the hot update fails.
[0029] Furthermore, the fixed feature code and the label are used to locate the entry address of the function in the embedded device software.
[0030] Furthermore, the host computer transmits the update data packet via the CAN network.
[0031] Furthermore, the transmission communication rate of the CAN network ranges from 50 kbps to 1 Mbps.
[0032] Compared with the prior art, the present invention has the following advantages:
[0033] (1) The present invention identifies the location of each function in the embedded device software and constructs a hash collision table; reconstructs the data standard of the update data packet, compares the validation data with the hash value of the identification hash value and the hash value of the update address data, and implements security and integrity validation, thereby determining the corresponding update function location from the hash collision table according to the update address data, and determining whether the space can accommodate it. If it cannot accommodate it, a jump address table is set, and data is stored in a data buffer memory to implement hot update;
[0034] The overall solution implements hot update tasks by sending reconstructed data packets and the embedded device parsing the packets when there is a need for hot update. This effectively solves the problems of difficult and lack of flexibility in updating embedded software, and can realize dynamic updates of software by self-modification without relying on other tools. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram of a flow chart of a method for hot updating software of an embedded device provided in an embodiment of the present invention;
[0036] Figure 2 A schematic diagram of the framework of a hot update system for embedded device software provided in an embodiment of the present invention;
[0037] Figure 3 A schematic diagram of an update status of an embedded device software hot update system provided in an embodiment of the present invention;
[0038] Figure 4 The second schematic diagram is a updating status diagram of an embedded device software hot update system provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0040] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0042] Example 1
[0043] like Figure 1 As shown, this embodiment provides a method for hot updating software of an embedded device, comprising the following steps:
[0044] S1: Receive the update data packet transmitted by the host computer, parse the update data packet, and obtain the identification hash value, update address data and verification data;
[0045] S2: Calculate the hash value of the identification and the hash value of the updated address data, and compare them with the verification data to perform security and integrity verification. If the verification passes, obtain the size of the updated address data;
[0046] S3: Searching for fixed feature codes and corresponding labels of each function in the embedded device software to obtain corresponding function addresses; using a hash function to obtain a function table of corresponding hash values for searching for function addresses in the embedded device software;
[0047] S4: Determine the corresponding function address in the embedded device software through the function table according to the identification hash value, and judge whether the length of the update address data is greater than the data length of the corresponding function in the embedded device software. If it is less, overwrite the update address data onto the data of the corresponding function address; if it is greater, store the update address data through the data buffer address. If it cannot be stored, the hot update fails.
[0048] Specifically, in step S4, the process of updating the storage of address data through the data buffer address is as follows:
[0049] If the length of the unused data of the data buffer address is greater than the length of the update address data, the update address data is written to the data buffer address, and a command to jump to the data buffer address is written at the corresponding function position;
[0050] If the length of the unused data in the data buffer address is smaller than the length of the update address data, the hot update fails.
[0051] The fixed feature code and label in step S3 are written into the header of the function to locate the entry address of the function in the embedded device software.
[0052] Preferably, the host computer transmits the update data packet via a CAN network, and the transmission communication rate of the CAN network ranges from 50 kbps to 1 Mbps.
[0053] The above method is equivalent to that when there is an update demand, the host computer sends an update data packet to the embedded device. When the embedded device receives the data, it parses the data table into the identification hash value, update address data, and verification data. Then the security of the data is identified, and the corresponding function address is found according to the incoming identification hash value. Then the update module carries out the task, and the data length of the corresponding function in the embedded device software is compared with the incoming update address data. When the length of the update address data is less than the data length of the corresponding function, the update address data is overwritten with the data of the corresponding function, and the update is successful; when the length of the update address data is greater than the data length of the corresponding function, if the length of the unused data of the data buffer address is less than the length of the update address data, the hot update fails; if the length of the unused data of the data buffer address is greater than the length of the update address data, the update address data is copied to the data buffer address, and the command to jump to the data buffer address is written at the corresponding function position, and the hot update is successful.
[0054] Example 2
[0055] like Figure 2 As shown, this embodiment provides an embedded device software hot update system, including a host computer and an embedded device end, the host computer is provided with a first CAN network communication module for transmitting an update data packet to the embedded device end through the CAN network;
[0056] The embedded device side includes:
[0057] A second CAN network communication module, used for receiving the update data packet transmitted by the first CAN network communication module;
[0058] The data parsing module is used to parse the update data packet to obtain the identification hash value, update address data and verification data;
[0059] The self-verification module is used to calculate the hash value of the identification and the hash value of the update address data, and compare them with the verification data to perform security and integrity verification. If the verification passes, the size of the update address data is obtained;
[0060] The identification and identification hash table module is used to search for the fixed feature code and the corresponding label of each function in the embedded device software to obtain the corresponding function address; the fixed feature code and the corresponding label are used to obtain the function table of the corresponding hash value by using the hash function, which is used to search for the function address in the embedded device software;
[0061] The update module is used to determine the corresponding function address in the embedded device software through the function table according to the identification hash value, and judge whether the length of the update address data is greater than the data length of the corresponding function in the embedded device software. If it is less, the update address data is overwritten on the data of the function address corresponding to the main memory; if it is greater, the update address data is stored in the data buffer memory through the data buffer address. If it cannot be stored, the hot update fails;
[0062] Main memory, used for data storage on the embedded device side;
[0063] Data buffer memory, used for buffer data storage on the embedded device side.
[0064] The specific process of the update module storing the update address data through the data buffer address is as follows:
[0065] If the length of the unused data of the data buffer address is greater than the length of the update address data, the update address data is written to the data buffer address, and a command to jump to the data buffer address is written at the corresponding function position;
[0066] If the length of the unused data in the data buffer address is smaller than the length of the update address data, the hot update fails.
[0067] The fixed signature and label are written into the header of the function and are used to locate the entry address of the function in the embedded device software.
[0068] The working process of the above embedded device software hot update system is specifically as follows:
[0069] When the host computer uses the CAN network to transmit the update data packet to the embedded device, the data parsing module starts to work and parses the data packet content into three parts: identification hash value, update address data, and verification data. The data then reaches the self-verification module, which compares the identification hash value in the data packet and the hash value of the update address data with the verification data in the data packet; and counts the size of the update address data. Then enter the identification and identification hash table module, search for the fixed feature code, obtain its function address, use the hash function to obtain the function table of the corresponding hash value for the fixed feature code and the label, find the corresponding function address through the identification hash value, and enter the update module.
[0070] like Figure 3 The figure shows a schematic diagram of the update situation of a hot update method for embedded device software. When the length of the update address data is less than the data length of the corresponding function, the update address data is overwritten with the data of the corresponding function to complete the update task;
[0071] like Figure 4The figure shows a second schematic diagram of the update situation of a hot update method for embedded device software. When the length of the update address data is greater than the data length of the corresponding function, if the length of the unused data of the data buffer address is greater than the length of the update address data, the update address data is copied to the data buffer address, and a jump to the data buffer address command is written at the corresponding function position; if the length of the unused data of the data buffer address is less than the length of the update address data, the hot update fails.
[0072] Preferably, the host computer transmits the update data packet via a CAN network, and the transmission communication rate of the CAN network ranges from 50 kbps to 1 Mbps.
[0073] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A method for hot updating software of an embedded device, characterized in that: The following steps are involved: Receive the update data packet transmitted by the host computer, parse the update data packet, and obtain the identification hash value, update address data and verification data; Calculate the hash value of the identification and the hash value of the update address data, and compare them with the verification data to perform security and integrity verification. If the verification passes, obtain the size of the update address data; Search for fixed feature codes and corresponding labels of each function in the embedded device software to obtain the corresponding function addresses; use a hash function to obtain a function table of corresponding hash values for searching the function addresses in the embedded device software; According to the identification hash value, the corresponding function address in the embedded device software is determined through the function table, and it is judged whether the length of the update address data is greater than the data length of the corresponding function in the embedded device software. If it is less, the update address data is overwritten on the data of the corresponding function address; if it is greater, the update address data is stored through the data buffer address. If it cannot be stored, the hot update fails.
2. The method for hot updating software of an embedded device according to claim 1, characterized in that: The process of storing the updated address data through the data buffer address is specifically as follows: If the length of the unused data of the data buffer address is greater than the length of the update address data, the update address data is written to the data buffer address, and a command to jump to the data buffer address is written at the corresponding function position; If the length of the unused data in the data buffer address is smaller than the length of the update address data, the hot update fails.
3. The method for hot updating software of an embedded device according to claim 1, characterized in that: The fixed characteristic code and the label are used to locate the entry address of the function in the embedded device software.
4. The method for hot updating software of an embedded device according to claim 1, characterized in that: The host computer transmits update data packets via the CAN network.
5. The method for hot updating software of an embedded device according to claim 4, characterized in that: The transmission communication rate of the CAN network ranges from 50 kbps to 1 Mbps.
6. A hot update system for embedded device software, characterized in that: It includes a host computer and an embedded device end, wherein the host computer is provided with a first CAN network communication module for transmitting an update data packet to the embedded device end via the CAN network; The embedded device terminal includes: A second CAN network communication module, used for receiving the update data packet transmitted by the first CAN network communication module; The data parsing module is used to parse the update data packet to obtain the identification hash value, update address data and verification data; A self-verification module, used to calculate the hash value of the identification and the hash value of the update address data, and compare them with the verification data to perform security and integrity verification. If the verification passes, the size of the update address data is obtained; The identification and identification hash table module is used to search for the fixed feature code and the corresponding label of each function in the embedded device software to obtain the corresponding function address; the fixed feature code and the corresponding label are used to obtain the function table of the corresponding hash value by using the hash function, which is used to search for the function address in the embedded device software; The update module is used to determine the corresponding function address in the embedded device software through the function table according to the identification hash value, and judge whether the length of the update address data is greater than the data length of the corresponding function in the embedded device software. If it is less, the update address data is overwritten on the data of the function address corresponding to the main memory; if it is greater, the update address data is stored in the data buffer memory through the data buffer address. If it cannot be stored, the hot update fails; Main memory, used for data storage on the embedded device side; Data buffer memory, used for buffer data storage on the embedded device side.
7. The embedded device software hot update system according to claim 6, characterized in that: The process of storing the updated address data through the data buffer address is specifically as follows: If the length of the unused data of the data buffer address is greater than the length of the update address data, the update address data is written to the data buffer address, and a command to jump to the data buffer address is written at the corresponding function position; If the length of the unused data in the data buffer address is smaller than the length of the update address data, the hot update fails.
8. The embedded device software hot update system according to claim 6, characterized in that: The fixed characteristic code and the label are used to locate the entry address of the function in the embedded device software.
9. The embedded device software hot update system according to claim 6, characterized in that: The host computer transmits update data packets via the CAN network.
10. The embedded device software hot update system according to claim 9, characterized in that: The transmission communication rate of the CAN network ranges from 50 kbps to 1 Mbps.
