File management method and system based on NOR Flash
By dividing NOR Flash into a linked list area and a data area, and adopting pointer management and circular erase methods, the problems of convenient management and resource consumption of NOR Flash in embedded systems are solved, achieving efficient file access and extended Flash lifespan.
Patent Information
- Application Number
- CN202511637694.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-10
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2045-11-10
AI Technical Summary
In embedded systems, NOR Flash file management suffers from problems such as inconvenient management, high resource consumption, easy loss of mapping tables, and inability to meet specific file access requirements.
The NOR Flash memory is divided into a linked list area and a data area. The linked list area stores management information, while the data area stores the data content. Through pointer management and circular erase methods, efficient file access and balanced erasure are achieved.
It achieves file management with simple logic, low resource consumption, and convenient data access, which is suitable for microcontroller systems with limited resources, meets specific file access needs, and improves the lifespan of Flash memory.
Smart Images

Figure CN121070879A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of embedded software system, and particularly relates to a file management method and system based on NOR Flash. BACKGROUND
[0002] In the field of embedded system development, there are a large number of application scenarios with single function, huge shipment volume and very strict cost limitation. In general, a single chip microcomputer with low price is used as a main processor. The single chip microcomputer has simple function, low performance and less resources, and generally does not carry an operating system or a file system. When facing a scenario with file storage and access demand, there is no unified interface to meet the demand.
[0003] In this application environment, only some records related to the working state of the device need to be stored, and only the records in the last few times need to be kept, so that the engineering personnel can troubleshoot problems according to the records.
[0004] Therefore, the types of files to be stored are less (about dozens of types), the number of times to be kept for each type of file is not much (about dozens of times), and the file content is small (a few hundred bytes). In general, NOR Flash (NOR type flash memory) is selected as the medium for storing files, which has low cost and moderate storage space, and can meet the demand.
[0005] The NOR Flash has the following characteristics: supporting access to any address, erasing before writing, one-time erasing range (generally referred to as sector) determined by chip characteristics, generally not less than 4K bytes, and the size of a file is generally less than 4K bytes, which leads to that the NOR Flash cannot be erased arbitrarily, is not convenient to use, and cannot effectively manage the stored data. At the same time, the service life of each sector decreases with the increase of the number of erasing times, which reduces the service life of the NOR Flash.
[0006] In addition, the traditional scheme relates to a storage management method of flash memory based on sector access. In the traditional scheme, the memory is divided into more than one block, referred to as a physical block, a logical storage area is defined, and the logical storage area is divided into more than one block, referred to as a logical block. A mapping between the logical space and the physical space is established, and two-level mapping tables are established in RAM according to the logical block number in the physical block and the logical page number in the physical page. In the traditional scheme, the two-level mapping tables are saved in the RAM space, which has the following related defects:
[0007] 1. The mapping table needs to open a large RAM space to save, which is a large expense in a system environment with limited resources such as a single chip microcomputer.
[0008] 2, the key information is stored in RAM, if the device is powered off during operation, the mapping table will be lost and cannot be recovered, which is a fatal defect.
[0009] 3, for the demand: a kind of file needs to be stored multiple times, when reading specific content, the traditional scheme cannot be implemented. SUMMARY
[0010] The present application aims to solve at least one of the technical problems in the background art, and provides a NOR Flash-based file management method and system.
[0011] To achieve the above object, the present application provides a NOR Flash-based file management method, comprising:
[0012] The NOR Flash is divided into a linked list area and a data area, wherein the linked list area is provided with a plurality of first sectors for storing different management information, the data area is provided with a plurality of second sectors for storing different data contents, and the different data contents stored in each second sector correspond one-to-one to the management information stored in each first sector;
[0013] When writing data contents into a specified second sector in the data area, update the management information of the corresponding first sector in the linked list area based on the written data contents;
[0014] Reserve an erase transfer sector in the linked list area;
[0015] When the corresponding first sector in the linked list area is updated to store a type of management information, transfer the pre-reserved part of the management information in the corresponding first sector in the linked list area based on the reserved erase transfer sector, erase the remaining management information, and then transfer the pre-reserved management information temporarily stored in the erase transfer sector back to the corresponding first sector;
[0016] When the corresponding multiple second sectors in the data area are written full of a type of data contents, erase the data contents written in the corresponding second sectors in the former part according to the order of writing data, and retain the data contents written in the corresponding second sectors in the latter part.
[0017] According to one aspect of the present application, further comprising: setting a first pointer in the data area to always point to the second sector in which the data is stored earliest; and setting a second pointer to always point to the idle second sector in the data area to be written with data;
[0018] Based on the second pointer, write data into the corresponding second sector in the data area, and based on the first pointer, read the overall data contents in the data area.
[0019] According to one aspect of the present application, when the corresponding multiple second sectors of the data area are filled with one type of data content, the data content written in the corresponding second sectors of the former part is erased according to the order of storing data, and the data content written in the corresponding second sectors of the latter part is reserved, which comprises:
[0020] When the corresponding multiple second sectors of the data area are filled with one type of data content, the data content written in the second sector pointed by the first pointer is erased, the first pointer points to the next second sector after the erasing, and the data content written in the next second sector pointed by the first pointer is continuously erased, and the data content in the corresponding second sectors is cyclically erased in this way until the preset minimum storage sector number requirement of the data content is met.
[0021] According to one aspect of the present application, the pre-reserved part of the management information is the management information saved after the update, and the remaining management information to be erased is the management information saved before the update.
[0022] According to one aspect of the present application, it further comprises: after the data content written in the corresponding second sectors of the part of the data area is erased and the data content written in the corresponding second sectors of the part is reserved, the management information of the corresponding first sector in the chain table area is updated based on the reserved data content.
[0023] To achieve the above-mentioned purpose, the present application further provides a file management system based on NOR Flash, which comprises:
[0024] A storage area division module divides the NOR Flash into two parts of a chain table area and a data area, wherein the chain table area is provided with multiple first sectors for storing different management information, the data area is provided with multiple second sectors for storing different data content, and the different data content stored in each second sector is linked to the management information stored in each first sector one by one;
[0025] A data writing and management information updating module, when data content is written into a specified second sector in the data area, the management information of the corresponding first sector in the chain table area is updated based on the written data content;
[0026] An erasing transfer sector setting module, which reserves an erasing transfer sector in the chain table area;
[0027] A management information erasing module, when the corresponding first sector of the chain table area is updated to be filled with one type of management information, the pre-reserved part of the management information in the corresponding first sector of the chain table area is transferred based on the reserved erasing transfer sector, the remaining management information is erased, and then the pre-reserved management information temporarily stored in the erasing transfer sector is transferred back to the corresponding first sector;
[0028] The data content erasing module erases the data content written in the corresponding second sectors of the earlier part in the order of writing data and keeps the data content written in the corresponding second sectors of the later part when the corresponding multiple second sectors of the data area are full of one type of data content.
[0029] To achieve the above object, the application further provides an electronic device, comprising a processor, a memory and a computer program stored in the memory and executable on the processor, wherein the computer program is executed by the processor to implement the NOR Flash-based file management method.
[0030] To achieve the above object, the application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the NOR Flash-based file management method.
[0031] According to the scheme of the application, the application implements the access management of files (including management information and data content) by means of area division and pointers, adopts the concept of pre-allocating space for each file, separating the file chain table area and the data area, and provides a NOR Flash-based file management method and system, which is simple in logic, low in resource occupation, and convenient and efficient in data access.
[0032] The application proposes a file management method and system which is simple in logic, light in load and convenient in reading and writing, and considers the erasing balance and is low in resource occupation, and is suitable for single-chip microcomputer systems with limited resources.
[0033] In the application, the management information exists in the Flash, and is not lost due to power failure, and the required cache space accounts for a very small proportion of the Flash storage space, and is very suitable for single-chip microcomputer systems with limited resources.
[0034] Each type of file has exclusive management information, and the storage information of the file can be easily located, and the reading requirements such as "the earliest", "the last time" and "the last three times" can be met.
[0035] The erasing method of the chain table area and the data area is circular, which means that the erasing of the Flash is balanced for each type of file. BRIEF DESCRIPTION OF DRAWINGS
[0036] Figure 1a flow chart of a NOR Flash based file management method according to an embodiment of the present application;
[0037] Figure 2 a NOR Flash space allocation diagram according to Embodiment 1 of the present application;
[0038] Figure 3 a linked list area structure diagram according to Embodiment 1 of the present application;
[0039] Figure 4 a data area structure diagram according to Embodiment 1 of the present application. DETAILED DESCRIPTION
[0040] The present application will now be discussed with reference to exemplary embodiments. It should be understood that the embodiments discussed are only for the purpose of better understanding and thus implementing the present application by those of ordinary skill in the art, and are not intended to imply any limitation on the scope of the present application.
[0041] As used herein, the term "comprising" and its variants are to be construed as open-ended terms meaning "including, but not limited to," in connection with any device, method, or the like. The term "based on" is to be construed as "based at least in part on." The terms "one embodiment" and "an embodiment" are to be construed as "at least one embodiment."
[0042] Figure 1 a flow chart of a NOR Flash based file management method according to an embodiment of the present application. As shown in the figure, in the present embodiment, the NOR Flash based file management method comprises: Figure 1
[0043] dividing the NOR Flash into a linked list area and a data area, wherein the linked list area is provided with a plurality of first sectors for storing different management information, the data area is provided with a plurality of second sectors for storing different data contents, and the different data contents stored in each second sector are linked to the management information stored in each first sector one by one;
[0044] when writing data contents into a designated second sector in the data area, updating the management information in the corresponding first sector in the linked list area based on the written data contents;
[0045] reserving an erase transfer sector in the linked list area;
[0046] when the corresponding first sector in the linked list area is updated to be full of a type of management information, transferring the reserved part of the management information in the corresponding first sector in the linked list area based on the reserved erase transfer sector, erasing the remaining management information, and then transferring the reserved management information temporarily stored in the erase transfer sector back to the corresponding first sector;
[0047] When the corresponding multiple second sectors of the data area are written full of a type of data content, the data content written in the corresponding second sectors of the earlier part is erased according to the order of writing data, and the data content written in the corresponding second sectors of the later part is reserved. In this way, the management of files (including management information and data content) is realized by means of area division and pointers, the concept of dividing the chain table area and the data area by pre-allocating space for each file is adopted, the erasure balance is considered, and the system is suitable for single-chip microcomputer systems with scarce resources.
[0048] In the embodiment, the first sector and the second sector are the minimum erasing units.
[0049] Further, according to an embodiment of the present application, the present application further comprises: setting a first pointer in the data area to always point to the second sector in which the data is stored earliest in the data area; and setting a second pointer to always point to the idle second sector in which the data is to be written in the data area.
[0050] Based on the second pointer, data is written in the corresponding second sectors in the data area, and based on the first pointer, the overall data content in the data area is read.
[0051] Further, according to an embodiment of the present application, when the corresponding multiple second sectors of the data area are written full of a type of data content, the data content written in the corresponding second sectors of the earlier part is erased according to the order of storing data, and the data content written in the corresponding second sectors of the later part is reserved, comprising:
[0052] When the corresponding multiple second sectors of the data area are written full of a type of data content, the data content written in the second sector pointed to by the first pointer is erased, the next second sector is pointed to by the first pointer after the erasure, and the data content written in the next second sector pointed to by the first pointer is continuously erased, and in this way, the data content in the corresponding second sectors is cyclically erased until the preset minimum storage sector number requirement of the data content is met. In this way, the data content written earlier can be deleted, the data content written latest is reserved, and then the access and investigation and other processing are performed based on the data content written latest.
[0053] Further, according to an embodiment of the present application, the part of the pre-reserved management information is the management information saved after the update, and the remaining management information to be erased is the management information saved after the update. In this way, the management information corresponding to the data content written earlier can be deleted, the management information corresponding to the data content written latest is reserved, and then the access and investigation and other processing are performed based on the data content written latest and the management information.
[0054] Further, according to an embodiment of the present application, the present application further comprises: writing data content in a part of the corresponding second sector, reserving the data content written in the part of the corresponding second sector, and updating the management information of the corresponding first sector in the chain table area based on the reserved data content. In this way, the first sector and the second sector are associated with each other, the number of erasures of the first sector and the second sector is effectively balanced, and the service life of the NOR Flash is effectively improved.
[0055] According to the above scheme of the present application, the present application realizes access management of files (including management information and data content) through area division and pointer, adopts the concept of pre-allocating space for each file, separating the file chain table area and the data area, and provides a file management method based on NOR Flash, which is simple in logic, low in resource occupation, and convenient and efficient in data access. It has strong applicability in resource-constrained systems such as single-chip microcomputers.
[0056] The present application proposes a file management method which is simple in logic, light in load, and convenient in reading and writing, considering the erasure balance and low resource occupation, and is suitable for resource-constrained single-chip microcomputer systems, aiming at the file reading and writing requirements in the common NOR Flash-based single-chip microcomputer system environment, and fully considering the resource-constrained and cost-sensitive requirements.
[0057] According to the above scheme of the present application, the management information exists in the Flash, and there is no need to worry about power loss, and the required cache space is very small compared with the Flash storage space. It is very suitable for resource-constrained environments such as single-chip microcomputer systems.
[0058] Each type of file has exclusive management information, so it is easy to locate the storage information of this type of file, and meet the reading requirements such as "the earliest", "the last time", "the first three times".
[0059] The erasing method of the chain table area and the data area is circular, which means that the erasing of the Flash is balanced for each type of file.
[0060] Further, in order to achieve the above purpose, the present application further provides a file management system based on NOR Flash, comprising:
[0061] The storage area division module divides the NOR Flash into a chain table area and a data area, wherein the chain table area is provided with a plurality of first sectors for storing different management information, the data area is provided with a plurality of second sectors for storing different data content, and the different data content stored in each second sector is one-to-one linked to the management information stored in each first sector;
[0062] The data writing and management information updating module updates the management information of the corresponding first sector in the chain table area based on the data content to be written when writing the data content into the specified second sector in the data area;
[0063] The erase transfer sector setting module reserves an erase transfer sector in the chain table area;
[0064] The management information erasing module, when the corresponding first sector in the chain table area is updated to store a type of management information, transfers the reserved part of the management information in the corresponding first sector in the chain table area based on the reserved erase transfer sector, erases the remaining management information, and then transfers the reserved management information temporarily stored in the erase transfer sector back to the corresponding first sector;
[0065] The data content erasing module, when the corresponding multiple second sectors in the data area are written full of a type of data content, erases the data content written in the corresponding second sectors in the front part according to the order of writing the data, and retains the data content written in the corresponding second sectors in the rear part.
[0066] Further, according to an embodiment of the present application, the present application further comprises: setting a first pointer in the data area to always point to the second sector in which the data is stored earliest in the data area; and setting a second pointer to always point to the idle second sector in the data area to be written with data;
[0067] Based on the second pointer, data is written into the corresponding second sector in the data area, and based on the first pointer, the overall data content in the data area is read.
[0068] Further, according to an embodiment of the present application, when the corresponding multiple second sectors in the data area are written full of a type of data content, the data content written in the corresponding second sectors in the front part is erased according to the order of storing the data, and the data content written in the corresponding second sectors in the rear part is retained, comprising:
[0069] When the corresponding multiple second sectors in the data area are written full of a type of data content, the data content written in the second sector pointed to by the first pointer is erased, the first pointer is then pointed to the next second sector, and the data content written in the next second sector pointed to by the first pointer is continuously erased, and in this way, the data content in the corresponding second sector is cyclically erased until a preset minimum storage sector number requirement of the data content is met. In this way, the data content written earlier can be deleted, the data content written latest can be retained, and then the data content written latest can be accessed and investigated.
[0070] Further, according to an embodiment of the present application, the pre-reserved part of the management information is the management information saved after the update, and the remaining management information to be erased is the management information saved before the update. In this way, the management information corresponding to the data content written earlier can be deleted, and the management information corresponding to the data content written latest can be reserved, and then the access and search and other processing can be performed based on the data content and the management information written latest.
[0071] Further, according to an embodiment of the present application, the present application further comprises: writing the data content in the second sector corresponding to the part in the erasing data area, reserving the data content written in the second sector corresponding to the part, and updating the management information of the first sector corresponding to the part in the chain table area based on the reserved data content. In this way, the first sector and the second sector can be associated with each other, and the number of erasures of the first sector and the second sector can be effectively balanced, thereby effectively improving the service life of the NOR Flash.
[0072] According to the above scheme of the present application, the present application realizes the access management of the file (including the management information and the data content) by the way of area division and pointer, adopts the concept of pre-allocating space for each file, separating the file chain table area and the data area, and provides a file management system based on NOR Flash, which is simple in logic, low in resource occupation, and convenient and efficient in data access. It has strong applicability in the system with scarce resources such as single-chip microcomputer.
[0073] The present application aims at the file reading and writing requirements in the common single-chip microcomputer system environment based on NOR Flash, fully considers the requirements of scarce system resources and cost sensitivity, and proposes a file management system which is simple in logic, light in load, and convenient in reading and writing. The system considers the erasure balance, is low in resource occupation, and is suitable for the single-chip microcomputer system with scarce resources.
[0074] According to the above scheme of the present application, the management information exists in the Flash, and is not lost due to power failure, and the required cache space accounts for a very small proportion of the Flash storage space. It is very suitable for the environment with scarce resources such as single-chip microcomputer system.
[0075] Each type of file has exclusive management information, and the storage information of this type of file can be easily located, and the reading requirements such as "the earliest", "the last time", and "the first three times" can be met.
[0076] The erasing method of the chain table area and the data area is circular, which means that the erasing of the Flash is balanced for each type of file.
[0077] Further, to achieve the above object, the present application also provides an electronic device, comprising a processor, a memory and a computer program stored in the memory and executable on the processor, the computer program being executed by the processor to implement the NOR Flash-based file management method as described above.
[0078] Further, to achieve the above object, the present application also provides a computer readable storage medium, the computer readable storage medium storing a computer program, the computer program being executed by a processor to implement the NOR Flash-based file management method as described above.
[0079] To make the objects, technical solutions and advantages of the present application clearer, further detailed description will be given to the present application in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only the best mode of the present application, which are used to explain the present application and do not limit the protection scope of the present application, and all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of the present application.
[0080] Embodiment 1
[0081] The present embodiment provides a NOR Flash-based file management method, which comprises the following steps as shown in Figure 2 、 Figure 3 、 Figure 4
[0082] The NOR Flash has a storage space of 4M bytes, a minimum erasing unit of Sector of 4K bytes, and a total of 1024 Sectors.
[0083] The file types to be stored are taken as 100, the minimum storage times of each type of file are taken as 50, and the size of each file is taken as 512 bytes.
[0084] (1) Storage area division method:
[0085] The NOR Flash is divided into a linked list area and a data area in units of Sectors, the linked list area stores management information, and the data area stores specific data content;
[0086] The linked list area occupies very little storage space, and the allocation method is that each type of file (management information) corresponds to a first Sector, and in addition, one erasing transfer Sector (erasing transfer sector) for erasing management transfer data is reserved, and a total of 101 Sectors are allocated.
[0087] The chain table area is composed of a plurality of chain table units Link, each first Sector is composed of a 1-byte state flag and a 3-byte data address. The state flag indicates four states: free, valid, erasable, and erased; and the data address indicates the storage address of the data record corresponding to the Link in the data area.
[0088] The data area occupies most of the storage space, and the space other than the chain table area is all the data area. The data area space is an integer multiple of the second Sector (second sector), and the data area allocates exclusive storage space for the data content of each type of file, and the allocation unit is also an integer multiple of the second Sector.
[0089] In this example, the data area is allocated a total of 923 Sectors, of which one Sector can be reserved for erasing management transfer data, and the effective data storage space is 922 second Sectors (second sectors);
[0090] The data area allocates exclusive storage space for each type of file. A class of files requires 50*512=25K bytes in total, each second Sector can store 8 files, and according to the integer multiple of the Sector, 7 Sectors are required, one erasing transfer Sector is reserved, and a total of 8 Sectors are allocated. Storing 100 files requires 800 Sectors, and the selected Flash specification meets the demand;
[0091] The data area is composed of a plurality of data units Data, and Data is the specific data content of each file.
[0092] (2) Data management method:
[0093] A Base pointer (first pointer) is set in the data area, which always points to the second Sector (the second Sector where the data is stored earliest) corresponding to the logical number 0 of the data area; and an In pointer (second pointer) is set, which always points to the free second Sector to be written;
[0094] When writing data, data is written into the second Sector pointed to by the In pointer, and after completion, the state flag in the file Link (chain table unit Link in the first Sector) is updated to valid, and the data address in the Link is the second Sector pointed to by the In pointer. The length of this data write is 512 bytes; after writing, the In pointer is offset to the next free second Sector to be written;
[0095] When reading data, the overall data is read according to the position of the Base pointer.
[0096] (3) Erasing management method:
[0097] Data area erase management: when a type of file data area has no free Data, i.e. 8 second Sectors are full, a total of 64 files are stored, each second Sector stores 8 files, the second Sector pointed by the Base is erased, and there are 56 files left, which meets the minimum storage record number requirement. The Base pointer points to the next second Sector;
[0098] Link list area erase management: when a type of file link list is full, only the last 50 links are reserved for 50 times of minimum reservation, the last 50 links are copied to the reserved erase transfer Sector in the link list area, the file link list is erased, and the 50 links are copied back, and the 50 links in the reserved erase transfer Sector are erased.
[0099] Those skilled in the art can understand that the modules and algorithm steps described in combination with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0100] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working process of the above-described device and equipment can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.
[0101] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and actual implementation can have another division manner, for example, a plurality of modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed mutual ones can be indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0102] The modules described as separate components can or can not be physically separated, and the components shown as modules can or can not be physical modules, i.e. they can be located in one place, or can be distributed on a plurality of network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0103] In addition, each functional module in the embodiments of the present application can be integrated in one processing module, or each module can exist physically, or two or more modules can be integrated in one module.
[0104] The functions described above if implemented in the form of software functional modules and sold or used as independent products, can be stored in a computer readable storage medium. Based on such an understanding, the technical solutions of the present application essentially or partially contribute to the prior art, or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods for transmitting / receiving implemented by the embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, and various other media capable of storing program codes.
[0105] The above description is merely preferred embodiments of the present application and a description of the principles of the technology applied. It should be understood by those skilled in the art that the scope of the application involved in the present application is not limited to the technical solutions formed by the specific combinations of the above technical features, and also covers other technical solutions formed by any combination of the above technical features or equivalent features without departing from the inventive concept. For example, the above features are replaced with the technical features disclosed in the present application (but not limited to) having similar functions to form technical solutions.
[0106] It should be understood that the sequence of the steps in the summary of the application and the embodiments does not absolutely mean the order of execution, and the execution order of the processes should be determined according to their functions and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
Claims
1. A file management method based on NOR Flash, characterized in that, The application comprises the following steps: Divide the NOR Flash into a chain table area and a data area, wherein the chain table area is provided with a plurality of first sectors for storing different management information, the data area is provided with a plurality of second sectors for storing different data contents, and the different data contents stored in each second sector correspond to the management information stored in each first sector one by one; When data contents are written into a specified second sector in the data area, update the management information of the corresponding first sector in the chain table area based on the written data contents; Reserve an erasing transfer sector in the chain table area; When the corresponding first sector in the chain table area is updated to store a type of management information, transfer the reserved part of the management information in the corresponding first sector in the chain table area based on the reserved erasing transfer sector, erase the remaining management information, and then transfer the reserved management information temporarily stored in the erasing transfer sector back to the corresponding first sector; When a plurality of corresponding second sectors in the data area are written full of a type of data contents, erase the data contents written in the corresponding second sectors in the front part according to the order of writing data, and retain the data contents written in the corresponding second sectors in the rear part.
2. The NOR Flash based file management method according to claim 1, wherein, The application further comprises the following steps: Set a first pointer in the data area to always point to the second sector in which the data is stored earliest; Set a second pointer in the data area to always point to the idle second sector to be written with data; Based on the second pointer, write data into the corresponding second sector in the data area, and based on the first pointer, read the overall data contents in the data area.
3. The NOR Flash based file management method of claim 2, wherein, When a plurality of corresponding second sectors in the data area are written full of a type of data contents, erase the data contents written in the second sector pointed to by the first pointer according to the order of storing data, point the first pointer to the next second sector after the data contents are erased, continue to erase the data contents written in the next second sector pointed to by the first pointer, and cyclically erase the data contents in the corresponding second sectors in this way until the minimum storage sector number requirement of the data contents is met. The reserved part of the management information is the management information updated and saved later, and the remaining management information to be erased is the management information updated and saved earlier.
4. The NOR Flash based file management method of claim 1, wherein, The application further comprises the following steps:
5. The NOR Flash based file management method according to any one of claims 1 to 4, characterized in that, After the data contents written in part of the corresponding second sectors in the data area are erased, and the data contents written in part of the corresponding second sectors are retained, update the management information of the corresponding first sector in the chain table area based on the retained data contents. The application comprises the following steps:
6. A file management system based on NOR Flash characterized in that, A storage area division module divides the NOR Flash into a chain table area and a data area, wherein the chain table area is provided with a plurality of first sectors for storing different management information, the data area is provided with a plurality of second sectors for storing different data contents, and the different data contents stored in each second sector correspond to the management information stored in each first sector one by one; A data writing and management information updating module, when data contents are written into a specified second sector in the data area, updates the management information of the corresponding first sector in the chain table area based on the written data contents; A data writing and management information updating module, when data contents are written into a specified second sector in the data area, updates the management information of the corresponding first sector in the chain table area based on the written data contents; an erasing transfer sector setting module, which reserves an erasing transfer sector in the chain table area; an information erasing module, which, when the corresponding first sector of the chain table area is updated to store a full type of management information, transfers the reserved part of the management information in the corresponding first sector in the chain table area based on the reserved erasing transfer sector, erases the remaining management information, and then transfers the reserved management information temporarily stored in the erasing transfer sector back to the corresponding first sector; a data content erasing module, which, when the corresponding multiple second sectors of the data area are written full of a type of data content, erases the data content written in the corresponding second sectors in the front part according to the order of writing the data content, and retains the data content written in the corresponding second sectors in the rear part.
7. An electronic device, characterized by A computer program product is stored in a computer readable storage medium, and includes a computer program. The computer program is executed by a processor to implement the NOR Flash based file management method according to any one of claims 1 to 5.
8. A computer readable storage medium, characterized in that, A computer program product is stored in a computer readable storage medium, and includes a computer program. The computer program is executed by a processor to implement the NOR Flash based file management method according to any one of claims 1 to 5.
Citation Information
Patent Citations
NOR-Flash hash table storage method and apparatus
CN106897228A
Storage management method of NOR Flash of small-internal-memory single-chip microcomputer
CN108319433A
Wear leveling method suitable for Nor Flash data storage and storage device
CN113793634A
Data storage management method of embedded NOR FLASH chip
CN113886281A
Data read-write operation control method for prolonging service life of Flash memory
CN118689371A