A method and tool for packaging version files of embedded devices
By inserting anti-redundancy plug-ins into the packaging system, duplicate data in the embedded device version file is automatically deleted and index encoding is generated, which solves the problems of long packaging time and large space occupancy, and achieves more efficient file packaging.
Patent Information
- Application Number
- CN202110693074.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-22
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2041-06-22
AI Technical Summary
When packaging embedded device version files, the bin file contains a large amount of duplicate redundant data, resulting in a long packaging time and a large space.
Insert anti-redundancy plug-ins in the packaging system, including comparison modules, index encoding generation modules and association modules, automatically delete duplicate files, and generate index encodings for querying.
Effectively delete unnecessary duplicate files, reduce file size, significantly reduce packaging time, and reduce file space.
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of packaging methods, and more specifically, to a method and a packaging tool for packaging version files of an embedded device. Background Art
[0002] Firmware upgrade means improving the working program or source code in the hardware through a special upgrade program to improve its compatibility, performance or functionality. The security of the firmware upgrade file (bin file) is a necessary condition for the security of the embedded system. The integrity of the bin file determines whether the embedded device upgrade can be successful. A bin file contains many resources, such as images, sounds, texts, scripts and other types of data. A general client may have tens of thousands of files, including some duplicate redundant data. Therefore, it will waste a long time in the packaging process and take up a lot of unnecessary space. Summary of the invention
[0003] In order to overcome the above-mentioned defects of the prior art, the present invention provides a method and a packaging tool for packaging version files of an embedded device. The technical problem to be solved by the present invention is: a bin file contains many resources, such as images, sounds, texts, scripts and various other types of data. A general client may have tens of thousands of files, including some repeated redundant data. Therefore, a long time will be wasted in the packaging process, and a large amount of unnecessary space will be occupied.
[0004] To achieve the above object, the present invention provides the following technical solution: a method and a packaging tool for an embedded device version file packaging, comprising the following steps:
[0005] S1. When files need to be packaged, use a packaging tool to create a new packaging directory, and place the file directory path to be packaged in the packaging directory, then collect the files to be packaged and read them, wherein each file is described by at least one file item, and each file item contains multiple file information for describing the file content. During the reading process, the order of the files is collected and recorded as a file order list, and at the same time, it is determined whether the file is an ordinary file or a file that needs to be encrypted based on the attributes of the file, and then the contents of the ordinary files are compared to remove redundant data. If a file corresponds to two or more locations, an index code for accessing the same file can be generated, and then the content in the encrypted file is processed in the same way.
[0006] S2. Then process the encrypted file separately. First, determine the encryption algorithm and generate an encryption key. Then use the encryption key to encrypt each module of the encrypted file separately. Then perform embedded system tailoring on the file. After compilation, generate a standard Linux kernel file and a rootfs file system image. Then compare the standard Linux kernel files generated by different tailoring requirements, remove the same part of the standard Linux kernel file header, and during the device upgrade process, group the intercepted same part back into the standard Linux kernel file header. Finally, package the bin file, perform CRC check calculation on the packaged bin file, write the obtained CRC check value to the end of the bin file, and then read all the nodes that need to be packaged from the node marking file, wherein the update package located at the node contains update files of different versions, divide the nodes that need to be packaged in the marking file into basic nodes, ordinary nodes and important nodes, and then perform outer layer traversal in reverse order for all the nodes that need to be packaged.
[0007] S3. When traversing to a certain node, export the updated file of the node and save it in the packaged file list. After traversing all important nodes, determine whether all files have been read. If so, stop packaging. If not, query the files that have not been read and read them again. Stop packaging after reading is completed, and then insert an anti-redundancy plug-in into the packaging system. The anti-redundancy plug-in includes an additional comparison module, an index code generation module and an association module. When there are new files, the additional comparison module can automatically compare the added files with the previously packaged archives. If the added files are repeated with the previous files, the duplicate files are automatically deleted. At the same time, the index code generation module can generate a new index code, and then the association module can associate the new index code with the repeated unique file, so that relevant personnel can query the duplicate files through the index code.
[0008] As a further solution of the present invention: the nodes that are not selected to be packaged between the two adjacent nodes to be packaged are traversed in the inner layer in reverse order.
[0009] As a further solution of the present invention: encryption is performed using an encryption algorithm when packaging the bin file, and the encryption algorithm is the MD5 encryption algorithm.
[0010] As a further solution of the present invention: the output end of the additional comparison module is electrically connected to the input end of the index code generation module, and the output end of the index code generation module is electrically connected to the input end of the association module.
[0011] As a further solution of the present invention: the function of the additional comparison module is to compare the additional file with the previous file to determine whether there is a duplicate file.
[0012] As a further solution of the present invention: the index code generation module can automatically generate a set of codes from the file, and the association module can associate the index code with the file.
[0013] As a further solution of the present invention: the specific method of the CRC check calculation is as follows: using a 32-bit cyclic redundancy algorithm, the binary data t(x) to be packaged is divided by the generating polynomial g(x), the final remainder is used as the CRC check value, and the calculation result is written to the end of the bin file.
[0014] As a further solution of the present invention: the packaging tool is a Webpack packaging tool.
[0015] As a further solution of the present invention: the Webpack packaging tool can perform multiple packaging tasks simultaneously.
[0016] The beneficial effects of the present invention are:
[0017] The present invention inserts an anti-redundancy plug-in into the packaging system so that the redundant plug-in can automatically delete the added duplicate files. At the same time, the index code generation module can generate a new index code, and then the association module can associate the new index code with the duplicate unique file, so that relevant personnel can query the duplicate file through the index code, so that the device can delete unnecessary duplicate files during and after packaging without affecting normal queries, thereby reducing the size of the file to a certain extent, thereby greatly reducing the packaging time and reducing the space occupied by the entire file. DETAILED DESCRIPTION
[0018] The technical solutions in the embodiments of the present invention are described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. 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.
[0019] A method and a packaging tool for embedded device version files, comprising the following steps:
[0020] S1. When files need to be packaged, use a packaging tool to create a new packaging directory, and place the file directory path to be packaged in the packaging directory, then collect the files to be packaged and read them, wherein each file is described by at least one file item, and each file item contains multiple file information for describing the file content. During the reading process, the order of the files is collected and recorded as a file order list, and at the same time, it is determined whether the file is an ordinary file or a file that needs to be encrypted based on the attributes of the file, and then the contents of the ordinary files are compared to remove redundant data. If a file corresponds to two or more locations, an index code for accessing the same file can be generated, and then the content in the encrypted file is processed in the same way.
[0021] S2. Then process the encrypted file separately. First, determine the encryption algorithm and generate an encryption key. Then use the encryption key to encrypt each module of the encrypted file separately. Then perform embedded system tailoring on the file. After compilation, generate a standard Linux kernel file and a rootfs file system image. Then compare the standard Linux kernel files generated by different tailoring requirements. Remove the same part of the standard Linux kernel file header. During the device upgrade process, group the intercepted same part back into the standard Linux kernel file header. Finally, package the bin file, perform CRC check calculation on the packaged bin file, write the obtained CRC check value to the end of the bin file, and then read all the nodes that need to be packaged from the node marking file, where the update package located at the node contains update files of different versions. The nodes that need to be packaged in the marking file are divided into basic nodes, ordinary nodes and important nodes. Then, all the nodes that need to be packaged are traversed in the outer layer in reverse order.
[0022] S3. When traversing to a certain node, export the updated file of the node and save it in the packaged file list. After traversing all important nodes, determine whether all files have been read. If so, stop packaging. If not, query the files that have not been read and read them again. Stop packaging after reading is completed, and then insert an anti-redundancy plug-in into the packaging system. The anti-redundancy plug-in includes an additional comparison module, an index code generation module and an association module. When there are new files, the additional comparison module can automatically compare the added files with the previously packaged archives. If the added files are repeated with the previous files, the duplicate files will be automatically deleted. At the same time, the index code generation module can generate a new index code, and then the association module can associate the new index code with the repeated unique file, so that relevant personnel can query the duplicate files through the index code.
[0023] The nodes that are not selected to be packaged between two adjacent nodes that need to be packaged are traversed in the inner layer in reverse order.
[0024] The bin file is encrypted using the MD5 encryption algorithm.
[0025] The output end of the additional comparison module is electrically connected to the input end of the index code generation module, and the output end of the index code generation module is electrically connected to the input end of the association module.
[0026] The function of the additional comparison module is to compare the added files with the previous files to determine whether there are duplicate files.
[0027] The index code generation module can automatically generate a set of codes for the file, and the association module can associate the index code with the file.
[0028] The specific method of CRC check calculation is as follows: using a 32-bit cyclic redundancy algorithm, divide the binary data t(x) to be packaged by the generating polynomial g(x), and use the final remainder as the CRC check value, and write the calculation result to the end of the bin file.
[0029] The packaging tool is the Webpack packaging tool.
[0030] The Webpack packaging tool can perform multiple packaging tasks at the same time.
[0031] In summary, the present invention inserts an anti-redundancy plug-in into the packaging system so that the redundant plug-in can automatically delete the added duplicate files. At the same time, the index code generation module can generate a new index code, and then the association module can associate the new index code with the duplicate unique file, so that relevant personnel can query the duplicate file through the index code, so that the device can delete unnecessary duplicate files during and after packaging without affecting normal queries, thereby reducing the file size to a certain extent, thereby greatly reducing the packaging time and reducing the space occupied by the entire file.
[0032] Finally, a few points should be explained: Although the present invention has been described in detail above with general descriptions and specific embodiments, on the basis of the present invention, the above embodiments are only used to illustrate the technical solution of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the aforementioned embodiments, ordinary technicians in this field should understand that they can still modify the technical solutions recorded in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for packaging version files of an embedded device, characterized in that: The following steps are involved: S1. When files need to be packaged, a packaging tool is used to create a new packaging directory, and the directory path of the files to be packaged is placed in the packaging directory. Then, the files to be packaged are collected and read. Each file is described by at least one file item, and each file item contains multiple file information for describing the content of the file. During the reading process, the order of the files is collected and recorded as a file order list. At the same time, it is determined whether the file is an ordinary file or a file to be encrypted based on the attributes of the file. Then, the contents of the ordinary files are compared to remove redundant data. If a file corresponds to two or more locations, an index code for accessing the same file can be generated, and then the content in the encrypted file is processed in the same way; S2. Then process the encrypted file separately. First, determine the encryption algorithm and generate an encryption key. Then use the encryption key to encrypt each module of the encrypted file separately. Then perform embedded system tailoring on the file. After compilation, generate a standard Linux kernel file and a rootfs file system image. Then compare the standard Linux kernel files generated by different tailoring requirements, remove the same part of the standard Linux kernel file header. During the device upgrade process, group the intercepted same part back into the standard Linux kernel file header. Finally, package the bin file, perform CRC check calculation on the packaged bin file, write the obtained CRC check value to the end of the bin file, and then read all the nodes that need to be packaged from the node marking file, wherein the update package located at the node contains update files of different versions. The nodes that need to be packaged in the marking file are divided into basic nodes, ordinary nodes and important nodes, and then all the nodes that need to be packaged are traversed in the outer layer in reverse order. S3. When traversing to a certain node, export the updated file of the node and save it in the packaged file list. After traversing all important nodes, determine whether all files have been read. If so, stop packaging. If not, query the files that have not been read and read them again. Stop packaging after reading is completed, and then insert an anti-redundancy plug-in into the packaging system. The anti-redundancy plug-in includes an additional comparison module, an index code generation module and an association module. When there are new files, the additional comparison module can automatically compare the added files with the previously packaged archives. If the added files are repeated with the previous files, the duplicate files are automatically deleted. At the same time, the index code generation module can generate a new index code, and then the association module can associate the new index code with the repeated unique file, so that relevant personnel can query the duplicate files through the index code.
2. A method for packaging version files of an embedded device according to claim 1, characterized in that: The nodes that are not selected to be packaged between two adjacent nodes that need to be packaged are traversed in the inner layer in reverse order.
3. The method for packaging version files of an embedded device according to claim 1, characterized in that: The encryption algorithm is used for encryption when packaging the bin file, and the encryption algorithm is the MD5 encryption algorithm.
4. The method for packaging version files of an embedded device according to claim 1, characterized in that: The output end of the additional comparison module is electrically connected to the input end of the index code generation module, and the output end of the index code generation module is electrically connected to the input end of the association module.
5. The method for packaging version files of an embedded device according to claim 4, characterized in that: The function of the additional comparison module is to compare the additional file with the previous file to determine whether there is a duplicate file.
6. A method for packaging version files of an embedded device according to claim 4, characterized in that: The index code generation module can automatically generate a set of codes from the file, and the association module can associate the index code with the file.
7. The method for packaging version files of an embedded device according to claim 1, characterized in that: The specific method of the CRC check calculation is as follows: using a 32-bit cyclic redundancy algorithm, the binary data t(x) to be packaged is divided by the generating polynomial g(x), the final remainder is used as the CRC check value, and the calculation result is written to the end of the bin file.
8. A packaging tool for a method for packaging version files of an embedded device according to any one of claims 1 to 7, characterized in that: The packaging tool is the Webpack packaging tool.
9. The packaging tool according to claim 8, characterized in that: The Webpack packaging tool can perform multiple packaging tasks at the same time.
Citation Information
Patent Citations
Method of packaging version files of embedded device
CN107688463A
Method of rapid batched packaging for generating APK file
CN107992311A