File management method and system based on nor flash

By dividing NOR Flash into a linked list area and a data area, and adopting a pointer management method, the problems of convenience and resource consumption in NOR Flash file management in embedded systems are solved, achieving efficient file access and extended lifespan.

CN121070879BActive Publication Date: 2026-02-27NANJING GUODIAN NANZI POWER GRID AUTOMATION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511637694.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-10
Publication Date
2026-02-27
Estimated Expiration
2045-11-10

AI Technical Summary

Technical Problem

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.

Method used

The NOR Flash is divided into a linked list area and a data area. The linked list area stores management information, and the data area stores data content. Efficient file access is achieved through pointer management and erasure/transfer of sectors. A simple area division and pointer management method is adopted.

Benefits of technology

It enables efficient and convenient file management in resource-constrained systems, reduces resource consumption, extends the lifespan of NOR Flash, and meets the access requirements of specific files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121070879B_ABST
    Figure CN121070879B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of embedded software systems, and provides a NOR Flash-based file management method and system.The method comprises the following steps: NOR Flash is divided into a linked list area and a data area, the linked list area is provided with a plurality of first sectors, and the data area is provided with a plurality of second sectors; an erasing transfer sector is reserved in the linked list area; when the corresponding first sectors of the linked list area are updated to be full of a type of management information, part of the management information in the corresponding first sectors of the linked list area is transferred and erased based on the reserved erasing transfer sector; and when the corresponding second sectors of 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 writing data, and the data content written in the corresponding second sectors in the rear part is reserved.The application pre-allocates space for each file, simultaneously considers erasing balance, and is suitable for a single-chip microcomputer system with resource shortage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of embedded software system technology, and in particular to a file management method and system based on NOR Flash. Background Technology

[0002] In the field of embedded system development, there are many application scenarios with simple functions, huge shipment volumes, and very strict cost constraints. In these scenarios, inexpensive microcontrollers are usually used as the main processor. However, microcontrollers have simple functions, low performance, and limited resources. They generally do not have an operating system or a file system. When faced with scenarios that require file storage and access, there is no unified interface to meet the requirements.

[0003] In this application environment, it is generally only necessary to store some records related to the working status of the device, and only the most recent records need to be retained so that engineers can troubleshoot problems based on the records.

[0004] Therefore, the number of file types that need to be stored is relatively small (around a few dozen), the number of times each type of file needs to be retained is also small (around a few dozen times), and the file content is also relatively small (a few hundred bytes). NOR Flash is generally chosen as the medium for storing files because it has low cost, moderate storage space, and can meet the requirements.

[0005] The characteristics of NOR Flash are: it supports access to any address, but it must be erased before a "write" operation. The area to be erased at one time (generally called a sector) depends on the chip's characteristics, but is generally no less than 4KB. However, a file size is generally less than 4KB, which means it cannot be erased arbitrarily, making it inconvenient to use and unable to effectively manage stored data. At the same time, the lifespan of each sector decreases with the number of erases, thus reducing the lifespan of NOR Flash.

[0006] Furthermore, traditional solutions involve sector-based flash memory management. These solutions divide the memory into multiple blocks, called physical blocks, define a logical storage area, and divide it into multiple blocks, called logical blocks. A mapping between logical and physical spaces is established, and a two-level mapping table is created in RAM based on the logical block number in the physical block and the logical page number in the physical page. Traditional solutions that store the two-level mapping table in RAM have the following drawbacks:

[0007] 1. The mapping table requires a large amount of RAM space to store, which is a significant expense in resource-constrained systems such as microcontrollers.

[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-mentioned purpose, 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 are one-to-one linked 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 this type of file can be easily located, and the reading requirements such as "the earliest", "the last time", "the previous three times" are 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 limited resources such as single-chip microcomputer.

[0073] The present application aims at the file reading and writing requirements in the common NOR Flash-based single-chip microcomputer system environment, and proposes a file management system which is simple in logic, light in load, and convenient in reading and writing, under the condition of fully considering the system resource shortage and cost sensitivity. The system considers the erasure balance, is low in resource occupation, and is suitable for the single-chip microcomputer system with limited 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 limited 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 erase transfer Sector reserved 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 NOR Flash based file management method, characterized by, 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 are linked to the management information stored in each first sector one by one; When data contents are written into a designated 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 contents; An erasing transfer sector is reserved in the chain table area; When the corresponding first sector in the chain table area is updated to be full of a type of management information, the reserved part of the management information in the corresponding first sector in the chain table area is transferred based on the reserved erasing transfer sector, the remaining management information is erased, and then the reserved part of the management information temporarily stored in the erasing transfer sector is transferred back to the corresponding first sector; When the corresponding second sectors in the data area are full of a type of data contents, the data contents written in the corresponding second sectors in the front part are erased according to the order of writing the data contents, and the data contents written in the corresponding second sectors in the rear part are reserved. The reserved part of the management information in the corresponding first sector in the chain table area is transferred based on the reserved erasing transfer sector, which is to copy the last 50 links to the reserved erasing transfer sector in the chain table area.

2. The NOR Flash based file management method according to claim 1, characterized by, The application further comprises the following steps: A first pointer is set in the data area to always point to the second sector in which the data is stored earliest in the data area; A second pointer is set in the data area to always point to the idle second sector in which the data is to be written; The corresponding second sector in the data area is written based on the second pointer, and the overall data contents in the data area are read based on the first pointer.

3. The NOR Flash based file management method according to claim 2, characterized by, When the corresponding second sectors in the data area are full of a type of data contents, the data contents written in the corresponding second sectors in the front part are erased according to the order of writing the data contents, and the data contents written in the corresponding second sectors in the rear part are reserved. When the corresponding second sectors in the data area are full of a type of data contents, the data contents written in the second sector pointed to by the first pointer are erased, the first pointer is then pointed to the next second sector, and the data contents written in the next second sector pointed to by the first pointer are continuously erased, so as to cyclically erase the data contents in the corresponding second sectors until the minimum storage sector number requirement of the data contents is met.

4. The NOR Flash based file management method of claim 1, wherein, 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.

5. The NOR Flash based file management method according to any one of claims 1 to 4, characterized in that, The application further comprises the following steps: After the data contents written in the corresponding second sectors in the data area are erased and the data contents written in the corresponding second sectors are reserved, the management information of the corresponding first sector in the chain table area is updated based on the reserved data contents.

6. A file management system based on NOR Flash characterized in that, The application comprises the following steps: The storage area division module divides 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 correspond to the management information stored in each first sector one by one; The data writing and management information updating module updates the management information of the corresponding first sector in the linked list area based on the written data contents when writing data contents into a specified second sector in the data area; The erase transfer sector setting module reserves an erase transfer sector in the linked list area; The management information erasing module transfers 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 when the corresponding first sector in the linked list area is updated to store a type of management information, erases the remaining management information, and then transfers the pre-reserved management information temporarily stored in the erase transfer sector back to the corresponding first sector; The data content erasing module erases the data contents written in the corresponding second sectors in the data area in the order of writing the data contents when the corresponding second sectors in the data area are written full of a type of data contents, and retains the data contents written in the corresponding second sectors in the order of writing the data contents. The reserved erase transfer sector based on the transfer of the pre-reserved part of the management information in the corresponding first sector in the linked list area is to copy the last 50 links to the reserved erase transfer sector in the linked list area.

7. An electronic device, characterized by The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the NOR Flash based file management method according to any one of claims 1-5.

8. A computer readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the NOR Flash based file management method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Wear leveling method suitable for Nor Flash data storage and storage device

    CN113793634A

  • Memory and optimization method of cache block

    CN119046186A