Dual-region code boot maintenance method for nonvolatile memory of embedded computer

By employing a dual-zone boot maintenance method using non-volatile memory in embedded computers and utilizing CRC32 verification of the main boot zone and backup boot zone, the problem of DSP program failure caused by FLASH data flipping is solved, thereby improving the reliability and stability of the embedded system.

CN121919045APending Publication Date: 2026-04-24SHAANXI CHANGLING ELECTRONICS TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-29
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

In existing technologies, data stored in FLASH may cause data flipping errors as storage time increases, leading to reduced reliability of embedded systems. In particular, errors in the secondary bootloader can cause DSP programs to fail to load and run normally.

Method used

A dual-zone boot maintenance method using non-volatile memory is adopted, including a main boot sector and a backup boot sector. Through CRC32 checksum and dual program area design, it is ensured that the correct secondary boot program can be loaded from the backup boot sector when the main boot sector is faulty. Verification is performed before loading the DSP program to achieve automatic code maintenance.

Benefits of technology

It improves the reliability of embedded systems, ensures that DSP programs can be loaded and run correctly, and achieves automatic code repair through the design of dual boot sectors and program sectors, thereby enhancing the stability and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121919045A_ABST
    Figure CN121919045A_ABST
Patent Text Reader

Abstract

The invention discloses a nonvolatile memory double-area code guide maintenance method of an embedded computer, and mainly solves the problem that an embedded system cannot normally operate due to FLASH bit flipping errors in the prior art. According to the implementation scheme, the method comprises the following steps: selecting a double-boot area and a double-program area from a FLASH storage space, and writing a secondary boot program and a DSP program into the areas; determining whether to load the backup boot area or not through the DSP configuration chip; selecting a loading program area according to whether the DSP program code of the main program area is intact or not; the DSP program reads secondary bootstrap program codes from the main bootstrap area and the backup bootstrap area, CRC32 verification is carried out on the secondary bootstrap program codes, bootstrap area codes needing to be repaired are determined, program codes are read from the main program area and the backup program area, CRC32 verification is carried out on the program codes, and program area codes needing to be repaired are determined; and repairing the codes of the bootstrap area or the program area needing to be repaired through the codes of the other bootstrap area or the program area. According to the method, the reliability of the DSP chip is improved, and the method can be used for an embedded computer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of embedded computers, and specifically relates to a dual-zone code boot and maintenance method for non-volatile memory, which can be used in TMS320C6700 series DSP chips in embedded computers. Background Technology

[0002] The mainstream system architecture in the modern embedded computer field generally consists of DSP + FPGA + peripheral devices. As the computing and control core of the embedded system, the program code running on the DSP is generally fixed in the off-chip non-volatile memory FLASH chip. After the system is powered on, the DSP loads the code from FLASH into the DSP for execution.

[0003] After the TMS320C6700 series DSP is powered on, for the DSP program to run normally, the first-level bootloader built into the DSP first needs to load the second-level bootloader from the specified FLASH space. After the second-level bootloader runs, it will load the DSP main program stored in FLASH into the DSP and point the program pointer to the DSP program entry point, so that the DSP program can run normally.

[0004] With the widespread use of FLASH chips, the inherent defects of FLASH have gradually been exposed. As the storage time increases, the data stored in FLASH will change from "0" to "1", resulting in code errors and reducing the reliability of embedded systems. If the secondary bootloader has an error, the DSP program will fail to load and run normally. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of the prior art by proposing a dual-zone boot maintenance method for non-volatile FLASH memory, thereby avoiding the problem of DSP programs failing to load and run normally due to data flip errors, achieving code maintenance, and improving the reliability of embedded systems.

[0006] To achieve the above objectives, the technical solution of the present invention includes the following:

[0007] 1. A dual-zone boot maintenance method for non-volatile memory of an embedded computer, characterized in that it includes:

[0008] (1) Select the first sector from the FLASH storage space as the master boot sector, and select the other 3 sectors as the backup boot sector, the main program sector and the backup program sector respectively;

[0009] (2) Read the secondary bootloader code and DSP program code from the target file, and perform CRC32 verification on them to obtain their respective checksums;

