Method for burning file system in NAND flash memory, electronic device, and storage medium

By obtaining the bad block information of NAND flash memory and calculating the offset, the location matching problem caused by bad blocks during file system burning in NAND flash memory is solved, and the correct reading and startup of the file system is achieved.

CN118069167BActive Publication Date: 2024-12-10UNITED MEMORY TECHNOLOGY (JIANGSU) LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410151757.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-02
Publication Date
2024-12-10
Estimated Expiration
2044-02-02

AI Technical Summary

Technical Problem

When there are bad blocks in NAND flash memory, the location information of the file system does not match the actual file location, resulting in the burned file system being unable to read correctly, resulting in the file system failing to start.

Method used

By obtaining the bad block information of NAND flash memory, determine the actual burn block of each file in the file system and calculate the offset, add the offset to the file location information, and burn the file to the location information and offset according to the location information and offset. NAND flash memory to ensure the correct reading of the file.

Benefits of technology

When confirming that the bad block overlaps the file's burning block before burning the file system, determine the file's burning block as other normal blocks of NAND flash memory, and increase the offset in the file location information to make the file location information relevant to the actual situation Block matching ensures correct file reading and normal startup of the file system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118069167B_ABST
    Figure CN118069167B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for burning a file system in a NAND flash memory, comprising: obtaining bad block information of the NAND flash memory; determining the actual burning block of each file in the file system according to the bad block information, and calculating the offset of each file; adding the offset to the position information of each file; burning the file system in the NAND flash memory; wherein the file is burned to the NAND flash memory according to the position information and the offset. The present invention solves the problem of file system startup failure when burning the file system to a NAND flash memory with bad blocks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of NAND flash memory, and in particular to a method for burning a file system in a NAND flash memory, an electronic device, and a storage medium. Background Art

[0002] In the related art, when burning a file system to a NAND flash memory, the file system needs to be compressed. However, during the process of burning the file system to the NAND flash memory, if there are bad blocks in the NAND flash memory, the location information of the file recorded by the file system during compression and the actual file location of the file in the NAND flash memory cannot match, resulting in the burned file system being unable to be correctly read during startup, causing the file system startup failure. Summary of the invention

[0003] The main purpose of the present invention is to provide a method for burning a file system in a NAND flash memory, aiming to solve the problem of file system startup failure when burning the file system to a NAND flash memory with bad blocks.

[0004] To achieve the above object, one aspect of the present invention provides a method for burning a file system in a NAND flash memory, the method comprising:

[0005] Get bad block information of NAND flash memory;

[0006] Determine the actual burning block of each file in the file system based on the bad block information and calculate the offset of each file;

[0007] Add an offset to each file's location information;

[0008] Burn the file system in NAND flash memory;

[0009] Among them, the file is burned into the NAND flash memory according to the location information and offset.

[0010] In some embodiments, determining the actual burned block of a file in the file system according to the bad block information includes:

[0011] According to the location information of each file, obtain the preset burning block of each file;

[0012] Determine whether the preset burning block is a block in the bad block information;

[0013] If one of the preset burning blocks belongs to the block in the bad block information, the actual burning block of the corresponding file is determined to be other normal blocks of the NAND flash memory.

[0014] In some embodiments, if all the preset burning blocks do not belong to the blocks in the bad block information, the preset burning block of each file is determined as the actual burning block of the file.

[0015] In some embodiments, calculating the offset of the file includes:

[0016] The offset is obtained according to the difference between the number of the actual burning block and the number of the preset burning block.

[0017] In some embodiments, adding an offset to the location information of the file includes:

[0018] Create a pad file corresponding to the preset burning block in the file directory;

[0019] Record the number and offset of the preset burning block in the pad file;

[0020] Bind the pad file to the file's location information.

[0021] In some embodiments, burning the file to the NAND flash memory according to the location information and the offset includes:

[0022] Read the pad file through the burner;

