Quick starting method and system for embedded system
By configuring the status register of the decompression module and combining the LZ4 and Huffman encoding algorithms, the fast startup of the embedded system is achieved, solving the problem of insufficient flexibility of the hardware decompression module, and improving the startup speed and efficiency.
Patent Information
- Application Number
- CN202510278551.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-10
- Publication Date
- 2025-07-04
AI Technical Summary
During the startup process of existing embedded systems, the flexibility and efficiency of the hardware decompression module are insufficient, resulting in a long startup time. The existing solution has a fixed block size decompression method that is not flexible enough to effectively shorten the startup time.
By configuring the status register of the decompression module, including the decompression mode, data acquisition address and data storage address, the decompression module performs blocking or multi-file decompression according to actual conditions, combining LZ4 and Huffman encoding algorithms to achieve flexible decompression of compressed mirror files.
It improves the startup speed and flexibility of embedded systems, reduces interrupt time and improves compression efficiency, and is especially suitable for fragmented files such as Android systems.
Smart Images

Figure CN120255966A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of embedded systems, and particularly to a method and system for quickly starting an embedded system. Background Art
[0002] With the increasingly wide application of embedded devices, many embedded systems, such as Linux systems, Android systems, etc., are sensitive to cold start or sleep wake-up time.
[0003] In order to improve the user experience and shorten the system startup time, the existing methods include: (1) optimizing the startup program to reduce the size of the system image file; (2) using a peripheral with a faster transmission speed to shorten the loading time of the system image file; (3) loading a compressed kernel image and using the CPU to decompress it; (4) loading a compressed kernel image and using a hard decompression module to decompress the kernel image. In the above methods, the optimization space of the startup program is limited, and it is difficult to significantly reduce the file size; the cost of a peripheral with a faster transmission speed is also higher; using the CPU to decompress will occupy the CPU computing power.
[0004] An existing solution is to set up a dedicated hardware decompression module. After the CPU finishes loading the compressed firmware, it sends a decompression instruction to the hardware decompression module. The hardware decompression module obtains the compressed firmware according to the decompression instruction and decompresses it, and the CPU does not need to wait for the previous firmware compression to complete when loading the compressed firmware, reducing the time used in the embedded startup process through parallelism. Although this solution reduces the loading time of the compressed firmware by setting up a separate hard decompression module for decompression, it is not flexible enough and the efficiency still needs to be further improved.
[0005] Another existing solution also sets up a hardware decompression module with a data decompression function. The CPU reads the compressed data in fixed block sizes and places the data in the input buffer of the hardware decompression module. When the CPU reads the first data block, it starts the hardware decompression module, and then continues to read the next data block from the storage medium. After the hardware decompression module is started, it reads the data from the input buffer for decompression. This solution uses a method of decompressing data blocks in fixed block sizes, and the segmentation method is fixed and not flexible enough. Summary of the Invention
[0006] The first object of the present invention is to provide a method for quickly starting an embedded system with high flexibility.
[0007] The second object of the present invention is to provide an embedded system that can achieve quick startup with high flexibility.
[0008] To achieve the above first object, the present invention provides a method for quickly starting an embedded system, which includes the following steps: The processor loads a compressed image file from an external memory to the main memory; the processor configures the status register of the decompression module, and the status register includes a decompression mode, a data acquisition address, and a data storage address, wherein the data storage areas corresponding to the data acquisition address and the data storage address are both located in the main memory; the decompression module acquires the compressed image file from the data storage area corresponding to the data acquisition address according to the decompression mode and decompresses it, and stores the decompressed compressed image file in the data storage area corresponding to the data storage address.
[0009] As can be seen from the above solution, the processor of the present invention loads the compressed image file and configures the status register of the decompression module, so that the decompression module decompresses the compressed image file according to the status register. Since the decompression mode of the status register can be configured according to the actual situation of each compressed image file, it has higher flexibility and decompression efficiency, thereby improving the startup speed of the embedded system.
[0010] A further solution is that the decompression mode is a block decompression mode; the status register includes a decompression length; the decompression module acquires the compressed image file from the data storage area corresponding to the data acquisition address according to the decompression mode and decompresses it, and stores the decompressed compressed image file in the data storage area corresponding to the data storage address, including the following steps: The decompression module acquires the first data block of the compressed image file from the data storage area corresponding to the data acquisition address and decompresses it according to the decompression length, stores the decompressed first data block in the data storage area corresponding to the data storage address, and issues an interrupt; the processor updates the decompression length, the data acquisition address, and the data storage address of the current status register; the decompression module acquires the second data block of the compressed image file from the data storage area corresponding to the updated data acquisition address and decompresses it according to the updated decompression length, and stores the decompressed second data block in the data storage area corresponding to the updated data storage address.
[0011] Thus, it can be seen that in the block decompression method of the present invention, the splitting method of the compressed image file is more flexible, and a corresponding decompression length can be configured for each data block. The decompression module decompresses the corresponding data block according to the configured decompression length, which improves flexibility and efficiency compared with the method of decompressing data blocks of a fixed size.
[0012] A further solution is that the decompression mode is the multi-file decompression mode; the compressed image file includes multiple compressed image sub-files; the decompression module obtains the compressed image file from the data storage area corresponding to the data acquisition address according to the decompression mode and decompresses it, and stores the decompressed compressed image file in the data storage area corresponding to the data storage address, including: the decompression module sequentially obtains the compressed image sub-files from the data storage area corresponding to the data acquisition address and decompresses them, and stores the decompressed compressed image sub-files in the data storage area corresponding to the data storage address, and issues an interruption until all the decompressed compressed image sub-files are stored in the data storage area corresponding to the data storage address.
[0013] It can be seen that the present invention can realize decompressing multiple image sub-files by the decompression module at one time through software configuration, can adapt to the situation of fragmented file decompression (such as the Android system), reduce the interruption time, and improve the decompression efficiency.
[0014] A further solution is that the decompression mode is the normal decompression mode; the decompression module obtains the compressed image file from the data storage area corresponding to the data acquisition address according to the decompression mode and decompresses it, and issues an interruption after storing the decompressed compressed image file in the data storage area corresponding to the data storage address.
[0015] A further solution is that the compressed image file is obtained by compressing the original image file by the LZ4 algorithm; the decompression module decompresses the compressed image file according to the LZ4 algorithm.
[0016] It can be seen that by utilizing the characteristic that the decompression speed of the LZ4 algorithm is very fast, it is applied to the compression and decompression of the original image file to improve the decompression efficiency.
[0017] A further solution is that the compressed image file is obtained by compressing the original image file by the LZ4 algorithm and then performing Huffman coding; the decompression module decodes the compressed image file according to the Huffman coding and then decompresses the compressed image file according to the LZ4 algorithm.
[0018] It can be seen that after the original image file is compressed by the LZ4 algorithm and then Huffman coding is performed to obtain the compressed image file, the size of the compressed image file is further reduced, so that the compressed image file can be loaded into the main memory faster, and since the decompression module and the processor process in parallel, the startup speed can be further improved.
[0019] To achieve the above second objective, the present invention provides an embedded system for rapid startup, which includes: a processor and a decompression module; the processor is connected to the decompression module, and is also connected to an external external memory and a main memory, and the decompression module is connected to the external memory and the main memory; the processor is used to load a compressed image file from the external memory to the main memory and configure the status register of the decompression module, and the status register includes a decompression mode, a data acquisition address, and a data storage address; the decompression module is used to obtain the compressed image file from the data storage area corresponding to the data acquisition address according to the decompression mode and decompress it, and store the decompressed compressed image file in the data storage area corresponding to the data storage address.
[0020] As can be seen from the above solution, the decompression module provided by the present invention is used as an independent hardware to decompress the compressed image file, which can be processed in parallel with the processor loading the compressed image file, thereby improving the startup speed of the embedded system. The decompression module decompresses different compressed image files through different decompression modes configured by the data status of the status register, improving the flexibility and efficiency of decompression, and then improving the startup speed of the embedded system.
[0021] A further solution is that the decompression module is an LZ4 decompression unit.
[0022] A further solution is that the decompression module further includes a Huffman decoding unit, and the Huffman decoding unit is connected to the LZ4 decompression unit.
[0023] Thus, the LZ4 decompression unit and the Huffman decoding unit are used to further reduce the size of the compressed image file, improving the startup speed of the embedded system. Description of the Drawings
[0024] Figure 1 It is a schematic diagram of the embedded system in the embodiment of the embedded system for rapid startup of the present invention.
[0025] Figure 2 It is a flowchart of the embodiment of the rapid startup method of the embedded system of the present invention.
[0026] Figure 3 is Figure 2 a specific flowchart of a situation of step S3 in
[0027] Figure 4 is Figure 2 a specific flowchart of another situation of step S3 in
[0028] The present invention will be further described below in conjunction with the drawings and embodiments. Detailed Embodiments
[0029] The embedded system for achieving fast startup of the present invention is provided with a processor and a decompression module. The processor loads a compressed image file, and the decompression module obtains and decompresses the compressed image file from the data storage area corresponding to the data acquisition address according to the set decompression mode, and stores the decompressed compressed image file in the data storage area corresponding to the data storage address. Since after the processor loads a compressed image file from the external memory to the main memory, the decompression module can process the compressed image file, and at the same time the processor can continue to load the next compressed image file to the main memory, achieving the effect of parallel processing of the processor and the decompression module. And the compressed image file occupies less storage space than the original image file before compression, which can make the compressed image file be loaded into the main memory faster than the original image file, improving the startup speed. The fast startup method of the embedded system of the present invention is implemented based on the above embedded system.
[0030] Embodiment of the embedded system for achieving fast startup:
[0031] See Figure 1 , the embedded system 100 for achieving fast startup of this embodiment includes a processor 11 and a decompression module 21. The processor 11 is connected to the decompression module 21.
[0032] The processor 11 is connected to the external external memory 31 and the external main memory 41. The decompression module 21 is connected to the external main memory 41.
[0033] Among them, the processor 11 is a central processing unit, the external memory 31 is a Flash memory, and the main memory 41 is a double data rate synchronous dynamic random access memory.
[0034] The processor 11 is used to obtain the compressed image file from the external memory 31, load the compressed image file to the main memory 41, and configure the status register of the decompression module 21.
[0035] The compressed image file is obtained by compressing the original image file during the image compilation stage and then performing Huffman coding, and is stored in the external memory 31.
[0036] The data status of the status register of the compressed image file decompression module 21 includes a decompression mode, a data acquisition address, a data storage address, and a startup control bit. The decompression mode is used to configure the way for the decompression module to perform decompression, specifically including a block decompression mode, a multi-file decompression mode, and a normal mode. The data acquisition address is used to indicate the specific data storage area in the main memory 41 where the compressed image file is loaded. The data storage address is used to indicate the specific data storage area in the main memory 41 where the decompressed compressed image file needs to be stored. The startup control bit is used to control whether the decompression module runs. Among them, when the startup control bit is set to "1", it starts to work, and when it is reset to "0", it stops working.
[0037] The decompression module 21 includes a Huffman decoding unit and an LZ4 decompression unit, and the Huffman decoding unit is connected to the LZ4 decompression unit.
[0038] The decompression module 21 is used to work according to the data status of its status register, including: starting or stopping working according to the status of the start control bit. When starting to work, according to the decompression mode, obtain the compressed image file from the data storage area corresponding to the data acquisition address, decode the compressed image file through the Huffman decoding unit, and then decompress the decoded compressed image file through the LZ4 decompression unit, and store the decompressed compressed image file in the data storage area corresponding to the data storage address.
[0039] In this embodiment, the LZ4 decompression unit realizes the decompression of the decoded compressed image file through the LZ4 algorithm. The LZ4 algorithm is relatively simple, has a small hardware implementation area, and a fast decompression speed. The average decompression speed can reach 1GB / s - 2GB / s. The LZ4 algorithm is a prior art, see Figure 2 , and the example process of LZ4 decompression includes: (1) frame header decoding: including magic number judgment, FLG decoding (parameter setting situation), content size (decoded file size), head check (frame header hashchecksum); (2) litrals data decoding: litrals data is non-matching data, and after decoding the litrals length, the litrals data can be directly output; (3) match data decoding: match data is matching data, and when the matchoffset (match data offset address) and match length are decoded, the match data can be copied from the dictionary and output; (4) judge whether the block is decompressed completely according to the block length; (5) Block end decoding: check whether the checksum is correct.
[0040] Example of a method for quickly starting an embedded system:
[0041] This embodiment is implemented based on the above embodiment. When starting the embedded system that realizes quick start, the processor loads the compressed image file from the external memory to the main memory, and then decompresses the compressed image file in the main memory through the decompression module, so as to execute the decompressed compressed image file and realize the quick start of the system. See Figure 2 , specifically including the following steps:
[0042] S1: The processor loads the compressed image file from the external memory to the main memory.
[0043] S2: The processor configures the status register of the decompression module.
[0044] S3: According to the decompression mode, the decompression module obtains the compressed image file from the data storage area corresponding to the data acquisition address and decompresses it, and stores the decompressed compressed image file in the data storage area corresponding to the data storage address.
[0045] S4: The processor executes the decompressed compressed image file.
[0046] In the above step S1, if the compressed image file includes multiple compressed image sub-files, at least one compressed image sub-file has been loaded into the main memory; if the compressed image file includes multiple data blocks, at least the first data block has been loaded into the main memory. When the decompression module is working, it does not affect the processor from loading the next data block or the next compressed image sub-file of the compressed image file, that is, the processor and the decompression module work in parallel. When the decompression module is working, it is necessary to ensure that the data block or the compressed image sub-file that the decompression module currently needs to decompress has been loaded into the main memory.
[0047] In the above step S2, the processor configures the status register of the decompression module by means of software configuration. The configuration of the status register of the decompression module is configured according to the characteristics of the compressed image file.
[0048] For a compressed image file that occupies a large storage space, when the decompression module does not have the memory space to load the entire compressed image file, the decompression mode needs to be configured as a block decompression mode, and the decompression length is configured to decompress the compressed image file in blocks.
[0049] For a compressed image file with multiple compressed image sub-files, the decompression mode needs to be configured as a multi-file decompression mode, so that the processor can complete the decompression of multiple compressed image sub-files by starting the decompression module once. The decompression module does not need to initiate interrupts frequently, saving interrupt time and improving decoding efficiency. In the multi-file decompression mode, after the decompression module is started, it decompresses each compressed image sub-file in sequence until the last compressed image sub-file is decompressed and stored in the main memory before sending out an interrupt once, rather than sending out an interrupt after each compressed image sub-file is decompressed.
[0050] Each compressed image sub-file has a corresponding data acquisition address and data storage address. When configuring the status register of the decompression module through software, the data acquisition address and data storage address of each compressed image sub-file will be written into the status register. Therefore, when the decompression module starts, it will sequentially complete the decompression of each compressed image sub-file according to the order of the addresses stored in the status register. For example, when the processor detects that there are 2 compressed image sub-files, after the first compressed image sub-file is loaded into the main memory, the data acquisition address of the first compressed image sub-file is written into the first read address position of the status register, and the data storage address of the first compressed image sub-file is written into the first write address position of the status register; the decompression module reads the first read address position and the first write address position of the status register, thereby obtaining the first compressed image sub-file from the data storage area corresponding to the data acquisition address of the first compressed image sub-file and completing the decompression operation, and storing the decompressed first compressed image sub-file in the data storage area corresponding to the data storage address of the first compressed image sub-file; while the decompression module is working, the processor continues to load, and the processor loads the second compressed image sub-file into the main memory. After completing the loading of the second compressed image sub-file, the data acquisition address of the second compressed image sub-file is written into the second read address position of the status register, and the data storage address of the second compressed image sub-file is written into the second write address position of the status register; the decompression module reads the second read address position and the second write address position of the status register, thereby obtaining the second compressed image sub-file from the data storage area corresponding to the data acquisition address of the second compressed image sub-file and completing the decompression operation, and storing the decompressed second compressed image sub-file in the data storage area corresponding to the data storage address of the second compressed image sub-file.
[0051] For a general single compressed image file, the decompression mode needs to be configured as the normal mode, and the compressed image file is directly decompressed.
[0052] See Figure 3 , when the compressed image file loaded in step S1 needs to occupy a large storage space, and the decompression mode configured in S2 is the block decompression mode, and the configured decompression length is the decompression length of the first data block of the compressed image file, then step S3 specifically includes the following steps:
[0053] S31: The decompression module obtains the data block of the compressed image file from the data storage area corresponding to the data acquisition address and decompresses it according to the decompression length, and stores the decompressed data block in the data storage area corresponding to the data storage address.
[0054] Among them, the compressed image module of this embodiment includes N data blocks. When the decompression module first executes step S32, it obtains the first data block of the compressed image file from the data storage area corresponding to the current data acquisition address, decompresses the first data block, and stores the decompressed first data block in the data storage area corresponding to the current data storage address. When the decompression module executes step S31 for the second time, it obtains the second data block of the compressed image file from the data storage area corresponding to the current data acquisition address, decompresses the second data block, and stores the decompressed second data block in the data storage area corresponding to the current data storage address. Similarly, when the decompression module executes step S31 for the Nth time, it realizes decompressing the Nth data block of the compressed image file and storing it in the data storage area corresponding to the current data storage address.
[0055] Among them, when the compressed image module decompresses each data block, it includes: decoding the data block through the Huffman decoding unit, decompressing the decoded data block through the LZ4 decompression unit, and storing the decompressed data block in the data storage area corresponding to the data storage address.
[0056] S32: The decompression module issues an interrupt.
[0057] Among them, the decompression module notifies the processor that the decompression of the current data block has been completed and stored in the current data storage space by initiating an interrupt.
[0058] S33: Determine whether all data blocks have been decompressed.
[0059] Among them, the processor determines whether all data blocks of the compressed image file have been decompressed, that is, whether all data blocks have been decompressed and stored in the main memory. If the judgment result is yes, it continues to execute step S4; otherwise, it executes step S34.
[0060] S34: The processor updates the status register.
[0061] Among them, the processor updates the decompression length, data acquisition address, and data storage address according to the next data block of the compressed image file, and then returns to step S31.
[0062] Thus, since the decompression length is set according to the actual size of each data block, when decompressing each data block, it can be decompressed according to the decompression length corresponding to the actual size of the data block, improving the decompression efficiency.
[0063] See Figure 4 , when the compressed image file loaded in step S1 includes multiple compressed image sub-files and the decompression mode configured in S2 is the multi-file decompression mode, step S3 specifically includes the following steps:
[0064] S31': The decompression module sequentially obtains the compressed image sub-files from the data storage area corresponding to the data acquisition address and decompresses them, and stores the decompressed compressed image sub-files in the data storage area corresponding to the data storage address until all the decompressed compressed image sub-files are stored in the data storage area corresponding to the data storage address.
[0065] Before the decompression module starts, it reads the data acquisition address and data storage address of a compressed image sub-file from the status register. Then the decompression module starts. After completing the decompression of the compressed image sub-file, it reads the data acquisition address and data storage address of the next compressed image sub-file from the status register and performs the decompression of the next compressed image sub-file. And so on, until all the decompression operations of the compressed image sub-files are completed.
[0066] When the decompression module decompresses each compressed image sub-file, it includes: decoding the compressed image sub-file through the Huffman decoding unit, decompressing the decoded compressed image sub-file through the LZ4 decompression unit, and storing the decompressed data block in the data storage area corresponding to the data storage address.
[0067] S32': The decompression module issues an interrupt.
[0068] When the compressed image file loaded in step S1 does not exceed the cache capacity of the decompression module, there is no need to decompress in blocks; when the compressed image file loaded in step S1 does not include multiple compressed image sub-files, there is also no need to adopt the multi-file decompression method. At this time, that is, the decompression module obtains the compressed image file from the data storage area corresponding to the data acquisition address and decompresses it, and stores the decompressed compressed image file in the data storage area corresponding to the data storage address.
[0069] It can be understood that for the next compressed image file required for the startup of the embedded system, it can also be decompressed and loaded into the main memory according to the above steps S1 to S3.
[0070] In summary, the processor of the present invention loads the compressed image file and configures the status register of the decompression module, so that the decompression module decompresses the compressed image file according to the status register. Since the decompression mode in the status register can be configured according to the actual situation of each compressed image file, it has higher flexibility and decompression efficiency, thereby improving the startup speed of the embedded system.
Claims
1. A fast startup method for an embedded system, characterized in that Including the following steps: The processor loads the compressed image file from the external memory to the main memory; The processor configures the status register of the decompression module, and the status register includes a decompression mode, a data acquisition address, and a data storage address, wherein the data storage areas corresponding to the data acquisition address and the data storage address are both located in the main memory; The decompression module acquires and decompresses the compressed image file from the data storage area corresponding to the data acquisition address according to the decompression mode, and stores the decompressed compressed image file in the data storage area corresponding to the data storage address.
2. The method for quickly starting an embedded system according to claim 1, wherein: The decompression mode is a block decompression mode; The status register includes a decompression length; The decompression module acquires and decompresses the compressed image file from the data storage area corresponding to the data acquisition address according to the decompression mode, and stores the decompressed compressed image file in the data storage area corresponding to the data storage address, including the following steps: The decompression module acquires the first data block of the compressed image file from the data storage area corresponding to the data acquisition address and decompresses it according to the decompression length, stores the decompressed first data block in the data storage area corresponding to the data storage address, and issues an interrupt; The processor updates the decompression length, the data acquisition address, and the data storage address of the current status register; The decompression module acquires the second data block of the compressed image file from the data storage area corresponding to the updated data acquisition address and decompresses it according to the updated decompression length, and stores the decompressed second data block in the data storage area corresponding to the updated data storage address.
3. The method for quickly starting an embedded system according to claim 1, wherein: The decompression mode is a multi-file decompression mode; The compressed image file includes a plurality of compressed image sub-files; The decompression module acquires and decompresses the compressed image file from the data storage area corresponding to the data acquisition address according to the decompression mode, and stores the decompressed compressed image file in the data storage area corresponding to the data storage address, including: The decompression module sequentially acquires and decompresses the compressed image sub-files from the data storage area corresponding to the data acquisition address, and stores the decompressed compressed image sub-files in the data storage area corresponding to the data storage address, and issues an interrupt until all the decompressed compressed image sub-files are stored in the data storage area corresponding to the data storage address.
4. The method for quickly starting an embedded system according to claim 1, wherein: The decompression mode is a normal decompression mode; The decompression module acquires and decompresses the compressed image file from the data storage area corresponding to the data acquisition address according to the decompression mode, and issues an interrupt after storing the decompressed compressed image file in the data storage area corresponding to the data storage address.
5. The method for quickly starting an embedded system according to any one of claims 1 to 4, wherein: The compressed image file is obtained by compressing the original image file using the LZ4 algorithm; The decompression module decompresses the compressed image file according to the LZ4 algorithm.
6. The method for rapid startup of an embedded system according to any one of claims 5, wherein: The compressed image file is obtained by compressing the original image file using the LZ4 algorithm and then performing Huffman coding; The decompression module decodes the compressed image file according to Huffman coding and then decompresses the compressed image file according to the LZ4 algorithm.
7. An embedded system for achieving fast startup, characterized in that, It includes: A processor and a decompression module; The processor is connected to the decompression module, and is also connected to an external external memory and main memory. The decompression module is connected to the external memory and the main memory; The processor is used to load the compressed image file from the external memory to the main memory and configure the status register of the decompression module. The status register includes a decompression mode, a data acquisition address, and a data storage address; The decompression module is used to obtain the compressed image file from the data storage area corresponding to the data acquisition address according to the decompression mode and decompress it, and store the decompressed compressed image file in the data storage area corresponding to the data storage address.
8. The embedded system for achieving rapid startup according to claim 7, wherein: The decompression module is an LZ4 decompression unit.
9. The embedded system for achieving rapid startup according to claim 7, wherein: The decompression module further includes a Huffman decoding unit, and the Huffman decoding unit is connected to the LZ4 decompression unit.