[0010] (3) Write the secondary boot program into the main boot sector and the backup boot sector respectively, and write the secondary boot program checksum into the end of the sector of each of the two boot sectors respectively; write the DSP code into the main program sector and the backup program sector respectively, and write the code length and checksum into the end of the sector of each of the two program sectors;

[0011] (4) Determine whether the DSP program is running through the DSP configuration chip: If the DSP program is not running, the configuration chip resets the DSP and forcibly pulls up the address line corresponding to the FLASH backup boot area, guiding the DSP to load the secondary boot program through the backup boot area; otherwise, execute (5).

[0012] (5) Perform CRC32 verification on the DSP program code read from the main program area through the secondary boot program, and compare the checksum with the checksum pre-stored at the end of the main program area to determine the running program area;

[0013] (6) The DSP program reads 1K Byte of data from the main boot sector and the backup boot sector and performs CRC32 verification on each. It then compares the checksums obtained from the two boot sectors with the checksums pre-stored at the end of each boot sector and determines whether to repair the boot sector code based on the comparison results.

[0014] (7) The DSP program reads the DSP program code from the main program area and the backup program area, performs CRC32 verification on the DSP code according to the pre-stored code length, and compares the checksums obtained from the two program areas with the checksums pre-stored at the end of the respective program areas to determine whether to repair the program area code.

[0015] (8) For a boot sector that needs to be repaired, repair the boot sector code through the code of another boot sector; for a program sector that needs to be repaired, repair the program sector code through the code of another program sector.

[0016] Terminology Explanation:

[0017] The program that will actually run in the DSP is called a DSP program;

[0018] The non-volatile FLASH sector that stores the secondary boot program code is called the boot sector;

[0019] The non-volatile FLASH sector that stores DSP program code is called the program area;

[0020] Changing the data in a non-volatile FLASH memory cell from "0" to "1" is called FLASH bit flipping.

[0021] The system features a dual boot sector setup, including a primary boot sector and a backup boot sector. Both sectors store the same secondary bootloader. If an error in the primary boot sector prevents the system from functioning, the DSP can load the secondary bootloader from the backup boot sector.

[0022] Compared with the prior art, the present invention has the following advantages:

[0023] First, because the present invention designs a dual boot sector boot strategy, the DSP can load a secondary boot program through a backup boot sector. When the main boot sector code cannot work properly, the backup boot sector program can be used to load the DSP program, ensuring that the correct secondary boot program can run.

[0024] Second, because the present invention designs a dual program area loading strategy, that is, by adding a CRC32 verification function to the secondary boot program, the secondary boot program can verify the DSP program stored in the non-volatile memory FLASH before loading the DSP program, ensuring that the correct DSP program is loaded into the DSP for execution.

[0025] Third, based on the dual boot sector and dual program sector design of non-volatile memory FLASH, this invention designs a corresponding DSP code verification and programming method, which can realize automatic maintenance of boot sector code and program sector code. Attached Figure Description

[0026] Figure 1 This is a flowchart illustrating the implementation of the present invention;

[0027] Figure 2 This is a flowchart of the secondary bootloader and DSP main program code file parsing sub-flowchart in this invention;

[0028] Figure 3 This is a diagram showing the connection relationship between the DSP, CPLD, and FLASH in this invention;

[0029] Figure 4 This is a flowchart of the boot sector verification and maintenance sub-process in this invention;

[0030] Figure 5 This is a flowchart of the program area verification and maintenance sub-process in this invention. Detailed Implementation

[0031] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments. Other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort should fall within the protection scope of the present invention. (Refer to...) Figure 1The implementation steps of this example include:

[0032] Step 1: Select the dual boot sector and dual program sector in FLASH.

[0033] The FLASH is a non-volatile memory, which is internally divided into sectors as shown in Table 1.

[0034] Table 1 FLASH Internal Sectors

[0035]

[0036] To embed the secondary bootloader and DSP program, a dual boot sector and a dual program sector need to be selected based on the sectors of the FLASH memory. The implementation includes:

[0037] 1.1) Selection of dual pilot zones:

[0038] Based on the property that the DSP can only read the secondary boot program from the first sector of the non-volatile memory FLASH, this example selects the first sector SA0 of the non-volatile memory FLASH as the main boot sector, and selects, but is not limited to, the ninth sector SA8 of the non-volatile memory FLASH as the backup boot sector.