[0023] Determine the actual burning block according to the offset and the number of the preset burning block;

[0024] Burn the file to the actual burning block.

[0025] In some embodiments, obtaining bad block information of a NAND flash memory includes:

[0026] Read the SA area of ​​the NAND flash memory and create a bad block table of the NAND flash memory.

[0027] Get bad block information based on the bad block table.

[0028] In some embodiments, after burning the file system in the NAND flash memory, the method further includes:

[0029] Verify the integrity of the burned file system;

[0030] If the file system after burning is incomplete, burn the file system again.

[0031] Another aspect of the present invention provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for burning a file system in a NAND flash memory as described above is implemented.

[0032] Another aspect of the present invention provides a storage medium storing a computer program. When the computer program is executed by a processor, the method for burning a file system in a NAND flash memory as described above is implemented.

[0033] The beneficial effect of the technical solution of the present invention is that before burning the file system, when it is confirmed that the bad blocks of the NAND flash memory overlap with the burning blocks of the file, the burning blocks of the file are determined to be other normal blocks of the NAND flash memory, and the offset of the file is added to the file position information of the file system, so that when reading the file after the burning is completed, the actual burning blocks of the file are found according to the position information and offset of the file, so that the position information of the file is matched with the actual blocks of the file in the NAND flash memory, and the correct reading of the file is completed. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A flowchart of a method for burning a file system in a NAND flash memory according to an embodiment of the present invention;

[0035] Figure 2 A sub-flow chart of a method for burning a file system in a NAND flash memory according to an embodiment of the present invention;

[0036] Figure 3 Another sub-flow chart of the method for burning a file system in a NAND flash memory according to an embodiment of the present invention;

[0037] Figure 4 Schematic diagram of the structure of an electronic device according to an embodiment of the present invention.

[0038] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0039] The scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0040] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, top, bottom, side...) are only used to explain the relative position relationship, movement status, etc. between the components in a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0041] It should also be noted that when an element is referred to as being "fixed on" or "disposed on" another element, it may be directly on the other element or there may be an intermediate element at the same time. When an element is referred to as being "connected to" another element, it may be directly connected to the other element or there may be an intermediate element at the same time.

[0042] In addition, the descriptions involving "first", "second", etc. in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features.

[0043] In view of the technical defects existing in the related art, this embodiment provides a method for burning a file system in a NAND flash memory. It should be noted that when the method is actually implemented, it can be executed by a computer control system, but is not limited to this. For ease of understanding, each step in the following embodiment can be understood as being processed and judged by a computer processor.

[0044] like Figure 1 As shown, the method for burning a file system in a NAND flash memory in this embodiment includes:

[0045] Step S100, obtaining the bad block information of the NAND flash memory. By scanning all blocks of the NAND flash memory chip, bad blocks that cannot store data normally are detected. The bad blocks described in this application refer to pseudo bad blocks where the NAND flash memory driver is stored and real bad blocks that are physically damaged. This step confirms the bad block distribution of the NAND flash memory and provides a basis for the actual burning location of the file. This step specifically reads the SA area of ​​the NAND flash memory and creates a bad block table of the NAND flash memory. Obtain the bad block information of the NAND flash memory according to the bad block table.

[0046] Since a certain physical space is reserved in the NAND flash memory as the SA area for storing bad block management information, in this step, the bad block information of the NAND flash memory is obtained by scanning and reading the data in the SA area of ​​the NAND flash memory and organizing and creating a complete bad block table. The bad block table created by reading the SA area of ​​the NAND flash memory records key information such as the number and address of the bad block marked at the factory for use in subsequent steps.

[0047] Step S200, determine the actual burning block of the file in each file system according to the bad block information, and calculate the offset of each file. Specifically, determine the preset burning block of the file according to the position information of each file. If the preset burning block is a bad block, it is necessary to specify other normal blocks as the actual burning block of the file.

