Method, processing system and storage medium for generating binary target file
By using the copy instructions and reverse data in the incremental file when updating the electronic device, the problem of time-consuming wireless transmission and time-consuming rollback is solved, and an efficient update and rollback process is achieved.
Patent Information
- Application Number
- CN201980048083.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2018-05-29
- Filing Date
- 2019-05-28
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2039-05-28
AI Technical Summary
When updating data files on an electronic device in the existing technology, transmitting a large amount of data through a wireless connection is time-consuming and involves a high risk of transmission errors, and falling back to the old data file in the event of an error requires additional data transmission, which is time-consuming.
Using delta files, containing copy instructions and reverse data, the processing system generates binary target files from binary source files and regenerates source files from target files when needed, reducing storage requirements and transfer time.
It achieves reduced storage requirements and transmission time during the update process, improves update efficiency, and can fall back to old data files without additional data transfer in error situations, reducing risks.
Smart Images

Figure CN112424747B_ABST
Abstract
Description
Background Art
[0001] The present invention relates to a method, apparatus and software for updating a data file on a device.
[0002] When updating software or other data files on a device, one option is to send a complete replacement data file to the device to replace the data file currently stored on the device. Such an approach is described in the applicant's previous application WO 2015 / 092355. However, this may require sending a large amount of data to the device, which may be undesirable, especially if the update is received over a wireless connection (e.g., a radio link). Transmitting large amounts of data over radio may be time consuming and may also present a higher risk of transmission errors.
[0003] An alternative approach is to not send the entire replacement data file, but to use the data differences to generate an incremental file (delta file) that is sent to the device. This incremental file (also called a difference file or difffile) communicates the differences between the existing (source) data file and the new (target) data file. Typically, the areas of the new data file will remain unchanged from the areas in the existing data file. The incremental file does not need to communicate the data contained in such areas, and therefore can be significantly smaller than the new data file itself.
[0004] Upon receiving such a delta file, the device may create a new data file in the device's memory by processing (interpreting) a set of delta instructions encoded in the delta file and applying those instructions to the existing data file. In some cases, the update may be applied in place, at least partially overwriting the existing data file. In this way, the update process does not require the device to reserve an amount of memory equal to the size of the new data file in addition to the memory occupied by the existing data file for performing the update. Less memory is required for the update process, which means that the device may be able to be manufactured more cheaply. This is particularly true for memory-constrained devices such as system-on-chip devices.
[0005] Sometimes, a new data file may identify a problem, which may necessitate restoring the old data file. For example, when the data file is a firmware module for a device, it may be determined after updating the firmware that the new firmware contains an error that means it cannot operate correctly on the device. In this case, it may be necessary to revert to the old firmware.
[0006] One disadvantage of overwriting an old data file with a new data file is that rolling back to the old data file requires an additional time-consuming data transfer in order to restore the old data file to the device.
[0007] The present invention seeks to provide a better method for updating data files (including software modules) on an electronic device. Summary of the invention
[0008] According to a first aspect, the present invention provides a delta file comprising instructions which, when executed by a processing system to which the delta file is transmitted, cause the processing system to generate a binary target file from a binary source file, wherein the delta file comprises:
[0009] one or more copy instructions that direct the processing system to include one or more binary copy strings from the binary source file in the binary destination file; and
[0010] Reverse data used to regenerate the entirety of the binary source file that is outside of one or more binary copy strings.
[0011] According to a second aspect, the present invention provides a method for reversibly generating a binary target file from a binary source file using a delta file, the method comprising:
[0012] receiving incremental files; and
[0013] Processes the instructions in the delta file to generate a binary object file from the binary source file,
[0014] The incremental files include:
[0015] one or more copy instructions identifying one or more binary copy strings in a binary source file; and
[0016] reverse data, which is used to regenerate the entirety of the binary source file that is outside of one or more binary copy strings,
[0017] where the reverse data is received as part of the delta file, and
[0018] The generated binary target files include:
[0019] One or more binary copy strings are read from a binary source file and included in a binary destination file.
[0020] The method may further include creating a regenerated binary source file identical to the binary source file from the binary target file by:
[0021] Reading one or more binary copy strings from a binary object file and including the one or more binary copy strings in a regenerated binary source file; and
[0022] Use reverse data to include all of the binary source file's binary data that is outside of one or more binary copy strings in the regenerated binary source file.
[0023] According to a third aspect, the present invention provides a processing system for processing instructions in a delta file received at an input of the processing system to generate a binary target file from a binary source file, and for processing instructions in the delta file to regenerate a binary source file from the binary target file,
[0024] The incremental files include:
[0025] one or more copy instructions that direct the processing system to include one or more binary copy strings from the binary source file in the binary destination file; and
[0026] reverse data for regenerating all of said binary source files that are external to said one or more binary copy strings,
[0027] wherein the reverse data is received as part of the delta file; and
[0028] The processing system is configured to process the delta file to generate a binary target file from the binary source file by:
[0029] reads one or more binary copy strings from a binary source file and includes one or more binary copy strings in a binary destination file, and
[0030] Wherein the processing system is configured to process the delta file to create a regenerated binary source file from the binary target file that is identical to the binary source file by:
[0031] Reading one or more binary copy strings from a binary object file and including the one or more binary copy strings in a regenerated binary source file; and
[0032] Use reverse data to include all of the binary source file's binary data that is outside of one or more binary copy strings in the regenerated binary source file.
[0033] Thus, it will be seen that, according to these aspects of the invention, the delta file contains reverse data, which is not required for generating the target file from the source file, but if desired, this allows the same delta file to be used to regenerate the source file from the target file. The copy instructions will typically not contain (e.g., encode) either the contents of the source file or the target file in the actual instructions, but will instead identify a binary string in the source file, for example using address and / or length information. Thus, the delta file can still be smaller than the source file and smaller than the target file, even if it contains reverse data, because the reverse data will typically only represent a portion of the source file. (This assumes that there is a typical level of overlap between the contents of the two files; if there is no overlap, for example if both files are fully encrypted and appear as random noise, then the incremental update method will be inappropriate.)
[0034] Conventional delta files (such as those described in RFC 3284) do not support regenerating a source file from a target file once the source file has been overwritten. This is because sections of the source file that were not copied to the target file by conventional delta files will be lost and cannot be recovered from the delta files and the target file.
[0035] The reverse data may encode the value of each bit position of the binary source file that is outside the bit positions whose values are contained in the one or more binary replicated strings. The reverse data may directly encode data from the source file, for example by including a replicate of one or more binary strings, or may encode binary data in any other manner, such as using lossless compression.
[0036] In some embodiments, the reverse data may be used alone to regenerate all of the binary source file that is outside of one or more binary copy strings, such as where all of the data outside of the binary copy string is directly included in the delta file. It should be noted that each copy instruction is essentially reversible simply by reading the corresponding binary copy string from the binary target file and including it in the regenerated binary source file in a reverse copy operation.
[0037] In other embodiments, the reverse data and the binary target file can be used together to regenerate all of the binary source file outside the one or more binary copy strings. For example, the reverse data can include one or more instructions for generating some or all of the binary data of the binary source file from the data in the binary target file. Such instructions can include an exclusive or (XOR) instruction, and the exclusive or instruction has an associated operand encoded in the incremental file for performing a bitwise exclusive or calculation on the target file of one or more bits, so as to regenerate data in the regenerated binary source file, which will be explained in more detail below.
[0038] The delta file is preferably smaller than the binary source file (ie, smaller in bytes in size). The delta file is preferably smaller than the binary target file.
[0039] A copy instruction can instruct a processing system to copy a binary copy string from a binary source file to a binary target file. This can include reading a binary copy string from a memory location within a binary source file, and writing the binary copy string to a target memory location, which can be a memory location within a binary target file or can be an intermediate or temporary memory location. A copy instruction can include two or more copy sub-instructions, each of which instructs the processing system to copy a binary copy string from a source address to a target address, so that the sequence together generates a binary copy string that is read from a binary source file and contains (e.g., written to) a binary target file. Each of the sub-instructions can be a copy instruction as disclosed herein. In other words, when two or more copy instructions act on the same binary copy string, such as moving the binary copy string to a temporary location before writing it to a final destination, the two or more copy instructions can be considered as a single copy instruction.
[0040] The binary target file and the binary source file may have at least one common memory address, so that the target file at least partially overwrites the source file.
[0041] The processing system may be part of or may be an electronic device such as an integrated circuit device or any other device. The processing system or device may include an input for receiving the incremental file. The input may be a wired or wireless interface. Embodiments of the present invention are particularly suitable for use on devices having a radio interface, especially a low bandwidth radio interface, such as an LTE-M or NB-IoT radio device, where compact but reversible incremental files are particularly beneficial because the time taken to receive the incremental file over the radio interface is relatively short.
[0042] The source file and the target file can be non-executable data files, but in a preferred embodiment group, the source file and the target file are software files, such as firmware modules, i.e., including software code. The source file and the target file can be libraries or executable files. The source file and the target file can include software instructions for execution by the processing system. When performing firmware upgrades or patches, the reversibility provided by the incremental file is particularly useful because the wrong target file may cause the device to be inoperable. Specifically, the wrong target file may cause the device to be unable to control the communication interface, such as a radio peripheral device, in order to receive a second incremental file or replace the firmware. However, the reversibility of the incremental file of the present invention mitigates this risk by enabling the firmware to fall back to the previous source file version without requiring the device to receive additional data. The update of the source firmware file to the target firmware file can be controlled by the boot loader software. The boot loader software may include instructions for testing the binary target file generated from the binary source file. The boot loader software may include instructions for regenerating the binary source file in response to an error detected in the binary target file.
[0043] In some embodiments, a delta file may include a sequence of instructions that a processing system may execute sequentially.
[0044] The processing system may include a target address counter for storing the current location (e.g., in the target file) of the current instruction from the incremental file. After processing each instruction, the processing system may increase the target address counter by an appropriate amount. In some embodiments, the processing system may include a source address counter for determining the current location (e.g., in the source file) of the current instruction from the incremental file. After processing each instruction, the processing system may increase the source address counter by an appropriate amount. If the processing system uses both the source address counter and the target address counter, it may not be necessary for the copy instruction to include any explicit source address or target address data.
[0045] Alternatively, the instructions in the incremental file may include (i.e., encode) a source address and / or a target address. Specifically, each copy instruction may include a source address operand and a target address operand. Each copy instruction may also include a length operand indicating the amount of data to be copied from the source address to the target address. Some copy instructions may instruct the processing system to copy data directly from the source file to the target file. However, as mentioned, some copy instructions (e.g., sub-instructions) may instruct the processing system to copy data to a temporary location that is not the expected final location of the data in the target file, or to copy data from such a temporary location to the target file.
[0046] The address value may be a hardware memory address value, or it may be an index or offset into a source file or into a target file, for example specifying a byte or word offset from the start of the respective file.
[0047] Reverse data can include address information representing the position (or one or more temporary positions) of a binary string in a source file and / or in a target file. The address information can include an address value, such as a bit, byte or word offset in a file. Alternatively, the address information can be encoded by one or more positions of the reverse data in the incremental file, and the incremental file can correspond to corresponding source address and / or target address values when the incremental file is processed to regenerate the source file. In this case, the counter step length of other instructions in the incremental file can also facilitate the encoding of the address information.
[0048] In addition to the copy instruction, the incremental file may also include other incremental instructions for generating a binary target file. The incremental file may include one or more addition instructions for generating a binary target file. Each addition instruction may have associated binary addition data. When generating a target file from a source file, the addition instruction may instruct the processing system to include the binary addition data in the binary target file. The incremental file may include one or more run instructions for generating a binary target file. Each run instruction may have an associated binary run value and a repeat value. The run instruction may instruct the processing system to include multiple copies of the binary run value in the binary target file, and the number of copies is equal to the repeat value. These addition or run instructions may include explicit target address information; or the addition or run instructions may include implicit target address information identified by the position of each instruction in the incremental file and the instruction preceding the instruction in the incremental file, as described above. When regenerating a source file from a target file, the addition and / or run instructions may be ignored, or the addition and / or run instructions may cause the processing system to increase the target address counter by an amount corresponding to the addition data or run length, but not to include any binary data in the regenerated source file.
[0049] Reverse data can include one or more reverse addition instructions, also referred to as jump instructions in this article.Each reverse addition instruction can have the associated binary reverse addition (or jump) data encoded in the incremental file.Binary reverse addition data can be equal to some or all of the binary data of the source file outside the binary copy string.When generating the target file from the source file, the reverse addition instruction can be ignored.In the embodiment using the source address counter, the reverse addition instruction can make the processing system increase the source address counter but not include any additional data in the target file.However, when regenerating the source file from the target file, the reverse addition instruction can guide the processing system to include the reverse addition data in the regenerated source file.When regenerating the source file, the reverse addition instruction can be used as an addition instruction process.In certain embodiments, the reverse addition instruction can include the associated source address.In other embodiments, the processing system can use the source address counter, and the position of the reverse addition instruction in the incremental file can encode the corresponding address of the associated reverse addition data in the source file.
[0050] In some embodiments, the delta file may include one or more XOR instructions. Each XOR instruction may have an associated binary operand and may direct the processing system to compute the bitwise XOR of: i) the associated binary operand and ii) a binary string from a binary source file or a binary target file when generating a binary target file, and include the result of the computation as a binary string in the binary target file. For reasons explained below, the XOR instruction and its operand may be considered part of the reverse data.
[0051] Like the copy instruction, the XOR instruction may contain the source address and the target address, or the source address but not the target address, or the target address but not the source address, or it may contain explicit address data. The binary operand may inherently provide length information. Including both the source address and the target address in the XOR instruction may simplify the process of reverse update compared to using an address counter to track the source location and / or the target location.
[0052] The source address of the XOR instruction can be in the source file or in the target file (or in a temporary location). Similarly, the target address of the XOR instruction can be in the source file or in the target file (or in a temporary location). In some embodiments, at least one XOR instruction is applied to a binary string from a binary source file. The XOR instruction can include (i.e., encode) associated target address information, which can be an address in the target file. The address information can be an offset from the beginning of the target file to the target file, or can be a relative offset, such as a value of a target file address counter relative to when processing the XOR instruction.
[0053] The XOR instruction contains source and target address information so that the delta file can use a copy instruction, followed by one or more XOR instructions, to include a binary string that is similar but not identical to the binary string in the source file in the target file. In a memory type that allows bits to be freely overwritten (e.g., SRAM), the processing system can perform such an instruction sequence by first copying the original binary string from the source address to the target address, and then using one or more XOR instructions to flip one or more bits at predetermined positions within the copied binary string based on the XOR data operand in the XOR instruction. In memory types that do not support arbitrary overwriting of data, such as flash memory (where a 1 bit can be changed to a 0 bit, but not vice versa without erasing the entire flash block), the processing system may process a COPY instruction followed by one or more XOR instructions that act on the copied data by applying the XOR instructions to the data while the data is being copied (i.e., after one or more bytes have been read from the source data but before those bytes have been written to the target address specified by the COPY instruction). In some embodiments, the processing system may be configured to recognize when a delta file contains such an instruction sequence, and not process the COPY if the associated XOR instruction has not been applied. Alternatively, the processing system may support a COPY instruction that contains an optional additional XOR operand that directs the processing system to perform one or more bitwise XOR operations on corresponding strings within the data to be copied. A delta file may contain one or more such COPY-with-XOR instructions.
[0054] Without XOR instructions, creating a binary string in the target file that is similar but not identical to a binary string in the source file would require the delta file to contain two or more copy instructions and one or more add instructions. Therefore, a combined copy and XOR operation can be used to reduce the number of copy instructions in the delta file, resulting in a smaller delta file.
[0055] This reduction in delta file size can be particularly significant when the target file has a high degree of similarity to the source file overall, but with a large number of small differences distributed throughout the file, because it enables the delta file to use fewer copy instructions acting on longer strings of data. Applicants have identified that when applying data diffs to processors that use PC-relative (program counter-relative) instruction addresses, such as Arm, TMThe use of the XOR instruction (either independently or as an extension to the copy instruction) is particularly beneficial when two versions of software code are being compiled and linked by a processor using a PC-relative addressing scheme. This is because recompiling the software may result in changes to the address of each subroutine call and branch. When using PC-relative addressing, if an opcode is copied to a new location, the relative offset encoded in the opcode changes, even if the opcode target address does not change; in contrast, when using absolute addressing, the absolute target address remains unchanged when the opcode is copied to a new location. Thus, in some embodiments, the source file and the target file are corresponding software files for execution by a processor using PC-relative addressing.
[0056] It should be noted that for purposes of understanding the scope of the present invention, the combination of one copy instruction and one or more XOR instructions that change the run of bits within the copied data (either as it is written or after it has been written) can be viewed as providing multiple separate copy instructions (each of which directs the processing system to include a corresponding binary copy string from the binary source file in the binary target file outside the run of XOR bits) and reverse data. In other words, the binary copy string can be viewed as those portions of the data from the source file that are included in the target file if XORed.
[0057] The use of XOR instructions in delta files is itself considered novel.
[0058] Thus, according to another aspect, the present invention provides a delta file comprising instructions that, when executed by a processing system, cause the processing system to generate a binary target file from a binary source file, wherein the delta file comprises:
[0059] copy instructions that direct the processing system to include a binary string from a binary source file in a binary destination file; and
[0060] An XOR instruction and an associated binary operand, wherein the XOR instruction directs the processing system to compute a bitwise XOR of the associated binary operand and a binary string from a binary source file or a binary target file, and to include the bitwise XOR as a binary string in the binary target file.
[0061] According to another aspect, the present invention provides a processing system for processing instructions in a delta file to generate a binary target file from a binary source file.
[0062] The incremental files include:
[0063] a copy instruction that identifies a binary copy string in a binary source file; and
[0064] XOR instruction and associated binary operands, and
[0065] The processing system is configured as follows:
[0066] processing the copy instruction by reading a binary copy string from a binary source file and including the binary copy string in a binary destination file; and
[0067] An XOR instruction is processed by computing the bitwise XOR of the associated binary operand and a binary input string from a binary source file or a binary object file and by including the bitwise XOR as a binary output string in the binary object file.
[0068] According to another aspect, the present invention provides a method for generating a binary target file from a binary source file, the method comprising:
[0069] Receive incremental files;
[0070] Processes the instructions in the delta file to generate a binary object file from the binary source file,
[0071] The incremental files include:
[0072] a copy instruction that identifies a binary copy string in a binary source file; and
[0073] XOR instruction and associated binary operands, and
[0074] The generated binary target files include:
[0075] processing the copy instruction by reading a binary copy string from a binary source file and including the binary copy string in a binary destination file; and
[0076] An XOR instruction is processed by computing a bitwise XOR of the binary operand and a binary input string from a binary source file or a binary object file and including the bitwise XOR as a binary output string in the binary object file.
[0077] The features of these aspects can be combined with the features of the earlier aspects or any other embodiments disclosed herein. Specifically, the incremental file can include reverse data as described above. The incremental file can include multiple copy instructions that identify corresponding binary copy strings in the binary source file. The incremental file can include multiple such XOR instructions.
[0078] Another benefit of the use of XOR instructions in the delta file arises when the delta file is reversible, because when generating the target file, the XOR instruction can be reversed simply by applying the same XOR instruction to the binary string contained in the target file as a result of the XOR instruction. This benefit exists even when the XOR instruction does not contain associated source address information.
[0079] If the source file needs to be regenerated from the target file and the delta file (e.g., because the source file has been overwritten by the target file during the generation process), the processing system can reverse the XOR instruction by calculating another bitwise XOR between the same associated operands and the related binary string from the target file (i.e., the binary string contained in the target file as a result of the initial processing of the XOR instruction). This other bitwise XOR will be the original binary string, which can be contained in the regenerated source file (directly or through a subsequent reverse copy instruction). When reversing the XOR operation to regenerate the source file, the original source address of the XOR instruction can be used as the target address, and the original target address can be used as the source address.
[0080] Therefore, including XOR instructions in the delta file does not require making the delta file larger in order to support the ability to regenerate the original source file from the target file.
[0081] In embodiments where the XOR instruction originally had a source address in the binary source file, this reverse application of the same XOR instruction will compute the original source file binary string that can be included in the regenerated binary source file.
[0082] In an embodiment where the XOR instruction initially has a source address and a target address both in a binary destination file (e.g., for performing a post-copy XOR operation in situ), this reverse application of the same XOR instruction will calculate the original XOR input string. This string can be written back to the destination file (e.g., overwriting the current data). The string can then be included in a reverse copy operation that copies the XOR input string along with other data to the regenerated binary source file.
[0083] In any of the embodiments disclosed herein, the delta file may be considered software, or as a computer program, i.e., program instructions for a processing system. Thus, aspects of the invention extend to transient and non-transient computer readable media containing the delta file as disclosed herein.
[0084] The processing system may consist of hardware only, or may include both hardware and software. In some embodiments, the processing system may include dedicated hardware logic for processing the incremental files. In other embodiments, interpreter software is used to process the incremental files. The interpreter software may be implemented in, for example, an Arm processor. TM Cortex TM-M series processors. The interpreter software includes processor instructions for parsing or interpreting the incremental instructions in the incremental file, and for applying the incremental instructions to the source file to generate the target file and / or for applying the incremental instructions to the target file to regenerate the source file. The interpreter software can be part of the processing system. The interpreter software can be stored in the memory of the processing system or device. The interpreter software can be included in the boot loader software. Alternatively, the interpreter software can be included in the incremental file, which is self-explanatory. In other embodiments, the incremental file can be directly executed by a general-purpose processor (i.e., including processor instructions for implementing copy, XOR and / or other incremental instructions).
[0085] In some embodiments, the incremental instructions are encoded so that the most frequently used instructions are the shortest. The incremental files can be stored or communicated in any suitable manner. The incremental files can be a single file or data block, or can be divided into multiple sub-files, or can be an instruction stream.
[0086] The processing system or a device including the processing system may include a memory for storing incremental files and / or for storing source files and / or for storing target files. The memory may include volatile and / or non-volatile memory areas. The processing system is preferably configured to rewrite at least a portion of the source file when generating the target file. This reduces the memory requirements of the update process, which can reduce the amount of memory required in the device as a whole, especially when the device is a resource-constrained device such as an integrated circuit device as in a preferred embodiment. In some embodiments, the device may even include a total of non-volatile memory that is smaller than the sum of the sizes of the source file and the target file.
[0087] The processing system may "include" the binary string in the generated file by writing the binary string to an appropriate location in a memory, which may be a non-volatile memory. Alternatively, the binary string may be included by outputting the binary string via an output, such as a communications port; this may occur in the case where the generated file (e.g., a binary object file) is generated in real time on-line by a communications device, rather than by a processing system that writes the object file in its entirety to a memory.
[0088] Unusually, if a copy instruction specifies a target location for a copied string that is the same as the source location of the string (i.e., the very same memory address), then processing the copy instruction to include the copied string in the target file may involve the processing system taking no action in response to this instruction (because the data is already in the required location).
[0089] The incremental instructions can all operate on data of one or more units of a constant minimum size. Each incremental instruction can operate on data that is an integer multiple of the constant unit size. In some embodiments, this unit can be 8 bits, as in RFC 3284, but in other embodiments it can be smaller or larger. In a preferred set of embodiments, the basic unit of data is 16 bits. This allows the incremental file to efficiently represent a file containing Arm TM The difference between the two files of Thumb2 code, which contain mostly 16-bit instructions.
[0090] The delta file may be generated in any suitable manner. The delta file will typically be created once (e.g., by a software developer) and sent to multiple (potentially thousands) of separate processing systems as disclosed herein. In some embodiments, in addition to one or more custom scripts for generating instructions (e.g., copy instructions, add instructions, reverse add (jump) instructions, and XOR instructions), a conventional software tool (e.g., a Unix difference utility) may be used to generate the delta file.
[0091] According to another aspect, the present invention provides a delta file comprising instructions that, when executed by a processing system, cause the processing system to generate a binary target file from a binary source file, wherein the delta file comprises:
[0092] one or more copy instructions that direct the processing system to include one or more binary copy strings from the binary source file in the binary destination file; and
[0093] Reverse data used to regenerate the entirety of the binary source file that is outside of one or more binary copy strings.
[0094] According to another aspect, the present invention provides a method for reversibly generating a binary target file from a binary source file using a delta file, the method comprising:
[0095] Processes the instructions in the delta file to generate a binary object file from the binary source file,
[0096] The incremental files include:
[0097] one or more copy instructions identifying one or more binary copy strings in a binary source file; and
[0098] reverse data used to regenerate the entirety of the binary source file that is outside of the one or more binary copy strings, and
[0099] The generated binary target files include:
[0100] One or more binary copy strings are read from a binary source file and included in a binary destination file.
[0101] According to another aspect, the present invention provides a processing system for processing instructions in a delta file to generate a binary target file from a binary source file, and for processing instructions in a delta file to regenerate a binary source file from a binary target file,
[0102] The incremental files include:
[0103] one or more copy instructions that direct the processing system to include one or more binary copy strings from the binary source file in the binary destination file; and
[0104] reverse data for regenerating all of the binary source files that are outside of one or more binary copy strings,
[0105] The processing system is configured to process the delta file to generate a binary target file from the binary source file by:
[0106] reads one or more binary copy strings from a binary source file and includes one or more binary copy strings in a binary destination file, and
[0107] Wherein the processing system is configured to process the delta file to create a regenerated binary source file from the binary target file that is identical to the binary source file by:
[0108] Reading one or more binary copy strings from a binary object file and including the one or more binary copy strings in a regenerated binary source file; and
[0109] Use reverse data to include all of the binary source file's binary data that is outside of one or more binary copy strings in the regenerated binary source file.
[0110] Features of any aspect or embodiment described herein may be applied to any other aspect or embodiment described herein where appropriate.When referring to different embodiments or groups of embodiments, it should be understood that these are not necessarily distinct, but may overlap. BRIEF DESCRIPTION OF THE DRAWINGS
[0111] Certain preferred embodiments of the present invention will now be described, by way of example only, with reference to the accompanying drawings, in which:
[0112] Figure 1 is a schematic diagram of a radio-on-a-chip device embodying the present invention;
[0113] Figure 2 is a schematic diagram showing the major software components stored in the flash memory of the device; and
[0114] Figure 3 is a flow chart of a firmware update operation for a device. DETAILED DESCRIPTION
[0115] Figure 1 An integrated circuit system-on-chip device 1 is shown which includes a radio and may therefore also be referred to as a radio-on-chip. The integrated circuit system-on-chip device may be incorporated into an electronic product such as a wireless heart rate monitor or a room temperature sensor or another Internet of Things device.
[0116] Device 1 includes a processor 2 (eg, ARM TM Cortex TM -M series processors), SRAM 3, hardware memory protection unit 4, non-volatile flash memory 5, input / output peripherals 6, radio 7 (which may include another processor), other peripherals 8 (which may include a cryptographic processor, ADC, DAC, timer, etc.), power management circuitry 9, and clock management circuitry 10. On-chip communications are handled by a bus system 11 (e.g., ARM TM The AMBA bus system) is provided, and the bus system may include one or more advanced high-performance buses (AHB) and / or advanced peripheral buses (APB).
[0117] The device 1 may contain other analog or digital components as required. When installed in a product, the device 1 may be connected to external components such as a power supply, a radio antenna 12, a crystal oscillator, capacitors, sensors, audio / video output devices, etc.
[0118] Figure 2 The main software components stored in the flash memory 5 for execution by the processor 2 are shown. These main software components include a boot loader 22, a firmware module 14, and an optional user application 15. The firmware module 14 is typically created by the device manufacturer, while the user application 15 may be created by a customer, such as a manufacturer of an appliance in which the system on chip 1 is installed. The software may first be loaded onto the device at the semiconductor manufacturing plant or at a later stage. Typically, the boot loader 22 and the firmware module 14 will be installed before the device 1 is released to the end user. This initial loading may be done through an external wired interface, such as a debug port.
[0119] The firmware module 14 may contain low-level code for controlling the radio device 7 and other peripheral devices 8. The firmware module may contain a real-time operating system. The firmware module may provide an application programming interface (API) to the user application 15, which allows the developer of the user application 15 to easily access the various functions of the device 1.
[0120] The bootloader contains code that is executed every time the device 1 is reset. The bootloader performs boot tasks such as writing configuration data to volatile hardware registers and verifying the integrity of the device 1 and the software. Updates to the firmware 14 are also performed under the control of the bootloader 13.
[0121] Once the device 1 is in the field, it may be necessary to replace the existing firmware 14 with new firmware in order to provide new features or fix software errors. For convenience, update data encoding the new firmware is received by radio using the radio device 7 via the antenna 12. The update data may be received via LTE-M, NB-IoT or other 3G, 4G or 5G cellular connection, or via WiFi TM or Bluetooth TM connection or received via any other suitable radio protocol.
[0122] During an update, the existing firmware 14 is overwritten by the new firmware. This avoids having to provide the SRAM 3 or flash memory 5 with sufficient capacity to store both the existing firmware 14 and the new firmware during an update, which would increase the cost of the device 1.
[0123] The update data received by the radio 7 contains a delta file encoding the new firmware as a difference to the existing firmware 14 .
[0124] The bootloader 13 contains instructions that cause the processor 2 to perform the update process. In one embodiment, the radio device 7 stores the received delta file in a cache in the SRAM 3. An interpreter algorithm within the bootloader 13 parses the cached delta file and applies the delta instructions contained in the delta file to the existing firmware 14 stored in the flash memory 5 to generate new firmware. The new firmware can be written directly to the flash memory 5, or can be cached in the SRAM 3 before being written to the flash memory 5.
[0125] Overwriting the existing firmware 14 with the new firmware may occur while the incremental file representing the new firmware is still being received by the radio device 7 (i.e., in real time). Alternatively, the entire incremental file can be received into a memory (e.g., flash memory 5) before the update begins. Although this may be slower than a real-time update and require more memory space, it allows the integrity of the received incremental file to be checked before the patch is applied (e.g., by verifying a checksum or hash). Even when the entire incremental file is cached before being processed, less memory space is required to perform the update than when the new firmware is received without using differential encoding; this is because data differences should always create an incremental file that is smaller than the target, since there will always be some data that is the same in the existing firmware 14 and the new firmware. Typically, there will be significant overlap between the contents of the old firmware 14 and the contents of the new firmware.
[0126] Figure 3 Summarizes the steps involved in updating old firmware 14 with new firmware.
[0127] In a first step 30, the device 1 receives a delta file by radio means. The entire delta file may be stored in the flash memory 5. Alternatively, the delta file may be stored in the SRAM 3, but if the device is reset during the update process, storing in the flash memory 5 may be beneficial as the delta file will be preserved.
[0128] In a second step 31, control is passed from the existing firmware 14 to the bootloader 22. The bootloader 22 verifies the delta file by checking a hash or checksum. If the delta file is not received correctly, the device 1 may abort the update process and return control to the existing firmware 14. A retransmission may be requested from the network.
[0129] In a third step 32, the boot loader 22 parses the delta file and applies the delta instructions it contains to the old firmware 14 to generate the new firmware. When the new firmware is generated, the new firmware is written over some or all of the old firmware 14. This process is described in more detail below.
[0130] In a fourth step 33, the bootloader 22 directs the new firmware to use the radio 7 to connect to a network or paired device.
[0131] If the connection is successful, the next step 34 may be to delete the incremental file to free up more memory space (but the incremental file may be retained for a longer time as required), after which normal operation is resumed. This may involve transferring control to the new firmware or user application 15.
[0132] If the radio connection fails, it can be concluded that the new firmware is not operating correctly and the device 1 needs to fall back to the old firmware. In this case, the next step 35 involves the bootloader 22 parsing the delta file a second time, but interpreting the delta file slightly differently (as described below) in order to convert the new firmware into the old firmware 14. The regenerated old firmware 14 is written over the new firmware (at least in part). After the old firmware 14 has been restored, the final step 34 of deleting the delta file and resuming normal operation can be performed. The device 1 can notify the network or paired device of the error so that appropriate action can be taken (e.g., reporting the problem with the new firmware to the firmware developer).
[0133] The interpreter algorithm in the boot loader 22 operates as follows.
[0134] The received incremental file contains the following incremental instruction types: copy, add (ADD), jump (SKIP) and XOR. These can be encoded in any suitable way, for example, as ASCII text or as binary code. In some embodiments, the incremental file may also contain a run (RUN) instruction, which is actually an effective type of addition instruction for adding repeated data words.
[0135] The copy instruction includes the following operands: source address, target address, length. The add instruction includes the following operands: target address, data. The jump instruction includes the following operands: source address, data (provided for use in a reverse operation, where the jump is implemented as an addition). The XOR instruction includes the following operands: source address, target address, XOR data. In the case where data is supplied as an operand, the data itself implicitly provides a length value, for example, limiting the number of bytes to be skipped in the jump operation. In some embodiments, the copy instruction can support an optional XOR operand, which causes the processor to perform a combined XOR copy operation when provided. Including the explicit source address and target address in the instruction, rather than using an incremental target address counter to track the target address when processing the instruction, can make it easier to reversely process incremental files.
[0136] When generating new (target) firmware from existing (source) firmware, the interpreter algorithm will process the instructions in the incremental file in sequence. The interpreter algorithm processes the copy instruction by reading the indicated byte string from the source address in the old firmware 14 and writing it unchanged to the target address. The target address can be a memory address that will be part of the new firmware. However, in some cases, the target address can be a temporary location, where the same data will be copied one or more times before writing it to its final location in the new firmware. By maintaining redundant copies of certain data while it is being updated, this can be useful to ensure that the update process is stable during power outages.
[0137] When generating new firmware, the update algorithm processes the add instruction by adding the indicated byte string to the target memory address. The update algorithm ignores jump instructions (these instructions will be used when undoing the update). The update algorithm processes the XOR instruction by reading the indicated byte string from the source memory address, calculating the bitwise XOR between the byte string and the XOR data operand encoded in the instruction, and writing the resulting byte string to the target address. As with the copy instruction, the target address of these additional instructions can be a temporary location or a final location within the new firmware.
[0138] If it is necessary to regenerate the old firmware 14 from the new firmware, the interpreter algorithm parses the delta file a second time. The interpreter algorithm processes each copy instruction by reading the indicated byte string from the original target address and writing it unchanged to the original source address. The interpreter algorithm ignores each add instruction (i.e., processes it as a jump instruction). The interpreter algorithm processes each jump instruction (i.e., processes it as an add instruction) by adding the indicated byte string to the indicated source address. The interpreter algorithm processes the XOR instruction by reading the indicated byte string from the original target address, calculating the bitwise XOR between the byte string and the XOR data operand encoded in the instruction, and writing the resulting byte string to the original source address.
[0139] A simplified example is now provided to illustrate these principles. The example shows a way to generate a reversible incremental file containing an XOR instruction. Of course, in practice, the source and target files may be much more complex than this, and other processes for generating suitable incremental files may be used.
[0140] Assuming the source file is called 'oldversion' and the target file is called 'newversion':
[0141] $cat oldversion
[0142] abcdefghij klmnop
[0143] $cat newversion
[0144] abcdij 1234567klmnop
[0145] First, convert the file into a hex dump with a 16-bit value on each side:
[0146] $od-t x2-A none-v-w2 oldversion>oldversion.vhx16
[0147] $
[0148] $od-t x2-A none-v-w2 newversion>newversion.vhx16
[0149] The 16-bit hex dump now looks like this:
[0150] $ cat oldversion.vhx16 6261 6463 6665 6867
[0155] 6a69
[0156] 6c6b
[0157] 6e6d
[0158] 706f
[0159] $ cat newversion.vhx16 6261 6463
[0162] 6a69 3231 3433 3635
[0166] 6b37
[0167] 6d6c
[0168] 6f6e
[0169] 0a70
[0170] Comparing the files side by side, the results are shown below:
[0171] $diff--side-by-side oldversion.vhx16 newversion.vhx16
[0172]
[0173] Insertions are marked with a '<'. Deletions are marked with a '<'. Different data is marked with a '|'. Data that is the same in both versions is the same in both columns.
[0174] The script is used to parse the two-column difference table and generate the following sequence of instructions:
[0175] copy(source: 00000000, destination: 00000000, length: 2 short int) [lines 1…2]
[0176] Jump(source: 00000004, data: 6665 6867) [lines 3…4]
[0177] copy(source: 00000008, destination: 00000004, length: 4 short int) [lines 5…8]
[0178] XORH(source: 0000000A, destination: 00000006, XOR data: 5E5A) [Line 6]
[0179] XORH(source: 0000000C, destination: 00000008, XOR data: 5A5E) [Line 7]
[0180] XORH(source: 0000000E, destination: 0000000A, XOR data: 465A) [Line 8]
[0181] add(destination: 0000000C, data: 6b37 6d6c 6f6e 0a70) [lines 9…12]
[0182] The 'source' address value is the byte count in the 'old version' file, while the 'destination' address is the byte count in the 'new version' file.
[0183] These instructions and the operands indicated may be encoded in a suitable manner to form a delta file.
[0184] Although the Copy instruction is shown here as acting on four short integers, in other embodiments the Copy instruction may copy only one short integer (6a69), where the following three XOR instructions would be executed as Copy and XOR operations.
[0185] To process the delta file in reverse (i.e., regenerate the 'old version' file from the 'new version' file), the interpreter processes the instructions in the same order, but swaps the 'source' and 'target' values in each copy instruction and in each XOR instruction; the interpreter also processes each jump instruction as an add instruction with a target address in the 'new version' file equal to the source address in the original jump instruction, and similarly processes each add instruction as a jump instruction. In this way, the same delta file can be used for both upgrade and rollback.
[0186] Instructions can be encoded in the delta file so that the most frequently used instructions are the shortest. In this simple example, it is possible to generate a 25-byte delta file.
[0187] In larger instances, such as updates for Arm TM Cortex TMA 1MB LTE modem firmware image for a -M processor with a traditional VCDIFF compressed delta image size without any fallback capability might be 280kB. Under the current copy / xor / add / jump scheme, a compressed delta image size of 80kB with fallback capability can be generated. This delta file is both smaller and more reversible.
[0188] It will be appreciated by those skilled in the art that the present invention has been illustrated by describing one or more specific embodiments thereof, but that the invention is not limited to these embodiments; many variations and modifications are possible within the scope of the appended claims.
Claims
1. A method for reversibly generating a binary target file from a binary source file using a delta file, the method comprising: Receive incremental files; and processing instructions in the delta file to generate the binary target file from the binary source file, The incremental files include: one or more copy instructions that identify one or more binary copy strings in the binary source file to include in the binary target file; and reverse data for regenerating all of the binary source file that is outside the one or more binary copy strings, the reverse data comprising one or more jump instructions for instructing a processing system to include in the regenerated binary source file all binary data of the binary source file that is outside the one or more binary copy strings; in: each jump instruction having associated binary jump data equal to some or all of the binary data of the source file external to the binary copy string, and each jump instruction including a source address operand identifying a location in said regenerated binary source document to include the associated binary jump data when said regenerated binary source document is generated; The reverse data is received as part of the delta file, and Generating the binary target file includes: The one or more copy instructions are processed by reading the one or more binary copy strings from the binary source file and including the one or more binary copy strings in the binary target file.
2. The method of claim 1 , further comprising creating a regenerated binary source file identical to the binary source file from the binary target file by: processing the one or more copy instructions by reading the one or more binary copy strings from the binary object file and including the one or more binary copy strings in the regenerated binary source file; and Using the reverse data to include all of the binary data of the binary source file that is external to the one or more binary copy strings in the regenerated binary source file, wherein using the reverse data comprises processing each of the one or more jump instructions by including binary jump data associated with the jump instruction at a location in the regenerated binary source file identified by the source address operand of the jump instruction.
3. The method of claim 2, comprising using the reverse data together with data from the binary target file to generate the entirety of the binary source file that is external to the one or more binary copy strings.
4. A method according to claim 1 or 2, wherein the reverse data encodes the corresponding value of each bit position in the binary source file that is outside a group of bit positions whose values are contained in the one or more binary copy strings.
5. A method according to claim 1 or 2, wherein the incremental file is smaller than the binary source file and smaller than the binary target file.
6. The method of claim 1 or 2, wherein the binary source file is stored in a memory, and wherein generating the binary target file comprises writing the binary target file at least partially over the binary source file.
7. A method according to claim 1 or 2, wherein the delta file includes one or more additional delta instructions that are not copy instructions.
8. The method of claim 1 or 2, wherein each of the one or more copy instructions includes a source address operand and a target address operand.
9. A method according to claim 1 or 2, wherein the incremental file includes an XOR instruction having associated binary operands, and wherein generating the binary target file includes calculating the bitwise XOR of: i) the associated binary operands, and ii) a binary string from the binary source file or the binary target file, and including the bitwise XOR as a binary string in the binary target file.
10. The method of claim 9, wherein the reverse data includes the XOR instruction, the method further comprising creating a regenerated binary source file from the binary object file that is identical to the binary source file, wherein the creating includes computing the bitwise XOR of: i) the binary operands of the XOR instruction, and ii) the binary string from the binary object file, and including the bitwise XOR in the regenerated binary source file or in the binary object file.
11. The method of claim 1 or 2, wherein the binary source file and the binary object file are corresponding software files compiled for execution by a processor using PC-relative addressing.
12. A processing system for processing instructions in a delta file received at an input of the processing system to generate a binary target file from a binary source file, and for processing the instructions in the delta file to regenerate the binary source file from the binary target file, The incremental files include: one or more copy instructions that direct the processing system to include one or more binary copy strings from the binary source file in the binary destination file; and reverse data for regenerating all of the binary source file that is external to the one or more binary copy strings, the reverse data comprising one or more jump instructions for instructing a processing system to include in the regenerated binary source file all binary data of the binary source file that is external to the one or more binary copy strings; wherein each jump instruction has associated binary jump data equal to some or all of the binary data of the source file external to the binary copy string, and each jump instruction includes a source address operand identifying a location in said regenerated binary source document to include the associated binary jump data when said regenerated binary source file is generated; wherein the reverse data is received as part of the delta file; and The processing system is configured to process the delta file to generate the binary target file from the binary source file by: processing the one or more copy instructions by reading the one or more binary copy strings from the binary source file and including the one or more binary copy strings in the binary target file, and wherein the processing system is configured to process the delta file to create a regenerated binary source file from the binary target file that is identical to the binary source file by: processing the one or more copy instructions by reading the one or more binary copy strings from the binary object file and including the one or more binary copy strings in the regenerated binary source file; and using the reverse data to include all of the binary data of the binary source file that is outside of the one or more binary copy strings in the regenerated binary source file, Wherein using the reverse data comprises processing each of the one or more jump instructions by including binary jump data associated with the jump instruction at a location in the regenerated binary source file identified by the source address operand of the jump instruction.
13. The processing system of claim 12, wherein the delta file and the binary source file are stored in a memory of the processing system.
14. The processing system of claim 12 or 13, wherein the binary source file and the binary object file comprise software code for execution by the processing system.
15. A processing system according to claim 12 or 13, wherein the processing system includes a processor and interpreter software for interpreting the instructions in the incremental file.
16. A processing system according to claim 15, wherein the interpreter software is contained in boot loader software stored in a memory of the processing system, and wherein the boot loader software further includes instructions for testing the binary target file generated from the binary source file, and for regenerating the binary source file using the delta file in response to detecting an error in the binary target file.
17. A processing system according to claim 12 or 13, comprising a radio interface for receiving the delta file.
18. A computer-readable storage medium comprising instructions which, when executed by a processing system, cause the processing system to perform all the steps of the method of claim 1.
Citation Information
Patent Citations
Updatable integrated-circuit radio
WO2015092355A1
Embedded POI (Point of Interest) data increment updating method supporting increment updating
CN102968327A
File processing method, device, and communication system
CN105760183A
Incremental updating packet generating method and device, and server
CN106648712A
Difference generation method and apparatus
EP1686463A1