[0039] 1.2) Dual program area selection:

[0040] This example selects, but is not limited to, the third sector SA2 and the fifth sector SA4 of the non-volatile memory FLASH as the main program area and the backup program area.

[0041] Step 2: Write the secondary bootloader and its checksum to the main boot sector SA0 and the backup boot sector SA8, and write the DSP program and its code length and checksum to the main program sector SA2 and the backup program sector SA4.

[0042] 2.1) Parse the target file to obtain the secondary bootloader code and DSP program code:

[0043] Reference Figure 2 The implementation of this step includes the following:

[0044] Read the target file, obtain the number of segments based on the file header data, obtain the program entry address based on the optional header data, and obtain the segment code execution address, segment length, and segment data pointer of the location of the secondary bootloader code and DSP program code based on the segment header data;

[0045] Segment data is extracted based on the segment code execution address, segment length, and segment data pointer. After decompiling, the segment data can be used to obtain the secondary bootloader file and the DSP program file.

[0046] 2.2) Read the secondary bootloader code file and the DSP program code file, and perform CRC32 verification on each of them to generate their respective checksums; then write the secondary bootloader into the SAO sector and SA8 sector of the FLASH respectively, and write the checksum of the secondary bootloader at the end of the sector; write the DSP program into the SA2 sector and SA4 sector of the FLASH respectively, and write the code length and checksum of the DSP program at the end of the sector.

[0047] Step 3: Select whether to load the backup boot sector based on the DSP program's running status.

[0048] Reference Figure 3 The CPLD chip is the configuration chip for the DSP. In the design, the CPLD chip, FLASH and DSP share the address bus EA21:EA2 and the data bus DA7:DA0.

[0049] After the DSP is powered on, it is necessary to select whether to load the backup boot sector based on whether the DSP program is running normally:

[0050] The DSP program periodically sends a watchdog signal to the CPLD chip. The CPLD chip uses the watchdog signal from the DSP to determine whether the DSP program is running normally.

[0051] If a dog feed signal is received from the DSP, it means that the DSP program is running normally and there is no need to load the backup boot sector;

[0052] If the CPLD chip does not detect the dog feed signal 10 seconds after the DSP starts, it means that the DSP has failed to operate normally. At this time, the CPLD chip sets the address bus EA21 high and then resets the DSP. Since the address bus EA21 is 1, the DSP will load the secondary boot program from the backup boot area.

[0053] Step 4: Select the loading program area based on whether the DSP program code in the main program area is intact.

[0054] 4.1) After the secondary boot program starts, it sends a message to the configuration chip CPLD to release control of the address bus EA21;

[0055] 4.2) The secondary bootloader reads the DSP program code from the main program area based on the pre-stored program code length at the end of the main program area and performs CRC32 check to obtain the checksum;

[0056] 4.3) Compare the checksum obtained from the verification with the checksum pre-stored at the end of the main program area:

[0057] If the comparison results are the same, the main program code is intact. Load the main program code into the designated RAM of the DSP and point the program pointer to the program entry point.

[0058] If the comparison results are different, there is a problem with the main program code. Load the backup program code into the designated RAM of the DSP and point the program pointer to the program entry point.

[0059] Step 5: Boot sector code verification and maintenance.

[0060] Reference Figure 4 The implementation of this step includes:

[0061] 5.1) Identify the boot sector code that needs repair:

[0062] 5.1.1) The DSP program reads 1KB of data from the master boot sector and the backup boot sector respectively, performs CRC32 checksum verification on the read data respectively, and obtains the respective checksums;

[0063] 5.1.2) Compare the checksums obtained from the verification with the checksums pre-stored at the end of their respective boot sectors:

[0064] If the checksums of the primary boot sector and the backup boot sector are the same as the checksums pre-stored at the end of their respective boot sectors, M_flag will not be changed and its value will be 0.

[0065] If the checksum of the master boot sector is different from the checksum pre-stored at the end of the master boot sector, it means that the code of the master boot sector is not intact. Set bit 0 of M_flag to 1 and the value of M_flag is 1.

