Method for preventing false rewriting of configured FLASH in DSP (Digital Signal Processor) power-down process
By software write-protecting FLASH in the DSP system and adding delays in erasing and unprotecting operations, the problem of FLASH being mistakenly rewritten during DSP power-off is solved, simplifying hardware design and reducing costs.
Patent Information
- Application Number
- CN202411414192.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-01-21
AI Technical Summary
During the DSP power outage, the DSP pointer runs away due to the power outage of the IO power outage, which may cause the FLASH to be erroneously rewritten, which will lead to the failure of system startup.
By software write-protecting FLASH and adding delays in erasing and unprotecting operations, it is ensured that there is not enough time to complete these operations during the DSP power-down process, thereby preventing FLASH from being accidentally rewritten.
It effectively prevents the problem of mistaken rewriting of FLASH during DSP power-off, simplifies hardware design, reduces hardware design costs, and eliminates the need to add additional power supply monitoring circuits.
Smart Images

Figure CN119336145A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of industrial control and signal processing, and in particular relates to a method for preventing erroneous rewriting of configuration FLASH during power-off of DSP. Background Art
[0002] In embedded systems with DSP as the core processor, FLASH chips are generally used as storage media to store programs. After the DSP is powered on, the solidified program is loaded from FLASH to the internal RAM space. In general, in order to facilitate the online program upgrade of the product without opening the cover, the online upgrade function will be involved in the program. That is, after receiving the online upgrade instruction, the DSP will enter the online upgrade function and write the new version of the program file to be upgraded to FLASH, that is, only the program upgrade function branch will have a write operation to FLASH. During the normal operation of the program, as long as no upgrade instruction is received, the DSP will only perform read operations during the entire program operation. However, due to the inconsistent power-off order of the DSP core power and IO power during the power-off process of the DSP, if the DSP core power is powered off before the IO power, the DSP program pointer will run away. At this time, the pointer may point to the FLASH write operation part inside the program upgrade, which will cause the system to power off. There may be a millisecond-level period of time to erase the FLASH process. This will cause the content in the FLASH to be rewritten and the next startup to fail.
[0003] To avoid this situation, the usual solution is to add power monitoring chips to the core power and IO power of the DSP to monitor the power-off process of the two voltages. When either the core power or the IO voltage drops to 90% of its specified value, the power monitoring chip will send a continuous low-level reset signal to the DSP and FLASH to prevent the DSP pointer from running away and the FLASH from entering the reset stage and no longer receiving any instructions. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] The technical problem to be solved by the present invention is to design a method to prevent the configuration FLASH from being rewritten by mistake during the power-off process of the DSP, so as to solve the problem of the FLASH being misoperated during the power-off process of the DSP.
[0006] (II) Technical solution
[0007] In order to solve the above technical problems, the present invention provides a method for preventing the configuration FLASH from being accidentally rewritten during the power-off process of the DSP, comprising the following steps:
[0008] Step 1: DSP is powered on, the program is initialized, and Step 2 is executed;
[0009] Step 2: Determine whether FLASH is in write protection state. If FLASH is not in write protection state, execute Step 3, otherwise execute Step 4;
[0010] Step 3: Perform a write protection operation on FLASH. After completing the write protection, execute Step 4;
[0011] Step 4: Determine whether to perform a program upgrade. If a program upgrade instruction is received, execute Step 6, otherwise execute Step 5;
[0012] Step 5: No program upgrade instruction is received, and the DSP runs the normal process;
[0013] Step 6: Determine again whether FLASH is in write protection state. If FLASH is in write protection state, execute Step 7, otherwise execute Step 8;
[0014] Step 7: Perform FLASH protection release operation. After releasing the FLASH protection status, execute Step 8;
[0015] Step 8: The program waits for 1 second, and then executes Step 9;
[0016] Step 9: Erase the corresponding sector of FLASH. After erasing, execute Step 10;
[0017] Step 10: Write the firmware file to be upgraded to the corresponding sector of FLASH. After the write operation is completed, execute Step 11;
[0018] Step 11: Perform write protection operation on FLASH again. After the operation is completed and verified successfully, execute Step 12;
[0019] Step 12: The program upgrade is completed.
[0020] Preferably, the process of FLASH unprotection in Step 7 is as follows:
[0021] Step 71: Write 0xAAA to the 0x555 address of FLASH. After writing, execute Step 72;
[0022] Step 72: The program waits for 1 second, and then executes Step 73;
[0023] Step 73: Write 0x55 to the 0x2AA address of FLASH. After writing, execute Step 74;
[0024] Step 74: The program waits for 1 second, and after the waiting is completed, executes Step 75;
[0025] Step 75: Write 0x90 to the 0x555 address of FLASH. After writing, execute Step 76;
[0026] Step 76: The program waits for 1 second, and after the waiting is completed, executes Step 77;
[0027] Step 77: Write 0x60 to the address after adding the offset address 0x42 to the base address SA of the FLASH sector to be unprotected. This write operation is performed every 100ms. After 10 times, execute Step 78;
[0028] Step78: Complete FLASH sector deprotection.
[0029] Preferably, the process of erasing the FLASH sector in Step 9 is as follows:
[0030] Step 91: Write 0xAAA to the 0x555 address of FLASH. After writing, execute Step 92;
[0031] Step 92: The program waits for 1 second, and after the waiting is completed, executes Step 93;
[0032] Step 93: Write 0x55 to the 0x2AA address of FLASH. After writing, execute Step 94;
[0033] Step 94: The program waits for 1 second, and then executes Step 95;
[0034] Step 95: Write 0x80 to the 0x555 address of FLASH. After writing, execute Step 96;
[0035] Step 96: Write 0xAA to the 0x555 address of FLASH. After writing, execute Step 97;
[0036] Step 97: Write 0x55 to the 0x2AA address of FLASH. After writing, execute Step 98;
[0037] Step 98: Write 0x10 to the base address SA of the FLASH sector to be erased, and execute Step 99;
[0038] Step99: Complete FLASH sector erasing and exit the erase function.
[0039] The present invention also provides a system for implementing the method.
[0040] (III) Beneficial effects
[0041] In order to prevent the problem of FLASH being accidentally rewritten due to the DSP pointer running away during the DSP power-off process because the nuclear power is powered off before the IO power, the present invention is based on the characteristics that the FLASH is not easily lost after power-off after write protection, and the write protection takes effect immediately without restarting during a point adding process. Write protection for FLASH is added by software, and the erasing and release protection functions are delayed. The problem that FLASH may be accidentally rewritten is solved without adding an additional power monitoring circuit.
[0042] The present invention performs software write protection on FLASH and increases a delay between an erase operation and a deprotection operation, thereby avoiding the problem of accidental rewriting of FLASH content during DSP power-off, simplifying hardware design without excessive consideration of power-off timing, and reducing hardware design costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is the flow chart of the FLASH write protection software of the present invention;
[0044] Figure 2 for Figure 1 FLASH deprotection software flow chart in;
[0045] Figure 3 for Figure 1 FLASH sector erase software flow chart. DETAILED DESCRIPTION
[0046] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0047] The invention provides a method for preventing erroneous rewriting of configuration FLASH during power-off of DSP. The method solves the problem of erroneous operation of FLASH during power-off of DSP by means of write protection and increasing delay.
[0048] like Figure 1 As shown, the software process of FLASH write protection (i.e., the overall implementation process of the method of the present invention) is described, and the steps are as follows:
[0049] Step 1: DSP is powered on, the program is initialized, and Step 2 is executed;
[0050] Step 2: Determine whether FLASH is in write protection state. If FLASH is not in write protection state, execute Step 3, otherwise execute Step 4;
[0051] Step 3: Perform a write protection operation on FLASH. After completing the write protection, execute Step 4;
[0052] Step 4: Determine whether to perform a program upgrade. If a program upgrade instruction is received, execute Step 6, otherwise execute Step 5;
[0053] Step 5: No program upgrade instruction is received, and the DSP runs the normal process;
[0054] Step 6: Determine again whether FLASH is in write protection state. If FLASH is in write protection state, execute Step 7, otherwise execute Step 8;
[0055] Step 7: Perform FLASH protection release operation. After releasing the FLASH protection status, execute Step 8;
[0056] Step 8: The program waits for 1 second, and then executes Step 9;
[0057] Step 9: Erase the corresponding sector of FLASH. After erasing, execute Step 10;
[0058] Step 10: Write the firmware file to be upgraded to the corresponding sector of FLASH. After the write operation is completed, execute Step 11;
[0059] Step 11: Perform write protection operation on FLASH again. After the operation is completed and verified successfully, execute Step 12;
[0060] Step 12: Program upgrade is completed, exit the function.
[0061] like Figure 2 As shown, the software process of FLASH unprotection in Step 7 in the above process is described, and the steps are as follows:
[0062] Step 71: Write 0xAAA to the 0x555 address of FLASH. After writing, execute Step 72;
[0063] Step 72: The program waits for 1 second, and then executes Step 73;
[0064] Step 73: Write 0x55 to the 0x2AA address of FLASH. After writing, execute Step 74;
[0065] Step 74: The program waits for 1 second, and after the waiting is completed, executes Step 75;
[0066] Step 75: Write 0x90 to the 0x555 address of FLASH. After writing, execute Step 76;
[0067] Step 76: The program waits for 1 second, and after the waiting is completed, executes Step 77;
[0068] Step 77: Write 0x60 to the address after adding the offset address 0x42 to the base address SA of the FLASH sector to be unprotected. This write operation is performed every 100ms. After 10 times, execute Step 78;
[0069] Step78: Complete FLASH sector deprotection and exit the deprotection function.
[0070] like Figure 3 As shown in the figure, the software process of erasing the FLASH sector in Step 9 of the overall process is described, and the steps are as follows:
[0071] Step 91: Write 0xAAA to the 0x555 address of FLASH. After writing, execute Step 92;
[0072] Step 92: The program waits for 1 second, and after the waiting is completed, executes Step 93;
[0073] Step 93: Write 0x55 to the 0x2AA address of FLASH. After writing, execute Step 94;
[0074] Step 94: The program waits for 1 second, and after the waiting is completed, executes Step 95;
[0075] Step 95: Write 0x80 to the 0x555 address of FLASH. After writing, execute Step 96;
[0076] Step 96: Write 0xAA to the 0x555 address of FLASH. After writing, execute Step 97;
[0077] Step 97: Write 0x55 to the 0x2AA address of FLASH. After writing, execute Step 98;
[0078] Step 98: Write 0x10 to the base address SA of the FLASH sector to be erased, and execute Step 99;
[0079] Step99: Complete FLASH sector erasing and exit the erase function.
[0080] In addition to write protection, several important delays (wait) in the present invention are used to deal with the possibility that the pointer that runs away during the DSP power-off process may point to the two operations of sector deprotection and sector erasure that may rewrite the FLASH. Since the power-off time difference between the core voltage and the IO voltage of the DSP will not exceed 1s, adding the above-mentioned sufficient delay can ensure that even if the pointer points to the sector deprotection or sector erasure operation, there is not enough time to complete either the sector deprotection or sector erasure operation during the process from the start of the DSP power-off to the completion of the power-off, thereby completely avoiding the problem of the FLASH being rewritten due to power-off.
[0081] It can be seen that the present invention provides a method based on FLASH write protection to prevent the pointer from flying away during the DSP power-off process, causing the FLASH to be accidentally rewritten, and solves the problem of FLASH being accidentally rewritten at a low cost from the software perspective. The present invention does not need to add an additional power monitoring device, but only needs to protect the FLASH by software, and at the same time solves the problem of FLASH being accidentally written due to the pointer flying away during the power-off process by increasing the delay method.
[0082] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for preventing accidental rewriting of configuration FLASH during DSP power-off, characterized in that: The following steps are involved: Step 1: DSP is powered on, the program is initialized, and Step 2 is executed; Step 2: Determine whether FLASH is in write protection state. If FLASH is not in write protection state, execute Step 3, otherwise execute Step 4; Step 3: Perform a write protection operation on FLASH. After completing the write protection, execute Step 4; Step 4: Determine whether to perform a program upgrade. If a program upgrade instruction is received, execute Step 6, otherwise execute Step 5; Step 5: No program upgrade instruction is received, and the DSP runs the normal process; Step 6: Determine again whether FLASH is in write protection state. If FLASH is in write protection state, execute Step 7, otherwise execute Step 8; Step 7: Perform FLASH protection release operation. After releasing the FLASH protection status, execute Step 8; Step 8: The program waits for 1 second, and then executes Step 9; Step 9: Erase the corresponding sector of FLASH. After erasing, execute Step 10; Step 10: Write the firmware file to be upgraded to the corresponding sector of FLASH. After the write operation is completed, execute Step 11; Step 11: Perform write protection operation on FLASH again. After the operation is completed and verified successfully, execute Step 12; Step 12: The program upgrade is completed.
2. The method according to claim 1, characterized in that The process of FLASH unprotection in Step7 is as follows: Step 71: Write 0xAAA to the 0x555 address of FLASH. After writing, execute Step 72; Step 72: The program waits for 1 second, and after the waiting is completed, executes Step 73; Step 73: Write 0x55 to the 0x2AA address of FLASH. After writing, execute Step 74; Step 74: The program waits for 1 second, and after the waiting is completed, executes Step 75; Step 75: Write 0x90 to the 0x555 address of FLASH. After writing, execute Step 76; Step 76: The program waits for 1 second, and after the waiting is completed, executes Step 77; Step 77: Write 0x60 to the address after adding the offset address 0x42 to the base address SA of the FLASH sector to be unprotected. This write operation is performed every 100ms. After 10 times, execute Step 78; Step78: Complete FLASH sector deprotection.
3. The method according to claim 1, characterized in that The process of erasing FLASH sectors in Step 9 is as follows: Step 91: Write 0xAAA to the 0x555 address of FLASH. After writing, execute Step 92; Step 92: The program waits for 1 second, and after the waiting is completed, executes Step 93; Step 93: Write 0x55 to the 0x2AA address of FLASH. After writing, execute Step 94; Step 94: The program waits for 1 second, and after the waiting is completed, executes Step 95; Step 95: Write 0x80 to the 0x555 address of FLASH. After writing, execute Step 96; Step 96: Write 0xAA to the 0x555 address of FLASH. After writing, execute Step 97; Step 97: Write 0x55 to the 0x2AA address of FLASH. After writing, execute Step 98; Step 98: Write 0x10 to the base address SA of the FLASH sector to be erased, and execute Step 99; Step99: Complete FLASH sector erasing.
4. The method according to claim 2, characterized in that The FLASH protection release process in Step 7 is implemented through the protection release function.
5. The method according to claim 4, characterized in that After completing the FLASH sector deprotection in Step 78, exit the deprotection function.
6. The method according to claim 3, characterized in that The FLASH sector erase process in Step 9 is implemented through the erase function.
7. The method according to claim 6, characterized in that After completing the FLASH sector erase in Step 99, exit the erase function.
8. The method according to any one of claims 1 to 7, characterized in that: This method is used in the fields of industrial control and signal processing.
9. A system for implementing the method according to any one of claims 1 to 7.
10. The system according to claim 9, characterized in that: The system is used in the fields of industrial control and signal processing.