[0048] For example, according to the location information of the file, it can be determined that the preset burning block of file A is block 10. However, after scanning the NAND flash memory, it is found that block 10 of the NAND flash memory is a bad block and block 11 is a normal block, so block 11 can be used as the actual burning block of file A.

[0049] For another example, according to the file location information, it can be determined that the preset burning block of file B is block 20. However, after scanning the NAND flash memory, it is found that blocks 20, block 21, and block 22 of the NAND flash memory are all bad blocks, and block 23 is a normal block, so block 23 can be used as the actual burning block of file B.

[0050] For another example, according to the location information of the file, it can be determined that the preset burning block of file C is block 30. However, after scanning the NAND flash memory, it is found that block 30 of the NAND flash memory is a bad block, and blocks 31, block 32, and block 33 are normal blocks, so block 33 can be used as the actual burning block of file C.

[0051] Of course, there may be a situation where the preset burning block of a file is a normal block. For example, the preset burning block of file D is block 40. However, after scanning the NAND flash memory, it is found that block 40 of the NAND flash memory is a normal block. At this time, file D can be directly burned to block 40 in the subsequent burning process, that is, the preset burning block of file D is the actual burning block of file D.

[0052] The file offset can be obtained by calculating the difference between the number of the actual burning block and the number of the preset burning block. Since each block of the NAND flash memory has a unique number, such as a 1GB NAND flash memory has 1024 blocks, that is, block1 to block1024. Here, the file offset is explained in combination with the above example.

[0053] For example, when the preset burning block of file A is block10 and the actual burning block of file A is block11, the offset of file A is 1.

[0054] For another example, when the preset burning block of file B is block 20 and the actual burning block of file B is block 23, the offset of file B is 3.

[0055] For another example, when the preset burning block of file C is block30 and the actual burning block of file C is block33, the offset of file C is 3.

[0056] When the preset burning block of a file is the actual burning block of the file, the offset of the file is 0.

[0057] Step S300: Add an offset to the location information of each file. The purpose of this step is to add the offset to the location information of the file so that when the file is subsequently read, the block storing the file can be accurately found according to the location information and the offset of the file.

[0058] Step S400, burning the file system in the NAND flash memory. The file of the file system is burned into the NAND flash memory according to the location information and the offset. For example: during the burning process, the preset burning block of the file is confirmed to be block10 based on the location information, and when the offset is 1, the burner burns the file into block11 of the NAND flash memory.

[0059] In this embodiment, before burning the file system, when it is confirmed that the bad blocks of the NAND flash memory overlap with the burning blocks of the file, the burning blocks of the file are determined to be other normal blocks of the NAND flash memory, and the offset of the file is added to the file position information of the file system, so that when reading the file after the burning is completed, the actual burning blocks of the file are found according to the file position information and offset, so that the file position information and the actual blocks of the file in the NAND flash memory are matched, and the correct reading of the file is completed, so as to ensure that the burned file system can be started normally.

[0060] Furthermore, if Figure 2 As shown, the process of determining the actual burning block of the file in the file system according to the bad block information in step S200 includes:

[0061] Step S210: Obtain the preset burning block of each file according to the location information of each file. Since the file system pre-plans and allocates the preset burning block for each file based on the location information of the file, the preset burning block of each file can be obtained based on the location information of the file.

[0062] Step S220, determine whether one of the preset burning blocks is a bad block in the bad block information. Compare the preset burning block obtained in step S210 with the bad block information of the NAND flash memory obtained in step 100 to determine whether the preset burning block is a bad block, so as to determine whether the storage location preset by the file system is available.

[0063] Among them, if a preset burning block belongs to the block in the bad block information, the actual burning block of the corresponding file is determined to be other normal blocks of the NAND flash memory. For example: the preset burning block of file E of the file system is block10, and according to the bad block information of the NAND flash memory, block10 of the NAND flash memory is a bad block. In this case, if the file system is burned directly, it will cause damage to file E. Therefore, in order to prevent this situation, it is necessary to determine other normal blocks of the NAND flash memory as the actual burning blocks of the file, such as normal blocks block11 or block12 of the NAND flash memory.