[0066] If the checksum of the backup boot sector is different from the checksum pre-stored at the end of the backup boot sector, it means that the code of the backup boot sector is not intact. Set bit 1 of M_flag to 1 and the value of M_flag to 2.

[0067] If the checksums of the primary boot sector and the backup boot sector are not the same as the checksums pre-stored at the end of their respective boot sectors, set bits 0 and 1 of M_flag to 1, and the value of M_flag to 3.

[0068] 6.1.3) Determine the boot sector code that needs repair based on the value of M_flag in the comparison results:

[0069] If M_flag equals 0, then no code fix is ​​needed;

[0070] If M_flag equals 1, then the master boot sector code needs to be repaired;

[0071] If M_flag equals 2, then the backup boot sector code needs to be repaired;

[0072] If M_flag equals 3, then the corresponding flag is set to indicate that the boot sector code is incorrect and cannot be automatically maintained.

[0073] 5.2) Boot sector code repair

[0074] The DSP program erases the boot sector that needs repair, reads the program code from another boot sector, and then writes it back into the boot sector that needs repair.

[0075] Step 6: Code verification and maintenance in the program area.

[0076] Reference Figure 5 The implementation of this step includes:

[0077] 6.1) Identify the program area that needs repair:

[0078] 6.1.1) The DSP reads the DSP program code from the main program area and the backup program area according to the code length pre-stored at the end of the program area and performs CRC32 verification respectively;

[0079] 6.1.2) Compare the checksums obtained from the verification with the checksum values ​​pre-stored at the end of their respective program areas:

[0080] If the checksums of the main program area and the backup program area are the same as the checksums pre-stored at the end of their respective program areas, M_flag will not be changed and its value will be 0.

[0081] If the checksum in the main program area is different from the checksum pre-stored at the end of the main program area, set bit 0 of M_flag to 1, and the value of M_flag is 1.

[0082] If the checksum in the backup program area is different from the checksum pre-stored at the end of the backup program area, set bit 1 of M_flag to 1 and the value of M_flag to 2.

[0083] If the checksums of the main program area and the backup program area are not the same as the checksums pre-stored at the end of their respective program areas, set bits 0 and 1 of M_flag to 1, and the value of M_flag is 3.

[0084] 6.1.3) Determine the code segment that needs repair based on the value of M_flag in the comparison result:

[0085] If M_flag equals 0, then no code fix is ​​needed;

[0086] If M_flag equals 1, then the main program code needs to be repaired;

[0087] If M_flag equals 2, then the backup program area code needs to be repaired;

[0088] If M_flag equals 3, then the corresponding flag is set to inform the program area code that there is an error and it cannot be automatically maintained.

[0089] 6.2) Code Repair in Program Area

[0090] The DSP program erases the program area that needs repair, reads the program code from another program area, and writes it into the program area that needs repair.

[0091] To verify the effectiveness of the present invention, after the secondary boot program and DSP program were burned into the FLASH, the main boot sector code and main program sector code were manually rewritten using a simulator. After restarting the processor board, the processor board program was able to run normally, thus verifying the feasibility of the dual-sector code boot and maintenance method of the present invention.

[0092] It should be noted that the step numbers in the specification and claims of this invention are only for the purpose of clearly describing the embodiments of this invention and facilitating understanding, and their order is not limited.

Claims

