A method for preventing abnormal changes in memory data caused by power failure of airborne equipment
By using the CPU in the airborne device to send locking and unlocking commands to the CPLD and controlling the reset pin of the Flash chip, the problem of Flash data rewriting caused by abnormal power-off timing is solved and the safety and reliability of the device are improved.
Patent Information
- Application Number
- CN202111336858.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-12
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-11-12
AI Technical Summary
Improper power-off timing design of airborne equipment may cause the Flash chip to be mistakenly rewritten, causing an embedded system failure. In severe cases, it may cause serious consequences. It is difficult for existing technology to effectively prevent such abnormal rewriting.
Send locking and unlocking commands to the CPLD through the CPU to control the reset pin of the Flash chip to ensure that the Flash data is prevented from being rewritten when the power-on and power-off timing is abnormal. Locking logic and unlocking logic are used to protect the Flash during power-on and power-off respectively. read and write permissions.
It effectively prevents abnormal tampering of Flash data caused by hardware design defects, simplifies the power-off timing design of airborne equipment boards, and improves the safety and reliability of the equipment.
Smart Images

Figure CN114064076B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of airborne embedded software, and in particular to a method for preventing abnormal changes in memory data caused by power-off of airborne equipment. Background Art
[0002] Most airborne devices are embedded products, which usually involve the interconnection between multiple chips. The basic embedded product system consists of several parts, including CPU, DDR, Flash, reset chip, etc. When designing an embedded system, it is necessary to carefully consider the power-on and power-off timing of each chip.
[0003] Currently, there is no fixed design scheme for the power-on and power-off timing of chips. When there is a problem with the power-on and power-off timing design, it may cause the embedded software to run away, further causing the Flash chip in the embedded system to be mistakenly rewritten, causing embedded system failures, and serious failures may result in the destruction of the aircraft and the death of people. Even if the probability of failure is very small, even a one in ten million probability, it is still a very serious problem in the aviation field.
[0004] Abnormal power-off analysis: The abnormal power-off operation mechanism is as follows Figure 1 As shown in the figure, the embedded system board consists of CPU, DDR, FLASH, reset chip and other parts.
[0005] ① Fault: The CPU core voltage is first powered down to outside the normal operating range
[0006] ②CPU instruction execution error occurs, the program runs away and jumps to the Flash update Routine block
[0007] ③ The wrong data is written back to the Flash, and the Flash file system is destroyed, which is FlashCorruption
[0008] ④ Due to insufficient voltage monitoring accuracy or slow response time, the CPU Reset signal is sent very late after the voltage becomes abnormal, and the FLASH file system has been damaged at this time.
[0009] ⑤If the DDR memory power supply fails before other power supplies, Flash Corruption may also occur.
[0010] The DDR memory on the board is powered by 3.3V and is powered off last. This factor will not cause FlashCorruption on the board.
[0011] This power-off sequence causes the embedded software to run to the code for updating the FLASH. There is a probability that the internal data of the FLASH will be overwritten, causing the rewritten erroneous embedded software code to be read the next time the board is started, resulting in abnormal product operation.
[0012] Therefore, a software solution needs to be developed to prevent the Flash of the embedded system from being abnormally rewritten when the designed power-on and power-off sequence is incorrect, thereby ensuring the normal operation of the embedded system of the airborne equipment. Summary of the invention
[0013] The object of the present invention is to provide a method for preventing abnormal changes in memory data caused by power-off of an onboard device, thereby avoiding the occurrence of Flash being accidentally rewritten when any onboard device is powered off abnormally.
[0014] Technical solution of the present invention:
[0015] A method for preventing abnormal changes in memory data caused by power-off of an airborne device, the method comprising the following steps:
[0016] 1) Initial workflow of airborne equipment board
[0017] After the board is powered on, the CPU first runs to the level 1 boot area, which will guide the CPU to the level 2 boot area. The level 2 boot area will select whether the CPU executes the application program or the online upgrade program.
[0018] 2) Application Process
[0019] If the CPU executes the application, the CPLD invalidates the reset pin of the FLASH, and the FLASH enters the reset invalid state. The board starts the program normally. The application first copies the program code stored in the Flash to the FRAM. After the copy is completed, the application reads the status of the Flash. If the Flash is not locked, the Flash locking program is executed and the process goes to step 4), sending a locking instruction to the CPLD to lock the read and write permissions of the Flash, and then the various functions in the application are run normally. If the Flash is locked, the various functions in the application are run normally.
[0020] 3) Online upgrade process
[0021] If the CPU executes the online upgrade program, according to the Flash unlocking program in the online upgrade program, it goes to step 5), unlocks the read and write permissions of the Flash, and the CPU writes the program to be upgraded into the Flash;
[0022] 4) Locking logic
[0023] The application program executed by the CPU sends a lock command to the CPLD logic device. The CPLD logic device controls the reset pin of the Flash to be valid, so that the Flash enters the reset state. At this time, the Flash cannot be operated, and the Flash is locked;
[0024] 5) Unlock logic
[0025] The online upgrade program executed by the CPU sends an unlock command to the CPLD logic device. The CPLD logic device controls the reset pin of the Flash to be invalid, so that the Flash enters a normal working state. At this time, the Flash can be operated to complete the unlocking of the Flash.
[0026] It is characterized in that the onboard equipment includes CPU, DDR, FLASH, reset chip and CPLD.
[0027] The characteristic of the invention is that the execution time of the locking command is short, and the CPU can read back the command after the command is issued, so as to ensure that the locking command is successfully executed without affecting the startup time of the application executed by the CPU.
[0028] The characteristic is that after the program running away caused by the abnormal power-off timing of the board continues to run for about 5-10ms, the CPU on the board will be completely out of power, and the entire execution time of the unlocking logic is set to 16ms. During the online upgrade process, even if the power is off and the program runs away, the CPU will not have time to unlock the FLASH, and the CPU on the board will be completely out of power, thereby ensuring that the FLASH will not be overwritten.
[0029] The invention is characterized in that the CPLD independently controls the reset pin of the FLASH, so that the FLASH reset signal is independently controlled by the CPLD, and the CPLD resets the FLASH without affecting other functions of the board.
[0030] It is characterized in that the locking logic specifically includes:
[0031] 4.1) The application reads the status of the Flash, writes a value to the selected address of the CPU, sends a lock instruction to the CPLD, and sets the reset signal of the FLASH to the valid state. At this time, any operation of reading and writing the FLASH is invalid;
[0032] 4.2) Determine whether the read-back command received by the CPU after the lock instruction is issued is valid. If valid, it is determined that the FLASH is locked successfully and the various functions in the application are executed normally; if invalid, it is determined that the FLASH is locked failed, and return to step 4.1) again to re-execute the locking operation; if the CPU fails to lock for 5 consecutive times, the locking operation is abandoned and the various functions in the application are executed normally.
[0033] Characterized in that, the unlocking logic specifically includes:
[0034] 5.1) The online upgrade program executed by the CPU sends an unlock command to the CPLD logic device.
[0035] After writing the value 1 in the selected address 1 of the CPU, after the internal logic processing of the CPLD, query whether the address 2 of the CPU is the value 2, if the address 2 of the CPU is the value 2, then continue to write the value 3 to the selected address 3 of the CPU, after the internal logic processing of the CPLD, query whether the address 4 of the CPU is the value 4, if the address 4 of the CPU is the value 4, then continue to write the value 5 to the selected address 5 of the CPU, after the internal logic processing of the CPLD, query whether the address 6 of the CPU is the value 6, if the address 6 of the CPU is the value 6, the CPU sends an unlock instruction to the CPLD, the unlock instruction includes writing the value 7 to the selected address 7 of the CPU, and continuing to write the value 8 to the selected address 8 of the CPU, after the internal logic processing of the CPLD, the reset signal of the FLASH of the CPLD will be set to invalid, the FLASH is successfully unlocked, and is in a normal read-write state;
[0036] 5.2) If the value found in address 2 of the CPU is not 2, or the value found in address 4 of the CPU is not 4, or the value found in address 6 of the CPU is not 6, it is determined that the FLASH unlocking has failed, and the value 9 is written to the selected address 9 of the CPU, and the value 10 is continued to be written to the selected address 10 of the CPU. After being processed by the internal logic of the CPLD, the internal unlocking state machine of the CPLD is reset.
[0037] The feature of the invention is that in step 5.1), a waiting time of 2ms is required before each address query and address writing.
[0038] Beneficial effects of the invention:
[0039] The advantage of the present invention is that the locking and unlocking of the Flash is controlled by the locking and unlocking commands of the CPU to prevent the data stored in the Flash from being abnormally modified by the CPU. The present invention can prevent the abnormal power-on and power-off timing of the airborne device board from being caused by hardware design defects, causing the CPU program to run away, and causing the key data stored in the Flash to be abnormally tampered with, thereby simplifying the design considerations of the power-on and power-off timing of the airborne device board and improving the safety of the airborne device. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 Schematic diagram of power-off abnormality
[0041] Figure 2 Design schematic diagram to prevent abnormal changes in memory data caused by power failure
[0042] Figure 3Locking operation flow chart
[0043] Figure 4 Unlocking operation flow chart DETAILED DESCRIPTION
[0044] The connection structure of the present invention is described in detail below with reference to the accompanying drawings and embodiments.
[0045] Based on the method of locking and unlocking Flash, CPLD is used to lock / unlock the FLASH chip, and the software cooperates with the operation. Figure 2 shown.
[0046] Board power-on workflow design: After the board is powered on, it first enters the level 1 boot area, that is, Figure 2 1LevelBootloader in the 1LevelBootloader; 1Level boot will guide the CPU into the software selection area - 2Level boot area, that is Figure 2 In the 2LevelBootloader, the 2-level boot will choose whether the CPU executes the online upgrade program or the application program, that is, Figure 2 Updata APP and User APP in.
[0047] When the second-level boot selects the CPU to execute the Updata APP, the Updata APP contains a Flash unlocking program, which unlocks the read and write permissions of the Flash and writes the program code to be upgraded into the Flash.
[0048] After the second-level boot selects the CPU to execute the User APP, the User APP will copy the program code stored in the Flash to the FRAM. After the copy is completed, the User APP reads the Flash status. If the Flash is not locked, it will execute the Flash locking program and send a locking instruction to the CPLD to lock the read and write permissions of the Flash. Then the various functions in the User APP will run normally.
[0049] Lock / unlock logic design: The lock / unlock FLASH logic is implemented by CPLD logic devices, and the Flash is locked and unlocked by controlling the reset pin of the Flash. The lock command is issued by the CPU application, and the unlock command is issued by the CPU online upgrade program.
[0050] Lock command: In order to minimize the impact on the startup time of the CPU application, the lock command requires a short execution time and can be read back after the command is issued to ensure successful execution of the command;
[0051] Unlock command: Since abnormal power-off will cause the program to run away, it is necessary to avoid the program running away to the unlocking program before unlocking, so the unlocking logic is relatively complex. Power-off during the CPU online upgrade process may also cause the program to run away in theory. In order to prevent accidental unlocking in this case, the entire execution time of the "unlocking logic" is designed to be 16ms. After testing multiple boards, the continuous running time of the program running away caused by abnormal power-off timing of the product is about 5-10ms. That is, during the online upgrade process, even if the power-off causes the program to run away, the DSP will not have time to unlock the FLASH, and the processor module on the board will be completely out of power, thereby ensuring that the FLASH will not be rewritten.
[0052] The specific locking and unlocking logic is as follows:
[0053] The FLASH reset signal is independently controlled by the CPLD. When the CPLD resets the FLASH, it will not affect other functions.
[0054] 1. Locking operation: When the board is powered on, the CPLD resets the FLASH to high, and the reset is invalid. The board starts the program normally. After the application is loaded, write 0XFF55 (tentative) to address 0x900001d0 to set the reset signal of the FLASH to low, and the reset is valid. At this time, any operation of reading and writing the FLASH is invalid.
[0055] 2. Lock failure: After the lock command is issued, read back whether the command is effective. If it is not effective, it is determined that the lock failed and the lock operation is performed again. If the lock command is still not effective after the board is powered on and the lock operation is performed 5 times each time, the lock operation is abandoned and the program function is executed normally. See the lock operation flow chart Figure 3 .
[0056] 3. Unlock operation: After writing 0XFF11 to address 0x900001c0, check whether address 0x900001c2 is 0XFF22 (interval 2 milliseconds). When address 0x900001c2 is 0XFF22, write 0XFF33 to address 0x900001c4 and check whether address 0x900001c6 is 0XFF44 (interval 2 milliseconds). When address 0x900001c6 is 0XFF44 , write 0XFF55 to address 0x900001c8, check whether address 0x900001ca is 0XFF66 (interval 2 milliseconds), when address 0x900001ca is 0XFF66, write 0XFF77 to address 0x900001cc, and write 0XFF88 to address 0x900001ce (interval 2 milliseconds). After all are met, the reset signal of FLASH will be set high and it is in normal read and write state.
[0057] 4. If unlocking fails, you can write 0x900001d2 address 0Xff00, then write 0XFF01 to reset the unlocking state machine. See the unlocking operation flow chart Figure 4 .
Claims
1. A method for preventing abnormal changes in memory data caused by power failure of an onboard device, the method The following steps are involved: 1) Initial workflow of airborne equipment board After the board is powered on, the CPU first runs to the level 1 boot area, which will guide the CPU to the level 2 boot area. The level 2 boot area will select whether the CPU executes the application program or the online upgrade program. 2) Application Process If the CPU executes the application, the CPLD invalidates the reset pin of the FLASH, and the FLASH enters the reset invalid state. The board starts the program normally. The application first copies the program code stored in the Flash to the FRAM. After the copy is completed, the application reads the status of the Flash. If the Flash is not locked, the Flash locking program is executed and the process goes to step 4), sending a locking instruction to the CPLD to lock the read and write permissions of the Flash, and then the various functions in the application are run normally. If the Flash is locked, the various functions in the application are run normally. 3) Online upgrade process If the CPU executes the online upgrade program, according to the Flash unlocking program in the online upgrade program, it goes to step 5), unlocks the read and write permissions of the Flash, and the CPU writes the program to be upgraded into the Flash; 4) Locking logic The application program executed by the CPU sends a lock command to the CPLD logic device. The CPLD logic device controls the reset pin of the Flash to be valid, so that the Flash enters the reset state. At this time, the Flash cannot be operated, and the Flash is locked; 5) Unlock logic The online upgrade program executed by the CPU sends an unlock command to the CPLD logic device. The CPLD logic device controls the reset pin of the Flash to be invalid, so that the Flash enters a normal working state. At this time, the Flash can be operated to complete the unlocking of the Flash.
2. The method according to claim 1, It is characterized in that The onboard equipment includes a CPU, a DDR, a FLASH, a reset chip and a CPLD.
3. The method according to claim 2, It is characterized in that The execution time of the locking command is short, and the CPU can read back the command after it is issued, ensuring that the locking command is successfully executed without affecting the startup time of the application executed by the CPU.
4. The method according to claim 3, It is characterized in that After the program runs away due to abnormal power-off timing of the board, the CPU on the board will be completely out of power after running for 5-10ms. The entire execution time of the unlocking logic is set to 16ms. During the online upgrade process, even if the program runs away due to power-off, the CPU will not have time to unlock the FLASH. The CPU on the board will be completely out of power, thereby ensuring that the FLASH will not be overwritten.
5. The method according to claim 4, It is characterized in that CPLD independently controls the reset pin of FLASH, so that the FLASH reset signal is independently controlled by CPLD. CPLD resets FLASH without affecting other functions of the board.
6. The method according to claim 5, It is characterized in that The locking logic specifically includes: 4.1) The application reads the status of the Flash, writes a value to the selected address of the CPU, sends a lock instruction to the CPLD, and sets the reset signal of the FLASH to the valid state. At this time, any operation of reading and writing the FLASH is invalid; 4.2) Determine whether the read-back command received by the CPU after the lock instruction is issued is valid. If valid, it is determined that the FLASH is locked successfully and the various functions in the application are executed normally; if invalid, it is determined that the FLASH is locked failed, and return to step 4.1) again to re-execute the locking operation; if the CPU fails to lock for 5 consecutive times, the locking operation is abandoned and the various functions in the application are executed normally.
7. The method according to claim 6, It is characterized in that The unlocking logic specifically includes: 5.1) The online upgrade program executed by the CPU sends an unlock command to the CPLD logic device. After writing the value 1 in the selected address 1 of the CPU, after the internal logic processing of the CPLD, query whether the address 2 of the CPU is the value 2, if the address 2 of the CPU is the value 2, then continue to write the value 3 to the selected address 3 of the CPU, after the internal logic processing of the CPLD, query whether the address 4 of the CPU is the value 4, if the address 4 of the CPU is the value 4, then continue to write the value 5 to the selected address 5 of the CPU, after the internal logic processing of the CPLD, query whether the address 6 of the CPU is the value 6, if the address 6 of the CPU is the value 6, the CPU sends an unlock instruction to the CPLD, the unlock instruction includes writing the value 7 to the selected address 7 of the CPU, and continuing to write the value 8 to the selected address 8 of the CPU, after the internal logic processing of the CPLD, the reset signal of the FLASH of the CPLD will be set to invalid, the FLASH is successfully unlocked, and is in a normal read-write state; 5.2) If the value found in address 2 of the CPU is not 2, or the value found in address 4 of the CPU is not 4, or the value found in address 6 of the CPU is not 6, it is determined that the FLASH unlocking has failed, and the value 9 is written to the selected address 9 of the CPU, and the value 10 is continued to be written to the selected address 10 of the CPU. After being processed by the internal logic of the CPLD, the internal unlocking state machine of the CPLD is reset.
8. The method according to claim 7, It is characterized in that In step 5.1), wait 2ms before each address query and address writing.
Citation Information
Patent Citations
Hardware writing protection method, single board and device
CN101188143A
Embedded processor with dual-port SRAM for programmable logic
US7096324B1
