Differential upgrade method, system and medium based on Flash page alignment
By directly writing the page upgrade point in the differential upgrade method of Flash page alignment, the problem of high memory consumption of differential firmware upgrade is solved, efficient firmware upgrade in resource-constrained devices is realized, and the upgrade speed and application scope are improved. .
Patent Information
- Application Number
- CN202311669932.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-07
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2043-12-07
AI Technical Summary
The existing differential firmware upgrade method requires a large memory space to restore the full firmware, which limits its application in resource-constrained terminal devices.
The differential upgrade method based on Flash page alignment is adopted. By receiving and writing the page upgrade points in the differential firmware, it is written directly in the Flash storage space, avoiding the need to cache the differential firmware and significantly reducing memory consumption.
It realizes efficient firmware upgrade in resource-constrained terminal devices, reduces memory consumption, broadens the application scope of differential upgrade, and improves the upgrade speed.
Smart Images

Figure CN117648109B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of firmware upgrade, and in particular to a differential upgrade method, system and medium based on a Flash page alignment mode. Background Art
[0002] Existing firmware upgrades are mainly divided into full upgrades and differential upgrades. Full upgrades are to send all firmware to the device to be upgraded. The advantage is that the upgrade protocol is simple and many file transfer protocols can be used. The disadvantage is that as long as the firmware is modified a little, the entire firmware needs to be upgraded, the upgrade speed is slow, and excessive traffic consumption or network bandwidth is wasted. This full upgrade method is mainly used in scenarios where the firmware size is small and the upgrade speed is not required. In order to solve the shortcomings of full firmware upgrades, differential upgrades were subsequently introduced. As the name suggests, the firmware to be upgraded and the firmware running on the device are subtracted to generate a differential firmware, and then the firmware is compressed and sent to the device to be upgraded. The device to be upgraded receives the firmware and decompresses it and combines it with the terminal-side firmware to restore the new full firmware. The advantages of this differential upgrade are that the firmware size is small, the upgrade speed is fast, and the traffic or bandwidth resources are significantly reduced. The disadvantage is that the firmware requires the terminal device to be upgraded to support the decompression algorithm, and a large memory space is required to restore the new full firmware, which has a large requirement for the memory space of the terminal device to be upgraded. This differential upgrade method is mainly used in scenarios where the firmware size is large and the upgrade time is required. That is, the above differential upgrade method can only be applied to terminal devices to be upgraded with abundant resources (especially memory resources). Summary of the invention
[0003] The embodiments of the present invention provide a differential upgrade method, system and medium based on a Flash page alignment mode, aiming to solve the problem that the existing differential upgrade method causes excessive memory consumption of a terminal device to be upgraded.
[0004] In a first aspect, an embodiment of the present invention provides a differential upgrade method based on a Flash page alignment method, comprising:
[0005] If the IoT platform receives the differential firmware uploaded by the differential terminal device, it initiates a firmware upgrade request to the terminal device to be upgraded, wherein the differential firmware includes firmware header information and an upgrade cluster, and the upgrade cluster includes at least one page upgrade point;
[0006] The terminal device to be upgraded returns upgrade permission information and reports firmware transmission information to the Internet of Things platform;
[0007] The IoT platform verifies the firmware transmission information to obtain a verification result. If the verification result is passed, the firmware header information is sent to the terminal device to be upgraded.
[0008] The Internet of Things platform sends the firmware data block information in the page upgrade point to the terminal device to be upgraded according to the page upgrade point information requested by the terminal device to be upgraded;
[0009] If the terminal device to be upgraded detects that the page upgrade point is received, the page upgrade point is written into the Flash storage space according to the firmware transmission information and the firmware header information;
[0010] If the terminal device to be upgraded detects that the differential firmware is transmitted and written into the Flash storage space, a differential upgrade result is generated according to the full firmware after the differential upgrade and the firmware header information, and the differential upgrade result is reported to the Internet of Things platform.
[0011] In a second aspect, an embodiment of the present invention further provides a differential upgrade system based on Flash page alignment, which includes: a receiving initiating unit, a verification sending unit and a receiving sending unit configured in an Internet of Things platform, a return reporting unit, a detection writing unit and a detection generating unit configured in a terminal device to be upgraded, wherein:
[0012] The receiving and initiating unit is used for initiating a firmware upgrade request to the terminal device to be upgraded if the IoT platform receives the differential firmware uploaded by the differential terminal device, wherein the differential firmware includes firmware header information and an upgrade cluster, and the upgrade cluster includes at least one page upgrade point;
[0013] The return reporting unit is used for the terminal device to be upgraded to return the upgrade permission information and report the firmware transmission information to the Internet of Things platform;
[0014] The verification and sending unit is used for the IoT platform to verify the firmware transmission information to obtain a verification result. If the verification result is a verification pass, the firmware header information is sent to the terminal device to be upgraded.
[0015] The receiving and sending unit is used for the Internet of Things platform to send the firmware data block information in the page upgrade point to the terminal device to be upgraded according to the page upgrade point information requested by the terminal device to be upgraded;
[0016] The detection writing unit is used for, if the terminal device to be upgraded detects that the page upgrade point has been received, to write the page upgrade point into the Flash storage space according to the firmware transmission information and the firmware header information;
[0017] The detection generation unit is used for generating a differential upgrade result according to the full firmware after the differential upgrade and the firmware header information if the terminal device to be upgraded detects that the differential firmware has been transmitted and written into the Flash storage space, and reports the differential upgrade result to the Internet of Things platform.
[0018] In the third aspect, an embodiment of the present invention also provides a differential upgrade system based on Flash page alignment, which includes an Internet of Things platform and a terminal device to be upgraded, wherein the Internet of Things platform and the terminal device to be upgraded both include a memory and a processor, a computer program is stored in the memory, and the Internet of Things platform and the processor of the terminal device to be upgraded implement the above method when executing the computer program.
[0019] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program can implement the above method when executed by a processor.
[0020] The embodiment of the present invention provides a differential upgrade method, system and medium based on a Flash page alignment mode. The method includes: if the Internet of Things platform receives the differential firmware uploaded by the differential terminal device, a firmware upgrade request is initiated to the terminal device to be upgraded, wherein the differential firmware includes firmware header information and an upgrade cluster, and the upgrade cluster contains at least one page upgrade point; the terminal device to be upgraded returns the upgrade permission information and reports the firmware transmission information to the Internet of Things platform; the Internet of Things platform verifies the firmware transmission information to obtain a verification result, and if the verification result is that the verification passes, the firmware header information is sent to the terminal device to be upgraded; the Internet of Things platform sends the firmware data block information in the page upgrade point to the terminal device to be upgraded according to the page upgrade point information requested by the terminal device to be upgraded; if the terminal device to be upgraded detects that the page upgrade point is received, the page upgrade point is written into the Flash storage space according to the firmware transmission information and the firmware header information; if the terminal device to be upgraded detects that the differential firmware is transmitted and written into the Flash storage space, a differential upgrade result is generated according to the full firmware after the differential upgrade and the firmware header information, and the differential upgrade result is reported to the Internet of Things platform. In the technical solution of the embodiment of the present invention, after the terminal device to be upgraded receives the page upgrade point in the differential firmware issued by the Internet of Things platform, it can be immediately written into the Flash storage space, without the need to cache all the differential firmware, and then restore it to a new full firmware, and then write it into the Flash storage space, thereby significantly reducing the memory consumption of the terminal device to be upgraded. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0022] Figure 1A schematic diagram of a differential upgrade system based on Flash page alignment provided by an embodiment of the present invention;
[0023] Figure 2 It is a flow chart of a differential upgrade method based on Flash page alignment provided by an embodiment of the present invention;
[0024] Figure 3 is a schematic diagram of manufacturing the differential firmware provided by an embodiment of the present invention;
[0025] Figure 4 is a transmission schematic diagram of differential firmware provided by an embodiment of the present invention;
[0026] Figure 5 is a schematic diagram of writing differential firmware provided by an embodiment of the present invention;
[0027] Figure 6 is a timing diagram of differential firmware transmission provided by an embodiment of the present invention;
[0028] Figure 7 A schematic block diagram of a differential upgrade system based on Flash page alignment provided by an embodiment of the present invention;
[0029] Figure 8 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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. 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.
[0031] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0032] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0033] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0034] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0035] See also Figure 1 , Figure 1 Schematic diagram of a differential upgrade system based on Flash page alignment provided by an embodiment of the present invention. The differential upgrade system based on Flash page alignment includes an Internet of Things platform and a terminal device to be upgraded. The Internet of Things platform and the terminal device to be upgraded communicate with each other to send firmware header information and page upgrade points, and receive differential upgrade results. It should be noted that, if Figure 1 As shown, the differential upgrade system based on the Flash page alignment method also includes a differential terminal device, and the differential terminal device communicates with the Internet of Things platform to upload the differential firmware.
[0036] Figure 2 The flowchart of a differential upgrade method based on Flash page alignment provided by an embodiment of the present invention is shown in FIG. The differential upgrade method based on Flash page alignment provided by an embodiment of the present invention can be applied to a differential upgrade system based on Flash page alignment. For example, the differential upgrade method based on Flash page alignment can be implemented by a software program configured on the differential upgrade system based on Flash page alignment to reduce the memory consumption of the terminal device to be upgraded. Figure 2 As shown, the method includes the following steps S100-S150.
[0037] S100. If the Internet of Things platform receives differential firmware uploaded by a differential terminal device, it initiates a firmware upgrade request to the terminal device to be upgraded, wherein the differential firmware includes firmware header information and an upgrade cluster, and the upgrade cluster includes at least one page upgrade point.
[0038] In an embodiment of the present invention, before the differential terminal device uploads the differential firmware to the Internet of Things platform, it is necessary to perform firmware segmentation and production to obtain the differential firmware. Specifically, the differential terminal device compiles a custom link script file through an IDE to generate a new firmware, wherein the custom link script file uses a large rectangle to represent a firmware, the square in the large rectangle represents a Flash page, the number on the Flash page is a page code, and the custom link script file is used to store different codes or data in a separate Flash page; compare the differences between the new firmware and the old firmware page space data one by one according to the Flash page alignment method to mark the differential page blocks with differences, record the page code where each differential page block is located as a page upgrade point to obtain multiple page upgrade points, wherein the old fixed part is the firmware generated by the custom link script file before the functional module code is written by IDE compilation; the number of the page upgrade points, the Flash page size, the firmware base address, and the CRC16 checksum and firmware size of the new firmware are saved in the firmware header to generate firmware header information; the firmware header information and the multiple page upgrade points are packaged into the differential firmware. More specifically, Figure 3 As shown, each color represents a type of code or data, and X represents the Flash page that the new firmware modifies relative to the old firmware, that is, the page upgrade point.
[0039] It should be noted that, in this embodiment, the terminal firmware is generally based on Flash storage, and the firmware is loaded from Flash when powered on. IDE or other compilers use custom link scripts to generate compiled firmware for differential terminal devices. The functional module code or data written by the user will be randomly distributed in the entire target Flash space (for example: 0x0000~0x10000). If the user modifies a single functional module and upgrades the firmware, the differential package produced will be scattered in multiple discontinuous address spaces. It should be noted that the Flash memory is managed in a page manner, and the page address is continuous. The erasure and writing of data must be an integer multiple of the page. If there is a difference in one page of the firmware, the entire page needs to be erased and rewritten. In order to solve the problem that the firmware is scattered in Flash, the present invention rewrites the link script file and forces the user function module code or data to be stored in one or more continuous Flash page spaces. Then, according to the Flash page alignment method, the differences in the page space data are compared one by one. As long as there is a difference of at least one byte in the page space, the page is marked as a differential page block, and the Flash page address is recorded as a page upgrade point. After the comparison is completed, the new firmware's checksum (CRC16), firmware size, number of upgrade points, and firmware base address are saved in the firmware header. The firmware format is: firmware header information (firmware size + Flash page size + number of upgrade points + firmware base address + CRC16 checksum) + upgrade cluster (page upgrade point 1 + page upgrade point 2... page upgrade point n).
[0040] Furthermore, after the differential terminal device completes the differential firmware, it uploads the differential firmware to the Internet of Things platform. The Internet of Things platform receives the differential firmware and initiates a firmware upgrade request to the terminal device to be upgraded, wherein the differential firmware includes firmware header information and an upgrade cluster, and the upgrade cluster contains at least one page upgrade point.
[0041] S110: The terminal device to be upgraded returns upgrade permission information and reports firmware transmission information to the Internet of Things platform.
[0042] In an embodiment of the present invention, the terminal device to be upgraded receives a firmware upgrade request initiated by the Internet of Things platform, and returns upgrade permission information and reports firmware transmission information to the Internet of Things platform, wherein the firmware transmission information includes a single transmission firmware size and an upgrade Flash page size. It should be noted that in this embodiment, the existing differential firmware transmission uses file transfer protocol, HTTP, block transfer protocol, etc. The above protocols can realize breakpoint resumption and block transmission, etc., but since the present embodiment needs to use a receiving and storing solution, the traditional file or block transfer protocol cannot be used, so the block transfer protocol is redesigned. The firmware transmission protocol uses blocks as the basic unit, and the page upgrade point is decomposed into multiple transmission blocks according to negotiation. Each time a page upgrade point is completed, the terminal needs to complete a firmware storage.
[0043] S120: The Internet of Things platform verifies the firmware transmission information to obtain a verification result. If the verification result is that the verification passes, the firmware header information is sent to the terminal device to be upgraded.
[0044] In an embodiment of the present invention, the Internet of Things platform verifies the firmware transmission information to obtain a verification result. If the verification result is a verification pass, the firmware header information is sent to the terminal device to be upgraded. It is understandable that if the verification result is a verification failure, the differential upgrade process is stopped, and an error response message is sent to the terminal device to be upgraded. The Internet of Things platform verifies the firmware transmission information to obtain a verification result. Specifically, the Internet of Things platform compares the single transmission firmware size with the upgrade Flash page size; if the single transmission firmware size is smaller than the upgrade Flash page size, the upgrade Flash page size is compared with the Flash page size in the firmware header information in the differential firmware; if the upgrade Flash page size is consistent with the Flash page size, the verification result is set to pass the verification. It is understandable that if the single transmission firmware size is not less than the upgrade Flash page size and / or if the upgrade Flash page size is inconsistent with the Flash page size, the verification result is set to fail the verification.
[0045] S130. The Internet of Things platform sends the firmware data block information in the page upgrade point to the terminal device to be upgraded according to the page upgrade point information requested by the terminal device to be upgraded.
[0046] In the embodiment of the present invention, after receiving the firmware header information, the terminal device to be upgraded starts block transmission and requests page upgrade point information from the Internet of Things platform. The Internet of Things platform sends the firmware data block information in the page upgrade point to the terminal device to be upgraded according to the page upgrade point information. Specifically, Figure 4 As shown, the differential firmware includes four page upgrade points, namely page upgrade point 0, page upgrade point 1, page upgrade point 2 and page upgrade point 3. Page upgrade point 0, page upgrade point 1, page upgrade point 2 and page upgrade point 3 each include 3 firmware blocks. The 3 firmware blocks in page upgrade point 0 are respectively identified as page 1+block 0, page 1+block 1 and page 1+block 2; the 3 firmware blocks in page upgrade point 1 are respectively identified as page 3+block 0, page 3+block 1 and page 3+block 2; the 3 firmware blocks in page upgrade point 2 are respectively identified as page 6+block 0, page 6+block 1 and page 6+block 2; the 3 firmware blocks in page upgrade point 3 are respectively identified as page 14+block 0, page 14+block 1 and page 14+block 2. It can be seen that the firmware blocks in page 1, page 3, page 6 and page 14 in the terminal device to be upgraded need to be upgraded.
[0047] S140: If the terminal device to be upgraded detects that the page upgrade point has been received, the page upgrade point is written into a Flash storage space according to the firmware transmission information and the firmware header information.
[0048] In an embodiment of the present invention, the terminal device to be upgraded receives the firmware data block information, and if it is detected that the page upgrade point is received, the page upgrade point is written into the Flash storage space according to the firmware transmission information and the firmware header information, wherein the firmware header information includes the firmware base address. If the terminal device to be upgraded detects that the page upgrade point is received, the page code and block number in each firmware data block information in the page upgrade point are extracted; the Flash first address of the data block is located according to the page code, the block number, the firmware base address, the single transmission firmware size, and the upgrade Flash page size, and the firmware data block in the firmware data block information is written into the Flash storage space according to the Flash first address. Specifically, the Flash storage space is a single Flash storage space or a dual Flash storage space. If the Flash storage space is the single Flash storage space, the firmware data block in the firmware data block information is written into the old firmware full Flash storage space according to the Flash first address; if the Flash storage space is the dual Flash storage space, the old firmware full Flash storage space is copied to the backup Flash storage space, and the firmware data block is written into the backup Flash storage space according to the Flash first address. Specifically, Figure 5 As shown, the single firmware space upgrade is to write the received differential firmware directly into the Flash storage space, while the dual firmware space upgrade is to first copy the old firmware to the backup Flash storage space, and then write the received differential firmware directly into the backup Flash storage space. It should be noted that in this embodiment, whether to copy the backup Flash storage space to the Flash storage space can be determined according to actual needs.
[0049] S150: If the terminal device to be upgraded detects that the differential firmware is transmitted and written into the Flash storage space, a differential upgrade result is generated according to the full firmware after the differential upgrade and the firmware header information, and the differential upgrade result is reported to the Internet of Things platform.
[0050] In an embodiment of the present invention, if the terminal device to be upgraded detects that the differential firmware is transmitted and written into the Flash storage space, a differential upgrade result is generated according to the full firmware after the differential upgrade and the firmware header information. Specifically, the full firmware after the differential upgrade is verified by a CRC16 verification algorithm to obtain a verification code; the CRC16 verification code is compared with the verification code; if the CRC16 verification code is consistent with the verification code, the differential upgrade result is set to a differential upgrade success; if the CRC16 verification code is inconsistent with the verification code, the differential upgrade result is set to a differential upgrade failure. The differential upgrade result is reported to the Internet of Things platform.
[0051] See also Figure 6 , Figure 6 is a timing diagram of differential firmware transmission provided by an embodiment of the present invention. Figure 6 In the process, a. the IoT platform initiates a firmware upgrade request (carrying the new firmware version number); b. the terminal device to be upgraded responds to allow the upgrade, and reports the single transmission firmware size (single transmission block size should be less than or equal to the Flash page size) information and Flash page size information to constrain the IoT platform to subsequently transmit firmware blocks; if the reported single transmission firmware size and Flash page size information are wrong, the differential upgrade process is stopped and an error response message is issued; c. the IoT platform issues firmware header information (CRC16 checksum, Flash page size, firmware size, number of page upgrade points, firmware base address); d. the terminal device to be upgraded receives the firmware header information for subsequent verification, starts block transmission, and requests page upgrade point (page upgrade point ID + block ID) information; e. the IoT platform receives the request for page upgrade point information, and issues the firmware page upgrade point ID + block ID + firmware data block; f. repeat steps de to complete the reception of a single page upgrade point firmware, and complete a Flash page write to the Flash storage space;
[0052] Repeat step f to complete the transmission and writing of the entire differential firmware. The terminal device to be upgraded reports a transmission completion instruction, which includes the differential upgrade result.
[0053] It should be noted that, in this embodiment, the specific data frame format of the firmware transmission protocol is as follows: upgrade request frame (firmware upgrade request): 0x01 + firmware version number; upgrade request result frame (upgrade permission information and firmware transmission information): 0x02 + whether to allow upgrade (1 byte) + negotiation information [Flash page size (2 bytes) + negotiation block size information (1 byte)]; firmware information frame (firmware header information): 0x03 + CRC16 check code (2 bytes) + Flash page size (2 bytes) + firmware size Small (4 bytes) + number of upgrade points (2 bytes) + firmware base address (4 bytes); data request frame (page upgrade point information): 0x04 + page code (1 byte) + block number (1 byte); data response frame (firmware data block information): 0x05 + page code (1 byte) + block number (1 byte) + firmware block; error response frame: 0x06 + result code (1 byte) (1: page upgrade point error, 2: block number error); transmission end frame: 0x07 + transmission result (1 byte) (0: success, 1: failure). It should also be noted that after receiving the firmware data frame, the terminal device to be upgraded extracts the page code and block number, as well as the firmware base address provided by the firmware information frame, and the Flash page size and data block size information in the negotiation information frame, locates the Flash head address of the data block according to the five-tuple information, and then burns the firmware data into the Flash. For example, if the firmware base address is 0x800000, the page code is 0x07, the Flash page size is 4k, the block size is 1k, and the block code is 0x02, then the Flash address of the data block is 0x800000+0x07*4k+2k, that is, 0x807800. After generating the complete full firmware, the CRC16 algorithm is needed to perform integrity check on the full firmware after differential upgrade to generate the differential upgrade result.
[0054] Table 1 shows the comparison of memory and bandwidth resource usage of different solutions (differential upgrade solution based on Flash page alignment, differential upgrade and full upgrade in this embodiment), assuming that the old firmware is 100KB, the new firmware is 100KB, the differential firmware is 6KB, and the Flash page size is 4KB.
[0055] Table 1 shows the comparison of memory and bandwidth resource usage of different solutions
[0056] plan Transfer size Memory size occupied by the device Full upgrade 100KB 4KB or 100KB Differential Upgrade Less than 6KB 100KB This embodiment 6KB 4KB
[0057] It can be seen from the above table that compared with differential upgrade, the firmware size is basically the same, which significantly reduces the memory consumption of the terminal device to be upgraded and broadens the types of devices for differential upgrade applications, especially some resource-constrained devices; compared with full upgrade, the firmware size is significantly reduced and the upgrade speed is greatly improved; this embodiment uses block transmission and supports breakpoint resumption and specified block retransmission.
[0058] To sum up, in the embodiment of the present invention, after receiving the page upgrade point in the differential firmware issued by the Internet of Things platform, the terminal device to be upgraded can be immediately written into the Flash storage space, without the need to cache all the differential firmware, and then restore it to a new full firmware, and then write it into the Flash storage space, thereby significantly reducing the memory consumption of the terminal device to be upgraded.
[0059] Figure 7 is a schematic block diagram of a differential upgrade system 200 based on Flash page alignment provided by an embodiment of the present invention. Figure 7 As shown, corresponding to the differential upgrade method based on Flash page alignment applied to the IoT platform and the terminal device to be upgraded, the differential upgrade system 200 based on Flash page alignment includes a unit for executing the differential upgrade method based on Flash page alignment. Figure 7 The differential upgrade system 200 based on Flash page alignment includes a receiving initiating unit 101, a verification sending unit 102 and a receiving sending unit 103 configured in the Internet of Things platform, and a return reporting unit 201, a detection writing unit 202 and a detection generating unit 203 configured in the terminal device to be upgraded.
[0060] Wherein, the receiving and initiating unit 101 is used for initiating a firmware upgrade request to the terminal device to be upgraded if the Internet of Things platform receives the differential firmware uploaded by the differential terminal device, wherein the differential firmware includes firmware header information and an upgrade cluster, and the upgrade cluster includes at least one page upgrade point; the returning and reporting unit 201 is used for the terminal device to be upgraded to return the upgrade permission information and report the firmware transmission information to the Internet of Things platform; the verifying and sending unit 102 is used for the Internet of Things platform to verify the firmware transmission information to obtain the verification result, and if the verification result is that the verification is passed, the firmware header information is sent to the terminal device to be upgraded. The receiving and sending unit 103 is used for the The Internet of Things platform sends the firmware data block information in the page upgrade point to the terminal device to be upgraded according to the page upgrade point information requested by the terminal device to be upgraded; the detection and writing unit 202 is used for the terminal device to be upgraded to detect that the page upgrade point is received, and then write the page upgrade point into the Flash storage space according to the firmware transmission information and the firmware header information; the detection and generation unit 203 is used for the terminal device to be upgraded to detect that the differential firmware is transmitted and written into the Flash storage space, and then generate a differential upgrade result according to the full firmware after the differential upgrade and the firmware header information, and report the differential upgrade result to the Internet of Things platform.
[0061] In some embodiments, such as the present embodiment, the differential upgrade system 200 based on Flash page alignment also includes a compilation unit, a first comparison unit, a generation unit and a packaging unit configured in the differential terminal device, and a sending unit configured in the Internet of Things platform.
[0062] The compiling unit is used for the differential terminal device to compile a custom link script file through an IDE to generate a new firmware, wherein the custom link script file uses a large rectangle to represent a firmware, a square in the large rectangle represents a Flash page, the number on the Flash page is a page code, and the custom link script file is used to store different codes or data in a separate Flash page; the first comparing unit is used to compare the differences between the page space data of the new firmware and the old firmware one by one according to the Flash page alignment method to mark the differential page blocks with differences, and record the page code of each differential page block. A plurality of page upgrade points are obtained for one page upgrade point, wherein the old fixed part is a firmware generated by the custom link script file before the functional module code is written by IDE compilation; the generating unit is used to save the number of the page upgrade points, the Flash page size, the firmware base address, the CRC16 check code of the new firmware and the firmware size in the firmware header to generate firmware header information; the packaging unit is used to package the firmware header information and the plurality of page upgrade points into the differential firmware; the sending unit is used to stop the differential upgrade process if the verification result is a verification failure, and send an error response message to the terminal device to be upgraded.
[0063] In some embodiments, such as this embodiment, the verification issuing unit 102 includes a first comparing subunit, a second comparing subunit and a first setting unit.
[0064] Among them, the first comparison subunit is used for the Internet of Things platform to compare the single transmission firmware size with the upgrade Flash page size; the second comparison subunit is used for, if the single transmission firmware size is smaller than the upgrade Flash page size, to compare the upgrade Flash page size with the Flash page size in the firmware header information in the differential firmware; the first setting unit is used for, if the upgrade Flash page size is consistent with the Flash page size, to set the verification result as verification passed.
[0065] In some embodiments, such as this embodiment, the detection writing unit 202 includes an extraction unit and a writing unit.
[0066] Among them, the extraction unit is used to extract the page code and block number in each firmware data block information in the page upgrade point if the terminal device to be upgraded detects that the page upgrade point reception is completed; the writing unit is used to locate the Flash first address of the data block according to the page code, the block number, the firmware base address, the single transmission firmware size and the upgrade Flash page size, and write the firmware data block in the firmware data block information into the Flash storage space according to the Flash first address.
[0067] In some embodiments, such as the present embodiment, the writing unit includes a first writing sub-unit and a second writing sub-unit.
[0068] Among them, the first writing sub-unit is used for writing the firmware data block in the firmware data block information into the full Flash storage space of the old firmware according to the Flash first address if the Flash storage space is the single Flash storage space; the second writing sub-unit is used for copying the full Flash storage space of the old firmware to the backup Flash storage space if the Flash storage space is the dual Flash storage space, and writing the firmware data block into the backup Flash storage space according to the Flash first address.
[0069] In some embodiments, such as this embodiment, the detection generation unit 203 includes a verification unit, a second comparison unit, a second setting unit, and a third setting unit.
[0070] Among them, the verification unit is used to verify the full firmware after the differential upgrade through the CRC16 verification algorithm to obtain a verification code; the second comparison unit is used to compare the CRC16 verification code with the verification code; the second setting unit is used to set the differential upgrade result to a successful differential upgrade if the CRC16 verification code and the verification code are consistent; the third setting unit is used to set the differential upgrade result to a failed differential upgrade if the CRC16 verification code and the verification code are inconsistent.
[0071] It should be noted that technicians in the relevant field can clearly understand that the specific implementation process of the differential upgrade system 200 based on Flash page alignment and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.
[0072] The differential upgrade system based on Flash page alignment can be implemented in the form of a computer program. The computer program can be used in Figure 8 Runs on the computer device shown.
[0073] See also Figure 8 , Figure 8 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 900 is an Internet of Things platform and a terminal device to be upgraded.
[0074] See also Figure 8 The computer device 900 includes a processor 902 , a memory and an interface 907 connected via a system bus 901 , wherein the memory may include a storage medium 903 and an internal memory 904 .
[0075] The storage medium 903 can store an operating system 9031 and a computer program 9032. When the computer program 9032 is executed, the processor 902 can execute a differential upgrade method based on a Flash page alignment mode.
[0076] The processor 902 is used to provide computing and control capabilities to support the operation of the entire computer device 900 .
[0077] The internal memory 904 provides an environment for the operation of the computer program 9032 in the storage medium 903. When the computer program 9032 is executed by the processor 902, the processor 902 can execute a differential upgrade method based on the Flash page alignment mode.
[0078] The interface 905 is used to communicate with other devices. Those skilled in the art will appreciate that Figure 8 The structure shown in the figure is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device 900 to which the solution of the present application is applied. The specific computer device 900 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0079] The processor 902 of each of the IoT platform and the terminal device to be upgraded is used to run a computer program 9032 stored in a memory to implement any embodiment of the differential upgrade method based on Flash page alignment.
[0080] It should be understood that in the embodiment of the present application, the processor 902 may be a central processing unit (CPU), and the processor 902 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0081] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing related hardware through a computer program. The computer program can be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the wireless communication system to implement the process steps of the embodiment of the above method.
[0082] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program. When the computer program is executed by a processor, the processor executes any embodiment of the differential upgrade method based on the Flash page alignment method.
[0083] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.
[0084] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, wireless communication software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0085] In the several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0086] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the system of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0087] If the 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 storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The wireless communication software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal wireless communication, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0088] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0089] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
[0090] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A differential upgrade method based on Flash page alignment, characterized in that: include: If the IoT platform receives the differential firmware uploaded by the differential terminal device, it initiates a firmware upgrade request to the terminal device to be upgraded, wherein the differential firmware includes firmware header information and an upgrade cluster, the upgrade cluster includes at least one page upgrade point, the page upgrade point is a Flash page modified by the new firmware relative to the old firmware, and the firmware header information is the number of the page upgrade points, the Flash page size, the firmware base address, the CRC16 checksum of the new firmware, and the firmware size are saved in the firmware header to generate the information; The terminal device to be upgraded returns upgrade permission information and reports firmware transmission information to the Internet of Things platform, wherein the firmware transmission information includes a single transmission firmware size and an upgrade Flash page size; The Internet of Things platform verifies the firmware transmission information to obtain a verification result, and if the verification result is that the verification passes, sends the firmware header information to the terminal device to be upgraded; The Internet of Things platform sends the firmware data block information in the page upgrade point to the terminal device to be upgraded according to the page upgrade point information requested by the terminal device to be upgraded; If the terminal device to be upgraded detects that the page upgrade point is received, the page upgrade point is written into the Flash storage space according to the firmware transmission information and the firmware header information; If the terminal device to be upgraded detects that the differential firmware is transmitted and written into the Flash storage space, a differential upgrade result is generated according to the full firmware after the differential upgrade and the firmware header information, and the differential upgrade result is reported to the Internet of Things platform; The Internet of Things platform verifies the firmware transmission information to obtain a verification result, including: The IoT platform compares the single transmission firmware size with the upgrade Flash page size; If the single transmission firmware size is smaller than the upgrade Flash page size, comparing the upgrade Flash page size with the Flash page size in the firmware header information in the differential firmware; If the upgrade Flash page size is consistent with the Flash page size, the verification result is set as verification passed.
2. The differential upgrade method based on Flash page alignment according to claim 1, characterized in that: If the IoT platform receives the differential firmware uploaded by the differential terminal device, before initiating a firmware upgrade request to the terminal device to be upgraded, the IoT platform also includes: The differential terminal device compiles a custom link script file through an IDE to generate a new firmware, wherein the custom link script file uses a large rectangle to represent a firmware, a square in the large rectangle represents a Flash page, the number on the Flash page is a page code, and the custom link script file is used to store different codes or data in a separate Flash page; Compare the differences between the page space data of the new firmware and the old firmware one by one according to the Flash page alignment mode to mark the differential page blocks with differences, record the page code where each differential page block is located as a page upgrade point to obtain multiple page upgrade points, wherein the old firmware is the firmware generated by the custom link script file before the functional module code is written by IDE compilation; The number of the page upgrade points, the Flash page size, the firmware base address, the CRC16 checksum of the new firmware, and the firmware size are stored in the firmware header to generate firmware header information; The firmware header information and the plurality of page upgrade points are packaged into the differential firmware.
3. The differential upgrade method based on Flash page alignment according to claim 1, characterized in that: After the Internet of Things platform verifies the firmware transmission information to obtain a verification result, the method further includes: If the verification result is that the verification fails, the differential upgrade process is stopped, and an error response message is sent to the terminal device to be upgraded.
4. The differential upgrade method based on Flash page alignment according to claim 1, characterized in that: The firmware header information includes a firmware base address; if the terminal device to be upgraded detects that the page upgrade point is received, the page upgrade point is written into the Flash storage space according to the firmware transmission information and the firmware header information, including: If the terminal device to be upgraded detects that the page upgrade point is received, the page code and block number in each firmware data block information in the page upgrade point are extracted; The Flash first address of the data block is located according to the page code, the block number, the firmware base address, the single transmission firmware size and the upgrade Flash page size, and the firmware data block in the firmware data block information is written into the Flash storage space according to the Flash first address.
5. The differential upgrade method based on Flash page alignment according to claim 4, characterized in that: The Flash storage space is a single Flash storage space or a dual Flash storage space; The step of writing the firmware data block in the firmware data block information into the Flash storage space according to the Flash first address includes: If the Flash storage space is the single Flash storage space, writing the firmware data block in the firmware data block information into the full Flash storage space of the old firmware according to the Flash first address; If the Flash storage space is the dual Flash storage space, the full Flash storage space of the old firmware is copied to the backup Flash storage space, and the firmware data block is written into the backup Flash storage space according to the Flash first address.
6. The differential upgrade method based on Flash page alignment according to claim 1, characterized in that: The firmware header information includes a CRC16 check code; The generating a differential upgrade result according to the full firmware after differential upgrade and the firmware header information includes: The full firmware after differential upgrade is verified by CRC16 verification algorithm to obtain the verification code; Compare the CRC16 check code with the check code; If the CRC16 check code is consistent with the check code, the differential upgrade result is set as a differential upgrade success; If the CRC16 check code is inconsistent with the check code, the differential upgrade result is set as differential upgrade failure.
7. A differential upgrade system based on Flash page alignment, characterized in that: include: The receiving and initiating unit, the verification and issuing unit and the receiving and issuing unit configured in the Internet of Things platform, the return reporting unit, the detection writing unit and the detection generating unit configured in the terminal device to be upgraded, wherein: The receiving initiating unit is used for initiating a firmware upgrade request to the terminal device to be upgraded if the IoT platform receives the differential firmware uploaded by the differential terminal device, wherein the differential firmware includes firmware header information and an upgrade cluster, the upgrade cluster includes at least one page upgrade point, the page upgrade point is a Flash page modified by the new firmware relative to the old firmware, and the firmware header information is information generated by saving the number of the page upgrade points, the Flash page size, the firmware base address, the CRC16 checksum of the new firmware, and the firmware size in the firmware header; The return reporting unit is used for the terminal device to be upgraded to return the upgrade permission information and report the firmware transmission information to the Internet of Things platform, wherein the firmware transmission information includes the single transmission firmware size and the upgrade Flash page size; The verification and sending unit is used for the IoT platform to verify the firmware transmission information to obtain a verification result. If the verification result is a verification pass, the firmware header information is sent to the terminal device to be upgraded. The receiving and sending unit is used for the Internet of Things platform to send the firmware data block information in the page upgrade point to the terminal device to be upgraded according to the page upgrade point information requested by the terminal device to be upgraded; The detection writing unit is used for, if the terminal device to be upgraded detects that the page upgrade point has been received, to write the page upgrade point into the Flash storage space according to the firmware transmission information and the firmware header information; The detection generation unit is used for generating a differential upgrade result according to the full firmware after the differential upgrade and the firmware header information if the terminal device to be upgraded detects that the differential firmware is transmitted and written into the Flash storage space, and reporting the differential upgrade result to the Internet of Things platform; The verification issuing unit comprises: A first comparison subunit, configured for the Internet of Things platform to compare the single transmission firmware size with the upgrade Flash page size; A second comparison subunit is used for comparing the upgrade Flash page size with the Flash page size in the firmware header information in the differential firmware if the single transmission firmware size is smaller than the upgrade Flash page size; The first setting unit is used to set the verification result as verification passed if the upgrade Flash page size is consistent with the Flash page size.
8. A differential upgrade system based on Flash page alignment, characterized in that: The method comprises an Internet of Things platform and a terminal device to be upgraded, wherein the Internet of Things platform and the terminal device to be upgraded both comprise a memory and a processor, a computer program is stored in the memory, and the Internet of Things platform and the processor of the terminal device to be upgraded implement the method as described in any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 can be implemented.
Citation Information
Patent Citations
A system and method for version upgrade of wireless terminal
CN109426521A
Local differential flashing method and system for controller
CN114443111A
In-situ upgrading method and device, network equipment and storage medium
CN116932022A
Memory optimized block-based differential update algorithm
US20210004223A1