1. A dual-zone boot maintenance method for non-volatile memory in an embedded computer, characterized in that, include: (1) Select the first sector from the FLASH storage space as the master boot sector, and select the other 3 sectors as the backup boot sector, the main program sector and the backup program sector respectively; (2) Read the secondary bootloader code and DSP program code from the target file, and perform CRC32 verification on them to obtain their respective checksums; (3) Write the secondary boot program into the main boot sector and the backup boot sector respectively, and write the secondary boot program checksum at the end of the sector of each of the two boot sectors respectively; write the DSP code into the main program sector and the backup program sector respectively, and write the program length and checksum at the end of the sector of each of the two program sectors; (4) Determine whether the DSP program is running normally by using the DSP configuration chip: If the DSP program is not running normally, the configuration chip resets the DSP and forcibly pulls up the address line corresponding to the FLASH backup boot area, guiding the DSP to load the secondary boot program through the backup boot area; Otherwise, execute (5); (5) Perform CRC32 verification on the DSP program code read from the main program area through the secondary boot program, and compare the checksum with the checksum pre-stored at the end of the main program area to determine the running program area; (6) The DSP program reads 1K Byte of data from the main boot sector and the backup boot sector and performs CRC32 verification on each. It then compares the checksums obtained from the two boot sectors with the checksums pre-stored at the end of each boot sector and determines whether to repair the boot sector code based on the comparison results. (7) The DSP program reads the DSP program code from the main program area and the backup program area, performs CRC32 verification on the DSP code according to the pre-stored code length, and compares the checksums obtained from the two program areas with the checksums pre-stored at the end of the respective program areas to determine whether to repair the program area code. (8) For boot sectors that need repair, repair the boot sector code using the code of another boot sector; For program sections that need repair, the code in that program section is repaired through the code in another program section.

2. The method according to claim 1, characterized in that, In step (4), the DSP program is determined by the DSP configuration chip. Whether it runs or not is determined based on whether the DSP configuration chip receives the DSP's watchdog signal: If the DSP configuration chip receives the DSP's watchdog signal, it determines that the DSP program is running normally. If the DSP configuration chip does not detect the DSP's watchdog signal 10 seconds after the DSP starts, it is determined that the DSP program has not started normally.

3. The method according to claim 1, characterized in that, The step (5) of comparing the checksum with the checksum pre-stored at the end of the main program area to determine the running program area is based on whether the values ​​of the two are the same. If the checksum is the same as the checksum value stored in the main program area, then the DSP program code in the main program area will be executed. If the checksum differs from the checksum value stored in the main program area, the DSP program code in the backup program area will be executed.

4. The method according to claim 1, characterized in that, The step (6) of comparing the checksums obtained from the primary boot sector and the backup boot sector with the checksums pre-stored at the end of their respective boot sectors to determine the repair of the boot sector code is based on whether the values ​​of the checksums of the primary boot sector and the backup boot sector are the same as the values ​​of the checksums pre-stored at the end of their respective boot sectors. If the checksums of the primary boot sector and the backup boot sector are the same as the checksum values ​​pre-stored at the end of their respective boot sectors, then no repair code is needed; If the checksum of the master boot record differs from the checksum value pre-stored at the end of the master boot record, the master boot record code needs to be repaired. If the checksum of the backup boot sector differs from the checksum value pre-stored at the end of the backup boot sector, the backup boot sector code needs to be repaired. If the checksums of the primary boot sector and the backup boot sector are not the same as the checksum values ​​pre-stored at the end of their respective boot sectors, a corresponding flag is set to indicate that the boot sector code is incorrect and cannot be automatically maintained.

5. The method according to claim 1, characterized in that, In step (7), the checksums obtained from the main program area and the backup program area are compared with the checksum values ​​pre-stored at the end of their respective program areas to determine the repair of the program area code. This is determined based on whether the checksums of the main program area and the backup program area are the same as the checksum values ​​pre-stored at the end of their respective program areas. If the checksums of the main program area and the backup program area are the same as the checksum values ​​pre-stored at the end of their respective program areas, then no repair code is needed. If the checksum in the main program area is different from the checksum value pre-stored at the end of the main program area, the code in the main program area needs to be repaired. If the checksum in the backup program area is different from the checksum value pre-stored at the end of the backup program area, the backup program area code needs to be repaired. If the checksums of the main program area and the backup program area are not the same as the checksum values ​​pre-stored at the end of their respective program areas, then a corresponding flag is set to indicate that the program area code is incorrect and cannot be automatically maintained.

6. The method according to claim 1, characterized in that, The step (8) involves repairing the boot sector code by using the code of another boot sector. This is achieved by using a DSP program to erase the boot sector code that needs to be repaired, reading the program code of another boot sector, and then writing it back into the boot sector code that needs to be repaired.

7. The method according to claim 1, characterized in that, In step (8), the program area that needs to be repaired is repaired by the code of another program area. This is achieved by first erasing the program area that needs to be repaired using the DSP program, then reading the program code of another program area and writing it into the program area that needs to be repaired.