A system protection method for Nand Flash abnormal bit flipping
By rewriting 0xff to correct and move the data after a bit flip is detected in the Nand Flash, the system anomaly caused by blank page flips in the Nand Flash data is resolved, thus achieving file system continuity and data protection.
Patent Information
- Application Number
- CN202411516317.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-10-29
AI Technical Summary
When a bit flip occurs in a blank page of NAND Flash under extreme conditions, the UBI file system cannot correct it, causing the system to enter an exception handling process and affecting normal write operations.
After detecting a bit flip, the system counts the number of flips and rewrites 0xff to correct the bit flip, moves the data to a spare block, erases the original block and tests it, marks unrepairable blocks as bad blocks, and remaps the logical blocks to the spare blocks.
It effectively handles abnormal bit flips in Nand Flash, avoids the system forcing read-only mode, and ensures the continuity of file system storage space and data integrity.
Smart Images

Figure CN119473700B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of embedded device technology, specifically to a system protection method for abnormal bit flipping in Nand Flash. Background Technology
[0002] NAND Flash, a commonly used storage medium in embedded devices, is prone to bit flipping. NAND Flash itself provides ECC (Electronic Code Correction) at the driver layer to correct for some degree of bit flipping. When data is written to a page of NAND Flash, an original ECC checksum is generated simultaneously. This checksum is then used to verify and correct any data errors when reading data from the same page. Therefore, blank pages do not store ECC data because no data has been written to them. However, under extreme conditions, bit flipping can still occur in these blank pages of NAND Flash. When a UBI (User-Defined File System) based on NAND Flash reads data from the Flash, it simultaneously checks both valid data areas and blank data areas. If a bit flip is detected in a blank data area and there is no corresponding ECC code to correct the data, the UBI file system will enter an exception handling process, forcibly switching the system to read-only mode for protection. Normal write operations to the NAND Flash will fail, leading to system errors. Therefore, effectively addressing the various impacts of NAND Flash bit flipping on the system has become a crucial issue for the application of NAND Flash in embedded systems. Summary of the Invention
[0003] This invention provides a system protection method for abnormal bit flipping in Nand Flash, which can effectively solve the problems in the background art.
[0004] To solve the above-mentioned technical problems, the present invention provides the following technical solution:
[0005] A system protection method for abnormal bit flipping in Nand Flash includes the following steps:
[0006] S100: After the UBI file system detects a bit flip in the data blank area of a physical block of Nand Flash, it counts the number of bit flips and sets all blank areas of the physical block where the bit flip occurred to 0xff, thereby correcting the bit flip.
[0007] S200: Move the data of the physical block (including the valid data area and the corrected data blank area) to a spare block;
[0008] S300: Erase the original block, verify whether it is completely erased and perform additional read and write tests. If it has been erased and the read and write tests are normal, the physical block is placed in the spare block list for later use. If it is detected that it cannot be completely erased or bit flipping problems still occur during read and write tests, the block is marked as a bad block in the MTD layer and stored in the bad block table to avoid future use.
[0009] S400: Cancel the mapping between the logical block and the original bit-flipped physical block, and enable the spare block that has received the moved data. Remap the original corresponding logical block to this spare block, thereby achieving continuity of the file system storage space.
[0010] As can be seen from the above technical solution, the system protection method for abnormal bit flipping in Nand Flash of the present invention has the following characteristics:
[0011] Beneficial effects:
[0012] When bit flips occur in a blank area of a physical block of Nand Flash under harsh conditions, the problematic block can be effectively handled by actively correcting the bit flips and relocating the data. This avoids the failure of the file system entering an exception handling program and the system being forced into read-only mode due to the lack of ECC data for repair. This invention provides effective protection for systems based on Nand Flash storage. Attached Figure Description
[0013] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0014] Figure 1 This is a flowchart of the present invention;
[0015] Figure 2 This is a schematic diagram of the method principle of the present invention; Detailed Implementation
[0016] The invention will now be further described with reference to the accompanying drawings.
[0017] like Figure 1 As shown in this embodiment, the system protection method for abnormal bit flipping in Nand Flash includes the following steps:
[0018] S100: After the UBI file system detects a bit flip in the data blank area of a physical block of Nand Flash, it counts the number of bit flips (since the flips in the blank area are all 1s flipped to 0s) and rewrites the blank area of the physical block where the bit flip occurred to 0xff, thereby correcting the bit flip.
[0019] S200: Move the data of the physical block (including the valid data area and the corrected data blank area) to a spare block;
[0020] S300: Erase the original block, verify whether it is completely erased and perform additional read and write tests. If it has been erased and the read and write tests are normal, the physical block is placed in the spare block list for later use. If it is detected that it cannot be completely erased or bit flipping problems still occur during read and write tests, the block is marked as a bad block in the MTD layer and stored in the bad block table to avoid future use.
[0021] S400: Cancel the mapping between the logical block and the original bit-flipped physical block, and enable the spare block that has received the moved data. Remap the original corresponding logical block to this spare block, thereby achieving continuity of the file system storage space.
[0022] Figure 2 This is a schematic diagram of the method principle of the present invention, which will be described below in conjunction with... Figure 2 The operating principle of the embodiments of the present invention will be described in detail below:
[0023] This invention addresses the issue that when the UBI file system detects a bit flip in a data blank area of a physical block while reading Nand Flash data, it does not enter the exception handling process even without ECC data correction. Instead, it utilizes the characteristic that the blank area data is all 0xff, meaning that bit flips all start from 1 and end with 0, to correct the non-0xff area by rewriting 0xff.
[0024] Since it's uncertain whether the flip is accidental or permanent and irreparable, meaning it's uncertain whether the block will be usable after correction, the repaired data needs to be completely moved to a spare block to avoid data loss. Then, an erase / write check is performed on the original block. It's also important to note that if the original block experiences an irreparable bit flip, the 0xff rewrite operation on the original block may fail. However, the repaired data will still be stored in the spare block because the file system will perform the same check and repair operation when remapping and reading the spare block later, and the flipped bits will be repaired in the spare block.
[0025] The in-situ bit flipped block is completely erased, and additional read / write tests are performed to evaluate its availability. If it can be completely erased and read / write tests are normal, it is considered an accidental bit flip, and the block is marked as a spare block and added to the spare block list, to be reused later by the UBI file system for load balancing or bad block handling. If data cannot be erased or read / write data verification is abnormal, the block is considered to have a permanent and unrecoverable bit flip problem, and it needs to be marked as a bad block at the MTD layer and added to the bad block list for disuse.
[0026] Finally, the logical mapping between the UBI file system logical block and the in-place flipped block is canceled, and the spare block for the moved data is enabled. The original corresponding logical block is remapped to this spare block. This achieves the preservation of the original data and the replacement of the in-place flipped block, ensuring the continuity of the file system storage space.
[0027] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A system protection method for abnormal bit flipping in Nand Flash, characterized in that: Includes the following steps: S100: After the UBI file system detects a bit flip in the data blank area of a physical block of Nand Flash, it counts the number of bit flips and rewrites the blank area of the physical block where the bit flip occurred to 0xff, thereby correcting the bit flip. S200: Move the data of this physical block to a spare block; S300: Erase the original block, verify whether it is completely erased and perform additional read / write tests. If it has been erased and the read / write test is normal, the physical block is placed in the spare block list for later use. If it is detected that it cannot be completely erased or bit flipping problems still occur during read / write tests, the physical block is marked as a bad block in the MTD layer and stored in the bad block table to avoid future use. S400: Cancel the mapping between the logical block and the original bit-flipped physical block, and enable the spare block that has received the moved data. Remap the original corresponding logical block to this spare block, thereby achieving continuity of the file system storage space.
Citation Information
Patent Citations
Nand-flash page bit flipping control method and Nand-flash page bit flipping control module
CN111737042A
Inline flash memory qualification in a storage system
US20220291837A1