Method and system for managing and maintaining files on NAND FLASH of spaceborne computer
Through the Yaffs2 file system and dynamic logical-physical address mapping table, combined with the wear leveling algorithm and redundant block replacement technology, the wear leveling and bad block management problems of NAND FLASH in the onboard computer are solved, improving data reliability and system efficiency.
Patent Information
- Application Number
- CN202510547303.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-09-16
AI Technical Summary
In the existing technology, the wear leveling management and bad block management of NAND FLASH by onboard computers are insufficient, resulting in overuse of certain blocks and formation of bad blocks, which affects the read and write speed and data reliability.
The Yaffs2 file system and dynamic logical-physical address mapping table are used, combined with a wear leveling algorithm and redundant block replacement technology to achieve transparent allocation of storage space and bad block management. Data writes are evenly distributed through the least recently used (LRU) algorithm, bad blocks are identified and marked in real time, and the logical-physical address mapping is updated through dynamic replacement of redundant blocks.
It achieves wear leveling of NAND FLASH, extends service life, improves data reliability and system efficiency, reduces the risk of data loss, and simplifies development and maintenance.
Smart Images

Figure CN120653191A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of onboard computer file management, and in particular to a method and system for managing and maintaining files on an onboard computer NANDFLASH. Background Art
[0002] As satellite missions become increasingly complex, the requirements for onboard computers are also increasing. Consequently, large-capacity data storage and management are becoming increasingly important. Non-volatile memory devices such as Flash memory (FLASH) offer advantages such as small size, low power consumption, and low cost, making them widely used as storage devices in onboard computers. However, the application of large-capacity non-volatile data storage solutions still faces challenges in terms of cost and software support. NAND Flash, with its fast write speeds, large capacity, and low cost, is suitable for applications requiring data storage. Currently, domestic onboard computers generally use FPGAs to control NAND Flash read and write operations. Data is stored in the NAND Flash in a sequential order. However, because NAND Flash blocks have a limited number of erase and write cycles, repeated erase and write operations on a single block can slow down read speeds or even damage and render it unusable. Once a block is damaged, the stored data becomes unusable. To improve read and write speeds and data reliability, bad block management is necessary.
[0003] Therefore, how to evenly use each storage block in Nand flash to avoid certain "specific" storage blocks from becoming bad blocks due to overuse, while also being able to promptly identify bad blocks when they are used and ensure that they are no longer used, is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0004] The purpose of the present invention is to address the shortcomings of the above-mentioned prior art and to provide a method and system for managing and maintaining files on the NAND FLASH of a space-borne computer, so as to solve the problem that current domestic space-borne computers generally use FPGA to control the reading and writing of NAND FLASH, and are unable to perform wear leveling management and bad block management on NAND FLASH.
[0005] On the one hand, a method for managing and maintaining files on a spaceborne computer's NAND FLASH is provided, comprising: S1: Use the Yaffs2 file system to manage NAND FLASH read and write at the file level, and implement transparent allocation of storage space based on a dynamic logical-physical address mapping table; S2: Uses a wear-leveling algorithm to evenly distribute data write operations to multiple physical sectors of the NAND FLASH, controlling unevenness and wear of the NAND FLASH sectors; S3: Identifies and marks bad blocks before shipment and those generated during use, dynamically replaces bad blocks with redundant blocks, and updates the mapping relationship between logical addresses and physical addresses to improve the reliability of file data stored on NAND FLASH.
[0006] Furthermore, in step S1, the transparent allocation of storage space based on the dynamic logical-physical address mapping table includes: By establishing a dynamic mapping table between logical sectors and physical sectors, the logical address of the file system is mapped to the physical address of NANDFLASH. The mapping table contains multiple mapping entries, each of which records the logical address, physical address and block status information; The mapping table adopts a hierarchical structure, including a global mapping table and a local block mapping table. The global mapping table records the correspondence between logical blocks and physical blocks, and the local mapping table records the detailed physical address distribution within a single logical block.
[0007] Furthermore, in step S2, using a wear leveling algorithm to evenly distribute data write operations to multiple physical sectors of the NAND FLASH includes: The wear leveling algorithm uses the least recently used algorithm (LRU) to dynamically adjust the write strategy, counting the number of erasures of each physical block in the NANDFLASH, and preferentially writing new data to the physical block with the least erasure count to achieve balanced wear of each block. If the number of erasures exceeds a preset threshold, a global block erase count balancing operation is triggered, migrating data from blocks with a high erase count to blocks with a low erase count. By updating the logical-physical address mapping table in real time, the data migration process is ensured to be transparent to the upper file system.
[0008] Furthermore, in step S3, dynamically replacing the bad block with the redundant block includes: During the initialization phase, the factory bad blocks are scanned and marked, and an initial bad block table is generated and stored in the reserved area of NAND FLASH; During runtime, it detects bad block generation events in real time, temporarily stores new bad block information in the memory buffer, writes it to the bad block table in batches when the system is idle, and updates the logical-physical address mapping table to skip bad blocks; Redundant physical blocks are used to replace bad blocks, and the logical addresses and replaced physical addresses are dynamically bound through a mapping table.
[0009] Preferably, the bad block table manages the factory bad blocks and the new bad blocks generated during use in a unified manner, and does not rely on an additional storage medium to store bad block information, and only implements bad block isolation by updating the logical-physical address mapping table; A redundant pool is pre-allocated in NAND FLASH. If a bad block is detected, the physical block corresponding to the logical address is marked as a bad block, the bad block is automatically skipped, a new physical block is allocated from the redundant pool, and the mapping table is updated to maintain the continuous address space of the file system for upper-layer applications.
[0010] More preferably, the bad block table further includes: The bad block marking adopts the strategy of directly writing into NAND FLASH instead of the real-time bad block marking method, combined with the real-time task scheduling mechanism of the operating system, triggering the persistence operation of the bad block table during the system idle period to avoid the interruption of the real-time task by the write operation.
[0011] Furthermore, the method further comprises: The underlying NAND FLASH hardware driver provides bad block identification, marking and erase counting functions. The Yaffs2 file system implements dynamic wear leveling and bad block replacement based on the hardware driver, and reduces random write operations through the log structure file system feature.
[0012] On the other hand, a method and system for managing and maintaining files on a spaceborne computer's NAND FLASH is also provided, comprising: The file read and write management module is used to perform file-level read and write management on NAND FLASH through the Yaffs2 file system and implement transparent allocation of storage space based on the dynamic logical-physical address mapping table; Wear leveling management module, which uses a wear leveling algorithm to evenly distribute data write operations to multiple physical sectors of NAND FLASH, and control the unevenness and wear of NAND FLASH sectors; The bad block management module is used to identify and mark bad blocks before delivery and bad blocks generated during use, dynamically replace bad blocks with redundant blocks, and update the mapping relationship between logical addresses and physical addresses to improve the reliability of file data stored on NAND FLASH.
[0013] At the same time, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that the program includes a boot program and an application program, and when executed by a processor, implements any of the above-mentioned methods for managing and maintaining files on the NAND FLASH of the onboard computer.
[0014] In addition, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to implement any of the above-mentioned methods for managing and maintaining files on the NAND FLASH of a satellite computer.
[0015] Compared with the prior art, the present invention has the following beneficial effects: The present invention uses a wear leveling algorithm to dynamically allocate data to the physical block with the least number of erases, avoiding excessive erasure of local blocks and making the wear level of all blocks tend to be balanced, thereby improving the durability and service life of NAND FLASH as a whole; The present invention identifies and marks bad blocks before shipment and bad blocks generated during use in real time, establishes a unified bad block table, and replaces bad blocks with spare good blocks through logical-physical address mapping, ensuring that data is not written to unreliable areas, effectively reducing the risk of data loss or damage. The present invention adopts a delayed bad block marking strategy, temporarily recording the newly generated bad block information in the memory and writing it to the NAND FLASH when the system is idle, thus avoiding the occupation of data processing bandwidth by real-time marking operations, thereby improving the real-time response capability and overall efficiency of the system; The present invention is based on the log structure characteristics of the Yaffs2 file system. All operations are read and written in file units, reducing the frequency of random writes. At the same time, combined with a dynamic logical-physical address mapping table, it shields the underlying bad block replacement details, provides a continuous address space for upper-level applications, and reduces the difficulty of development and maintenance. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings: Figure 1 This is a flow chart of a method for managing and maintaining files on a satellite-borne computer's NAND FLASH; Figure 2 A schematic diagram of a wear leveling algorithm flow of the present invention; Figure 3 This is a schematic diagram of a mapping table structure of the present invention; Figure 4 A schematic diagram of a bad block management process of the present invention; Figure 5 The figure is a hardware structure diagram of a method for managing and maintaining files on a satellite-borne computer's NAND FLASH according to the present invention. DETAILED DESCRIPTION
[0017] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0018] Through innovative wear-leveling strategies, delayed bad block marking mechanisms, dynamic address mapping table design, and high collaboration with the Yaffs2 file system, this invention achieves significant improvements in extending storage media life, ensuring data reliability, and optimizing system performance. It is suitable for high-reliability, long-life onboard computer application scenarios.
[0019] The specific implementation of the present invention is described below with reference to the accompanying drawings and embodiments.
[0020] Example 1 See also Figure 1 , a technical solution for a method of managing and maintaining files on a satellite-borne computer NAND FLASH provided in this embodiment, including: S1: Use the Yaffs2 file system to manage NAND FLASH read and write at the file level, and implement transparent allocation of storage space based on a dynamic logical-physical address mapping table; S2: Uses a wear-leveling algorithm to evenly distribute data write operations to multiple physical sectors of the NAND FLASH, controlling unevenness and wear of the NAND FLASH sectors; S3: Identifies and marks bad blocks before shipment and those generated during use, dynamically replaces bad blocks with redundant blocks, and updates the mapping relationship between logical addresses and physical addresses to improve the reliability of file data stored on NAND FLASH.
[0021] In step S1, this embodiment transplants and runs the Yaffs2 file system on the onboard computer to perform data read and write access on all NAND FLASH files.
[0022] In addition, the transparent allocation of storage space based on the dynamic logical-physical address mapping table further includes: By establishing a dynamic mapping table between logical sectors and physical sectors, the logical address of the file system is mapped to the physical address of NANDFLASH. The mapping table contains multiple mapping entries, each of which records the logical address, physical address and block status information; The mapping table adopts a hierarchical structure, including a global mapping table and a local block mapping table. The global mapping table records the correspondence between logical blocks and physical blocks, and the local mapping table records the detailed physical address distribution within a single logical block.
[0023] In this embodiment, the mapping table is structured as follows: Figure 3 As shown, the dynamic logical-physical address mapping table includes the association between logical address, physical address, erase count and block status, wherein the block status is used to identify good or bad blocks, free blocks or allocated blocks.
[0024] Then, the wear leveling management of step S2 is performed on the NAND FLASH on the onboard computer, and each storage block in the NAND FLASH is used evenly to prevent certain "specific" storage blocks from becoming bad blocks due to excessive use.
[0025] A wear-leveling algorithm distributes writes across multiple sectors on the Nand flash, controlling uneven writes and "wear" on the Nand flash. This algorithm creates a file partition table between the Nand flash's logical and physical sectors, providing a clear view of the file system. In principle, this algorithm ensures that all Nand flash sectors reach their endurance limits at approximately the same time, thereby extending the Nand flash's lifespan.
[0026] Specifically, the wear leveling algorithm of this embodiment adopts the least recently used algorithm LRU to dynamically adjust the write strategy. The specific implementation steps are as follows: Figure 2 As shown, first, the data instructions in each physical block are read and mapped to the physical address through the mapping table. The erasure counts of each physical block in the NAND FLASH are counted, and new data is preferentially written to the physical block with the least erasure count to achieve balanced wear of each block. If the erase count exceeds the preset threshold, the global block erase count balancing operation is triggered to migrate the data of the block with a high erase count to the block with a low erase count. By updating the logical-physical address mapping table in real time, the data migration process is ensured to be transparent to the upper file system.
[0027] Then, the bad block management in step S3 is performed to improve the reliability of the file data stored on the NAND FLASH. Figure 4 As shown, further comprising: During the initialization phase, the factory bad blocks are scanned and marked, and an initial bad block table is generated and stored in the reserved area of NAND FLASH; During runtime, it detects bad block generation events in real time, temporarily stores new bad block information in the memory buffer, writes it to the bad block table in batches when the system is idle, and updates the logical-physical address mapping table to skip bad blocks; Redundant physical blocks are used to replace bad blocks, and the logical addresses and replaced physical addresses are dynamically bound through a mapping table.
[0028] Specifically, when a used block needs to be rewritten, a swap block is selected based on the block's physical address, the data of the used block is sent to the swap block, and the used block is finally erased and used as a new block. The mapping table in the memory is updated to achieve the purpose of the rewrite operation.
[0029] The bad block table manages both factory bad blocks and newly generated bad blocks in a unified manner, and does not rely on additional storage media to store bad block information. Bad block isolation is achieved only by updating the logical-physical address mapping table. A redundant pool is pre-allocated in NAND FLASH. If a bad block is detected, the physical block corresponding to the logical address is marked as a bad block, the bad block is automatically skipped, a new physical block is allocated from the redundant pool, and the mapping table is updated to maintain the continuous address space of the file system for upper-layer applications.
[0030] The bad block marking adopts the strategy of directly writing into NAND FLASH instead of the real-time bad block marking method, combined with the real-time task scheduling mechanism of the operating system, triggering the persistence operation of the bad block table during the system idle period to avoid the interruption of the real-time task by the write operation.
[0031] Specifically, in this embodiment, the primary task of bad block management is to identify and mark bad blocks. Bad blocks are then stored in a bad block table and no longer used. The underlying FLASH driver provides functions for identifying and marking bad blocks, but the YAFFS2 file system does not implement this functionality. This method unifies newly generated bad blocks with original bad blocks, resulting in a simple design and requiring no additional storage space for the bad block table. However, the disadvantage is that newly generated bad blocks require a write operation.
[0032] Another task of bad block management is determining when to mark newly generated bad blocks. YAFFS2 uses a "mark as you generate" strategy, marking newly generated bad blocks immediately. This method ensures real-time updates of the bad block table and is ideal for storing the bad block table using external storage media. However, this solution uses a strategy of writing bad blocks directly to the flash memory. Real-time marking of bad blocks reduces the system's data processing capacity and may result in data loss. Therefore, this solution does not mark bad blocks in real time. Instead, it first records newly generated bad blocks in memory and then marks them when the system is idle.
[0033] In addition to the above, the method of the present invention also includes: The underlying NAND FLASH hardware driver provides bad block identification, marking and erase counting functions. The Yaffs2 file system implements dynamic wear leveling and bad block replacement based on the hardware driver, and reduces random write operations through the log structure file system feature.
[0034] In summary, the method provided by the present invention runs on an onboard computer and uses the Yaffs2 file system to implement wear leveling and bad block management for NAND FLASH storage files, thereby increasing the life of NAND FLASH.
[0035] This embodiment also provides a system for managing and maintaining files on the NAND FLASH of a satellite-borne computer, including: The file read and write management module is used to perform file-level read and write management on NAND FLASH through the Yaffs2 file system and implement transparent allocation of storage space based on the dynamic logical-physical address mapping table; Wear leveling management module, which uses a wear leveling algorithm to evenly distribute data write operations to multiple physical sectors of NAND FLASH, and control the unevenness and wear of NAND FLASH sectors; The bad block management module is used to identify and mark bad blocks before delivery and bad blocks generated during use, dynamically replace bad blocks with redundant blocks, and update the mapping relationship between logical addresses and physical addresses to improve the reliability of file data stored on NAND FLASH.
[0036] It should be noted that the steps in the method for managing and maintaining files on the NAND FLASH of a satellite computer provided in this embodiment can be implemented using corresponding modules in the system for managing and maintaining files on the NAND FLASH of a satellite computer. Those skilled in the art can refer to the technical solution of the system to implement the step flow of the method. That is, the embodiments in the system can be understood as preferred examples for implementing the method, which will not be described in detail here.
[0037] The hardware structure for implementing the method of this embodiment is as follows: Figure 5 shown.
[0038] In addition to implementing the system and its various devices provided by the present invention in purely computer-readable program code, it is entirely possible to implement the same functions of the system and its various devices provided by the present invention in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. by logically programming the method steps. Therefore, the system and its various devices provided by the present invention can be considered a hardware component, and the devices included therein for implementing the various functions can also be considered as structures within the hardware component; the devices for implementing the various functions can also be considered as both software modules implementing the method and structures within the hardware component.
[0039] Finally, it should be noted that the above description is merely a preferred embodiment of the present invention, and the scope of protection of the present invention is not limited to the above embodiment. All technical solutions based on the principles of the present invention are within the scope of protection of the present invention. It should be noted that improvements and modifications that do not depart from the principles of the present invention, which are apparent to those skilled in the art, should also be considered within the scope of protection of the present invention.
[0040] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A method for managing and maintaining files on a satellite-borne computer's NAND FLASH, characterized in that: include: S1: Use the Yaffs2 file system to manage NAND FLASH read and write at the file level, and implement transparent allocation of storage space based on a dynamic logical-physical address mapping table; S2: Uses a wear-leveling algorithm to evenly distribute data write operations to multiple physical sectors of the NAND FLASH, controlling unevenness and wear of the NAND FLASH sectors; S3: Identifies and marks bad blocks before shipment and those generated during use, dynamically replaces bad blocks with redundant blocks, and updates the mapping relationship between logical addresses and physical addresses to improve the reliability of file data stored on NAND FLASH.
2. The method for managing and maintaining files on the NAND FLASH of a satellite-borne computer according to claim 1, characterized in that: In step S1, the transparent allocation of storage space based on the dynamic logical-physical address mapping table further includes: By establishing a dynamic mapping table between logical sectors and physical sectors, the logical address of the file system is mapped to the physical address of NANDFLASH. The mapping table contains multiple mapping entries, each of which records the logical address, physical address and block status information; The mapping table adopts a hierarchical structure, including a global mapping table and a local block mapping table. The global mapping table records the correspondence between logical blocks and physical blocks, and the local mapping table records the detailed physical address distribution within a single logical block.
3. The method for managing and maintaining files on the NAND FLASH of a satellite-borne computer according to claim 1, characterized in that: In step S2, using a wear leveling algorithm to evenly distribute data write operations to multiple physical sectors of the NAND FLASH further includes: The wear leveling algorithm uses the least recently used (LRU) algorithm to dynamically adjust the write strategy. It counts the number of erases of each physical block in the NAND FLASH and preferentially writes new data to the physical block with the least erase count to achieve balanced wear of each block. If the erase count exceeds a preset threshold, a global block erase count balancing operation is triggered to migrate data from blocks with a high erase count to blocks with a low erase count. By updating the logical-physical address mapping table in real time, the data migration process is ensured to be transparent to the upper file system.
4. The method for managing and maintaining files on a satellite-borne computer NAND FLASH according to claim 1, wherein: In step S3, dynamically replacing bad blocks with redundant blocks further includes: During the initialization phase, the factory bad blocks are scanned and marked, and an initial bad block table is generated and stored in the reserved area of NAND FLASH; During runtime, it detects bad block generation events in real time, temporarily stores new bad block information in the memory buffer, writes it to the bad block table in batches when the system is idle, and updates the logical-physical address mapping table to skip bad blocks; Redundant physical blocks are used to replace bad blocks, and the logical addresses and replaced physical addresses are dynamically bound through a mapping table.
5. The method for managing and maintaining files on the NAND FLASH of a satellite-borne computer according to claim 4, characterized in that: The bad block table manages the factory bad blocks and the new bad blocks generated during use in a unified manner, and does not rely on additional storage media to store bad block information. It only implements bad block isolation by updating the logical-physical address mapping table; A redundant pool is pre-allocated in NAND FLASH. If a bad block is detected, the physical block corresponding to the logical address is marked as a bad block, the bad block is automatically skipped, a new physical block is allocated from the redundant pool, and the mapping table is updated to maintain the continuous address space of the file system for upper-layer applications.
6. The method for managing and maintaining files on the NAND FLASH of a satellite-borne computer according to claim 5, characterized in that: The bad block table further includes: The bad block marking adopts the strategy of directly writing into NAND FLASH instead of the real-time bad block marking method, combined with the real-time task scheduling mechanism of the operating system, triggering the persistence operation of the bad block table during the system idle period to avoid the interruption of the real-time task by the write operation.
7. The method for managing and maintaining files on a satellite-borne computer NAND FLASH according to claim 1, characterized in that: The method further comprises: The underlying NAND FLASH hardware driver provides bad block identification, marking and erase counting functions. The Yaffs2 file system implements dynamic wear leveling and bad block replacement based on the hardware driver, and reduces random write operations through the log structure file system feature.
8. A method and system for managing and maintaining files on a satellite-borne computer's NAND FLASH, characterized in that: include: The file read and write management module is used to perform file-level read and write management on NAND FLASH through the Yaffs2 file system and implement transparent allocation of storage space based on the dynamic logical-physical address mapping table; Wear leveling management module, which uses a wear leveling algorithm to evenly distribute data write operations to multiple physical sectors of NAND FLASH, controlling the unevenness and wear of NAND FLASH sectors; The bad block management module is used to identify and mark bad blocks before delivery and bad blocks generated during use, dynamically replace bad blocks with redundant blocks, and update the mapping relationship between logical addresses and physical addresses to improve the reliability of file data stored on NAND FLASH.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program includes a boot program and an application program, and when executed by a processor, implements the method for managing and maintaining files on the NAND FLASH of a satellite-borne computer according to any one of claims 1 to 7.
10. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to implement the method for managing and maintaining files on the NAND FLASH of the onboard computer as described in any one of claims 1 to 7.