Chip startup method based on NorFlash interface
By compressing the chip startup file and using the chip partition table and uncompressed file header for quick reading and decompression, the problem of NorFlash storage space is solved, and an efficient and reliable chip startup process is achieved.
Patent Information
- Application Number
- CN202210555555.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-19
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2042-05-19
AI Technical Summary
During the startup process, the size of the code and parameter configuration data such as BootLoader and Firmware is not fixed, resulting in waste of NorFlash storage space, which increases costs.
By compressing and storing the files required for chip startup into NorFlash, and using chip partition tables and uncompressed file headers to achieve rapid reading, decompression and loading, reducing storage space usage and improving the reliability of the startup process.
It effectively reduces storage space usage, improves the reliability of chip startup and simplicity of implementation, and reduces costs.
Smart Images

Figure CN114911533B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of digital signal processing, and in particular relates to a chip startup method based on a NorFlash interface. Background Art
[0002] With the development of economy and technology and the improvement of people's living standards, high-performance chips have been widely used in people's production and life, bringing endless convenience to people's production and life.
[0003] For some high-performance NorFlash-booted chips, they usually go through multiple boot stages before they can finally run the chip firmware. For example, after the chip is powered on, the first-level hardware boot code (generally called BootRom) is executed by default. The first-level boot code loads the second-level boot code (generally called BootLoader) from NorFlash. BootLoader will initialize different peripherals and load the corresponding firmware code (generally called Firmware) according to the product positioning of the chip, so that the business of the chip product can really run.
[0004] However, the above chip startup process has the following defects: because the sizes of BootLoader, Firmware and other codes, parameter configuration data, resource files, etc. related to different products of the same chip are not fixed, it is necessary to reserve storage space in the NorFlash of the chip. At this time, the reserved storage space will be relatively large, resulting in a waste of storage space; moreover, the storage location of the above codes and files in the storage space is currently randomly determined, which may cause a large amount of NorFlash storage space to be wasted. The waste of a large amount of NorFlash storage space will bring about a significant and serious cost increase. Summary of the invention
[0005] The object of the present invention is to provide a chip startup method based on a NorFlash interface which occupies less storage space, has high reliability and is simple and convenient to implement.
[0006] The chip startup method based on the NorFlash interface provided by the present invention comprises the following steps:
[0007] S1. Compress the files required for chip startup and store them in the chip's NorFlash; store the corresponding compressed information data at the same time;
[0008] S2. When the chip is powered on, BootRom performs the bottom-level initialization operation;
[0009] S3.BootRom performs peripheral initialization operations;
[0010] S4. Read the stored compressed information data;
[0011] S5. According to the compressed information data read, the BootLoader program is loaded and executed by decompression inspection;
[0012] S6. BootLoader program execution phase, the Firmware program is loaded and executed by decompression and inspection;
[0013] S7. Firmware program execution phase, use the decompression test method to load and execute resource files and parameter files;
[0014] S8. After all files are loaded and executed, the chip startup is completed.
[0015] The step S1 specifically includes the following steps:
[0016] A. Keep the BootRom program file;
[0017] B. Determine whether the Bootloader program file exists:
[0018] If the Bootloader program file exists, the Bootloader program file is compressed and stored in the NorFlash of the chip, while retaining the uncompressed file header of the Bootloader program file; the uncompressed file header is used to store the data information of the compressed file;
[0019] If the Bootloader program file does not exist, proceed directly to the subsequent steps;
[0020] C. Compress the firmware program file and store the compressed file in the NorFlash of the chip, while retaining the uncompressed file header of the firmware program file;
[0021] D. Determine whether a resource file exists:
[0022] If a resource file exists, the resource file is compressed and stored in the NorFlash of the chip, while the uncompressed file header of the resource file is retained;
[0023] If the resource file does not exist, proceed directly to the next step;
[0024] E. Determine whether a parameter file exists:
[0025] If a parameter file exists, compress the parameter file and store the compressed file in the NorFlash of the chip, while retaining the uncompressed file header of the parameter file;
[0026] If the parameter file does not exist, proceed directly to the subsequent steps;
[0027] F. Based on the principle of minimizing storage space usage, all files obtained in steps A to E are stored in the NorFlash of the chip;
[0028] G. Construct a chip partition table file and store it in the NorFlash of the chip; the chip partition table file is used to record the storage information of all files in step A to step E.
[0029] The uncompressed file header specifically includes compressed data length, QSPI / SPI parameters, decompression parameters and verification information.
[0030] The step G specifically comprises the following steps:
[0031] Construct a chip partition table file; the chip partition table file is used to store information of all files in step A to step E;
[0032] The chip partition table file occupies the first sector of the chip's NorFlash;
[0033] In the chip partition table file, each partition is 32 bytes, and a maximum of 32 partitions are included; the information of each partition includes the partition name, partition address, partition size, verification information and partition flag information.
[0034] The step S3 specifically includes the following steps:
[0035] Read the chip partition table file from the chip's NorFlash;
[0036] Check whether the read chip partition table file is valid:
[0037] If it works, proceed to the next steps;
[0038] If wireless, it is considered that the startup has failed.
[0039] The decompression test method specifically includes the following steps:
[0040] a. Read the partition item information corresponding to the file or program currently to be loaded according to the read chip partition table file;
[0041] b. Check whether the partition entry information read in step a is valid:
[0042] If it works, proceed to the next steps;
[0043] If it is wireless, it is considered that the startup has failed;
[0044] c. Read the corresponding uncompressed file header from the chip's NorFlash according to the read partition item information;
[0045] d. Check whether the uncompressed file header read in step c is legal:
[0046] If it is legal, proceed to the next step;
[0047] If it is illegal, the startup is deemed to have failed;
[0048] e. According to the read uncompressed file header, obtain the decompression parameters and initialize the decompression controller;
[0049] f. According to the read uncompressed file header, obtain QSPI / SPI parameters and initialize the QSPI / SPI controller to maximize the reading performance of the chip's NorFlash;
[0050] g. Read the compressed data from the chip's NorFlash according to the read uncompressed file header, and store it in the chip's internal memory:
[0051] If the compressed data is read successfully, continue with the subsequent steps;
[0052] If the compressed data fails to be read, the startup is deemed to have failed;
[0053] h. Decompress the compressed data:
[0054] If the decompression is successful, continue with the subsequent steps;
[0055] If the decompression fails, the startup is considered to have failed;
[0056] i. Verify the decompressed data:
[0057] If the verification is successful, the file or program that needs to be loaded is loaded successfully;
[0058] If the verification fails, the startup is considered to have failed.
[0059] The chip startup method based on the NorFlash interface provided by the present invention greatly reduces the requirement for storage space by compressing files and storing them; fast reading, decompression and loading of compressed files are realized through chip partition table files and non-compressed file header files; therefore, the method of the present invention occupies less storage space for chip startup process files, and the startup process has higher reliability and is simple and convenient to implement. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 The figure is a schematic diagram of the method flow of the present invention. DETAILED DESCRIPTION
[0061] like Figure 1 The method flow chart of the method of the present invention is shown as follows: the chip startup method based on the NorFlash interface provided by the present invention comprises the following steps:
[0062] The chip described in the present invention supports hard decryption function (including gzip / lz4 / lzo / lzma, etc.), hard verification function (including CRC16 / CRC32, etc.), Qspi / Spi related NorFlash interface function, and DMA data transmission function;
[0063] S1. Compress the files required for chip startup and store them in the NorFlash of the chip; and store the corresponding compressed information data at the same time; specifically, the steps include:
[0064] A. Keep the BootRom program file;
[0065] B. Determine whether the Bootloader program file exists:
[0066] If the Bootloader program file exists, the Bootloader program file is compressed and stored in the NorFlash of the chip, while retaining the uncompressed file header of the Bootloader program file; the uncompressed file header is used to store the data information of the compressed file;
[0067] If the Bootloader program file does not exist, proceed directly to the subsequent steps;
[0068] C. Compress the firmware program file and store the compressed file in the NorFlash of the chip, while retaining the uncompressed file header of the firmware program file;
[0069] D. Determine whether a resource file exists:
[0070] If a resource file exists, the resource file is compressed and stored in the NorFlash of the chip, while the uncompressed file header of the resource file is retained;
[0071] If the resource file does not exist, proceed directly to the next step;
[0072] E. Determine whether a parameter file exists:
[0073] If a parameter file exists, compress the parameter file and store the compressed file in the NorFlash of the chip, while retaining the uncompressed file header of the parameter file;
[0074] If the parameter file does not exist, proceed directly to the subsequent steps;
[0075] F. Based on the principle of minimizing storage space usage, all files obtained in steps A to E are stored in the NorFlash of the chip;
[0076] G. Construct a chip partition table file and store it in the NorFlash of the chip; the chip partition table file is used to record the storage information of all files in step A to step E; specifically, the steps include:
[0077] Construct a chip partition table file; the chip partition table file is used to store information of all files in step A to step E;
[0078] The chip partition table file occupies the first sector of the chip's NorFlash, namely 0sector;
[0079] In the chip partition table file, each partition is 32 bytes, and a maximum of 32 partitions are included; the information of each partition includes the partition name, partition address, partition size, verification information and partition flag information;
[0080] In specific implementation, the uncompressed file header specifically includes the compressed data length, QSPI / SPI parameters, decompression parameters and checksum information;
[0081] S2. When the chip is powered on, BootRom performs the bottom-level initialization operation;
[0082] S3.BootRom performs peripheral initialization operations; specifically includes the following steps:
[0083] Read the chip partition table file from the chip's NorFlash;
[0084] Check whether the read chip partition table file is valid:
[0085] If it works, proceed to the next steps;
[0086] If it is wireless, it is considered that the startup has failed;
[0087] S4. Read the stored compressed information data;
[0088] S5. According to the compressed information data read, the BootLoader program is loaded and executed by decompression inspection; when implemented, if there is a Bootloader program, this step is performed; if there is no Bootloader program, this step is not required;
[0089] S6. BootLoader program execution phase, the Firmware program is loaded and executed by decompression and inspection. In specific implementation, if the Firmware program exists, this step is executed; if the Firmware program does not exist, this step is not required.
[0090] S7. Firmware program execution stage, the resource file and parameter file are loaded and executed by decompression and inspection; in specific implementation, if the execution resource file and parameter file exist, this step is executed; if the execution resource file and parameter file do not exist, this step is not required;
[0091] S8. After all files are loaded and executed, the chip startup is completed.
[0092] In specific implementation, the above decompression test method specifically includes the following steps:
[0093] a. Read the partition item information corresponding to the file or program currently to be loaded according to the read chip partition table file;
[0094] b. Check whether the partition entry information read in step a is valid:
[0095] If it works, proceed to the next steps;
[0096] If it is wireless, it is considered that the startup has failed;
[0097] c. Read the corresponding uncompressed file header from the chip's NorFlash according to the read partition item information;
[0098] d. Check whether the uncompressed file header read in step c is legal:
[0099] If it is legal, proceed to the next step;
[0100] If it is illegal, the startup is deemed to have failed;
[0101] e. According to the read uncompressed file header, obtain the decompression parameters and initialize the decompression controller;
[0102] f. According to the read uncompressed file header, obtain QSPI / SPI parameters and initialize the QSPI / SPI controller to maximize the reading performance of the chip's NorFlash;
[0103] g. Read the compressed data from the chip's NorFlash according to the read uncompressed file header, and store it in the chip's internal memory:
[0104] If the compressed data is read successfully, continue with the subsequent steps;
[0105] If the compressed data fails to be read, the startup is deemed to have failed;
[0106] h. Decompress the compressed data:
[0107] If the decompression is successful, continue with the subsequent steps;
[0108] If the decompression fails, the startup is considered to have failed;
[0109] ii. Verify the decompressed data:
[0110] If the verification is successful, the file or program that needs to be loaded is loaded successfully;
[0111] If the verification fails, the startup is considered to have failed.
Claims
1. A chip startup method based on NorFlash interface, characterized in that The steps include: S1. Compress the files required for chip startup and store them in the chip's NorFlash; also store the corresponding compressed information data. Specifically, the steps include: A. Keep the BootRom program file; B. Determine whether the Bootloader program file exists: If the Bootloader program file exists, the Bootloader program file is compressed and stored in the chip's NorFlash, while retaining the uncompressed file header of the Bootloader program file; the uncompressed file header is used to store the data information of the compressed file; If the Bootloader program file does not exist, proceed directly to the subsequent steps; C. compressing the firmware program file and storing the compressed file in the chip's NorFlash, while retaining the uncompressed file header of the firmware program file; the uncompressed file header specifically includes the compressed data length, QSPI / SPI parameters, decompression parameters, and checksum information; D. Determine whether the resource file exists: If a resource file exists, compress it and store the compressed file in the chip's NorFlash, while retaining the uncompressed file header of the resource file. If the resource file does not exist, proceed directly to the next steps; E. Determine whether the parameter file exists: If a parameter file exists, compress it and store the compressed file in the chip's NorFlash, while retaining the uncompressed file header of the parameter file. If the parameter file does not exist, proceed directly to the subsequent steps; F. Based on the principle of minimizing storage space, store all files obtained in steps A to E into the chip's NorFlash; G. Construct a chip partition table file and store it in the chip's NorFlash. The chip partition table file is used to record the storage information of all files in steps A to E. Specifically, the steps include: Construct a chip partition table file; the chip partition table file is used to store information of all files in steps A to E; The chip partition table file occupies the first sector of the chip's NorFlash; In the chip partition table file, each partition is 32 bytes, and a maximum of 32 partitions are included; the information of each partition includes the partition name, partition address, partition size, checksum information, and partition flag information; S2. When the chip is powered on, BootROM performs low-level initialization operations; S3.BootRom performs peripheral initialization operations; specifically includes the following steps: Read the chip partition table file from the chip's NorFlash; Check whether the read chip partition table file is valid: If it is effective, proceed to the next steps; If it is wireless, it is considered that the startup has failed; S4. Read the stored compressed information data; S5. Based on the compressed information data read, the decompression test method is used to load and execute the BootLoader program; S6. BootLoader program execution phase, using the decompression test method to load and execute the firmware program; S7. Firmware program execution phase, using the decompression test method to load and execute resource files and parameter files; S8. After all files are loaded and executed, the chip is started; The decompression test method specifically includes the following steps: a. Read the partition entry information corresponding to the file or program currently to be loaded based on the read chip partition table file; b. Check whether the partition entry information read in step a is valid: If it is effective, proceed to the next steps; If it is wireless, it is considered that the startup has failed; c. Read the corresponding uncompressed file header from the chip's NorFlash according to the read partition entry information; d. Check whether the uncompressed file header read in step c is legal: If it is legal, proceed to the next step; If it is illegal, the startup is deemed to have failed; e. According to the read uncompressed file header, obtain the decompression parameters and initialize the decompression controller; f. According to the read uncompressed file header, obtain the QSPI / SPI parameters and initialize the QSPI / SPI controller to maximize the chip's NorFlash reading performance; g. Read the compressed data from the chip's NorFlash according to the read uncompressed file header and store it in the chip's internal memory: If the compressed data is read successfully, continue with the subsequent steps; If the compressed data fails to be read, the startup is deemed to have failed; h. Decompress compressed data: If the decompression is successful, continue with the subsequent steps; If the decompression fails, the startup is considered to have failed; i. Verify the decompressed data: If the verification is successful, the file or program that needs to be loaded is loaded successfully; If the verification fails, the startup is deemed to have failed.