[0064] If all the preset burning blocks do not belong to the blocks in the bad block information, the preset burning blocks of each file are determined as the actual burning blocks. For example, there are 500 files in the file system, and the preset burning blocks of these files do not belong to the blocks in the bad block information. At this time, the preset burning blocks of the 500 files are the actual burning blocks in the subsequent burning process. It can be understood that when the preset burning block and the actual burning block of a file are the same, the offset of the file is 0.

[0065] Furthermore, if Figure 3 As shown, the process of adding the offset to the location information of each file in step S300 specifically includes:

[0066] Step S310: Create a pad file corresponding to the preset burning block in the file directory. Specifically, create a pad file in the file directory of the file system, and the pad file has a unique corresponding relationship with the preset burning block of the file.

[0067] Step S320, recording the number and offset of the preset burning block in the pad file. The pad file, as an extended information carrier, can store the number of the preset burning block and the offset of the file, so that it can be read by the burner in the subsequent burning process to find the actual burning block. Or it can be read by the processor in the file reading process after burning to find the actual burning block of the file, so as to accurately read the file.

[0068] Step S330, bind the pad file to the location information of the file. This allows the burner and processor to retrieve the pad file when burning and reading the location information of the file, so that the corresponding block can be found based on the location information and pad information of the file when burning and reading data, and then burned and read.

[0069] For example, during the programming process, the programmer reads the preset programming block of file A as block 10, and reads the pad file corresponding to the preset programming block of file A to obtain the offset 1 of file A. Then, the actual programming block of file A can be calculated to be block 11, and file A is programmed into block 11 of the NAND flash memory during programming.

[0070] For example, in the process of reading data, the processor reads the burning block of file A as block 10 according to the file directory of the file system. When accessing file A, block 11 of the NAND flash memory is actually accessed according to the offset of file A, so that file A can be read.

[0071] By using the pad file method, the offset is recorded and associated with the file location information, so as to guide the burner and processor to find the correct block when burning and reading data, thereby ensuring the burning integrity of the file system and the accuracy of the file system's access to files.

[0072] Further, in step 400, the process of burning the file of the file system to the NAND flash memory according to the location information and the offset specifically includes:

[0073] Step 410, read the pad file through the burner. The pad file corresponding to the target file in the file system is loaded and parsed by the burner program to obtain the relevant information of the file in the file system. For example: when burning file A, read the location information corresponding to file A and the pad file bound to the location information to obtain the information of the preset burning block of file A and the offset of file A.

[0074] Step 420, determine the actual burning block according to the offset and the information of the preset burning block. Based on the information of the preset burning block of the file obtained in step 410 and the offset of the file, calculate the actual burning block of the file. For example, when the preset burning block of file A is block10 and the offset of file A is 1, the actual burning block of file A is block11. The actual burning address of the file can be determined by this step.

[0075] Step 430: Burn the file to the actual burning block. For example, the preset burning block of file A obtained by the burner through steps 410 and 420 is block10, and the offset of file A is 1, then the actual burning block of file A calculated is block11, so the burner burns file A to block11 of the NAND flash memory.

[0076] Furthermore, after executing step 400, the method further includes step 500, verifying the integrity of the burned file system. The specific verification process is:

[0077] Verify the original file system and the image of the file system after burning. Specifically, read all the data of the original file system and the image of the file system after burning and compare the data.

[0078] If all data are completely consistent, the verification is considered to have passed and the file system has been burned successfully.

[0079] If some data is inconsistent, the verification is considered to have failed and needs to be reinitialized, erased, and the file system burned again until the verification passes.

[0080] This embodiment can effectively avoid data errors during the burning of the file system by adding a verification mechanism, thereby improving the stability and reliability of the burning.

[0081] In some embodiments, an electronic device 100 is also provided. Figure 4 As shown, the electronic device 100 includes a memory 110, a processor 120, and a computer program stored in the memory 110 and executable on the processor 120. When the processor 120 executes the computer program, the method for burning a file system in a NAND flash memory as described in the above embodiment is implemented. Among them, the memory 110 is used to store data information such as computer programs and file system images, and can be implemented using data carriers such as NAND flash memory chips. The processor 120 is used to read and parse the computer program, and to operate and process the data and the file system according to the program instructions. The processor 120 can be a CPU or a single-chip microcomputer, but is not limited thereto.

[0082] The computer program is pre-designed and is used to implement the method for burning a file system in a NAND flash memory as described in the above embodiment. The computer program is stored in the memory 110 mentioned above.

[0083] When the processor 120 loads and executes the computer program, the processor 120 reads and parses the instructions of the computer program, and gradually completes steps 100 to 400 of the above embodiment according to the instructions.

[0084] In some embodiments, a storage medium is also provided, which stores a computer program, and when the computer program is executed by a processor, the method of burning a file system in a NAND flash memory as described in the above embodiment is implemented. The storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0085] The above description is only a partial or preferred embodiment of the present invention. Neither the text nor the drawings can limit the scope of protection of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the overall concept of the present invention, or direct / indirect application in other related technical fields are included in the scope of protection of the present invention.

Claims

1. A method for burning a file system in a NAND flash memory, characterized in that: include: Get bad block information of NAND flash memory; Determine the actual burning block of each file in the file system according to the bad block information, and calculate the offset of each file; Adding the offset to the location information of each file includes: creating a pad file corresponding to the preset burning block in the file directory, recording the number of the preset burning block and the offset in the pad file, and binding the pad file to the location information of the file; Burning the file system in the NAND flash memory; The file is burned into the NAND flash memory according to the position information and the offset, comprising: reading the pad file through a burner, determining the actual burning block according to the offset and the number of the preset burning block, and burning the file into the actual burning block; When reading a file after burning is completed, the actual burning block of the file is searched according to the location information of the file and the offset, so that the location information of the file and the actual block of the file in the NAND flash memory are matched to read the file.

2. The method for burning a file system in a NAND flash memory according to claim 1, characterized in that: Determining the actual burning block of each file in the file system according to the bad block information comprises: According to the location information of each file, obtaining a preset burning block of each file; Determine whether one of the preset burning blocks is a block in the bad block information; If one of the preset burning blocks belongs to the block in the bad block information, the corresponding actual burning block of the file is determined to be another normal block of the NAND flash memory.

3. The method for burning a file system in a NAND flash memory according to claim 2, characterized in that: If all the preset burning blocks do not belong to the blocks in the bad block information, the preset burning block of each of the files is determined as the actual burning block of the file.

4. The method for burning a file system in a NAND flash memory according to claim 2, characterized in that: The calculation of the offset of each file includes: The offset is obtained according to the difference between the number of the actual burning block and the number of the preset burning block.

5. The method for burning a file system in a NAND flash memory according to claim 1, characterized in that: The obtaining of bad block information of NAND flash memory includes: Reading the SA area of ​​the NAND flash memory and creating a bad block table of the NAND flash memory; The bad block information is acquired according to the bad block table.

6. The method for burning a file system in a NAND flash memory according to claim 1, characterized in that: After burning the file system in the NAND flash memory, the method further includes: Verifying the integrity of the file system after burning; If the file system after burning is incomplete, the burning of the file system is performed again.

7. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for burning a file system in a NAND flash memory as claimed in any one of claims 1 to 6 is implemented.

8. A storage medium, characterized in that: A computer program is stored, and when the computer program is executed by a processor, the method for burning a file system in a NAND flash memory as claimed in any one of claims 1 to 6 is implemented.