CN115495024B - NandFlash-based wave recording file storage method, device, terminal and storage medium - Google Patents

NandFlash-based wave recording file storage method, device, terminal and storage medium Download PDF

Info

Publication number
CN115495024B
CN115495024B CN202211432629.4A CN202211432629A CN115495024B CN 115495024 B CN115495024 B CN 115495024B CN 202211432629 A CN202211432629 A CN 202211432629A CN 115495024 B CN115495024 B CN 115495024B
Authority
CN
China
Prior art keywords
block
good
recording file
nandflash
management list
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211432629.4A
Other languages
Chinese (zh)
Other versions
CN115495024A (en
Inventor
王志辉
狄维娜
李国朋
尹鋆辉
杨松
王志豪
盖世
叶丛林
尚京
赵飞龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shijiazhuang Kelin Electric Co Ltd
Original Assignee
Shijiazhuang Kelin Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shijiazhuang Kelin Electric Co Ltd filed Critical Shijiazhuang Kelin Electric Co Ltd
Priority to CN202211432629.4A priority Critical patent/CN115495024B/en
Publication of CN115495024A publication Critical patent/CN115495024A/en
Application granted granted Critical
Publication of CN115495024B publication Critical patent/CN115495024B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0616Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0652Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a recording file storage method, a device, a terminal and a storage medium based on NandFlash, wherein the method comprises the following steps: storing block addresses of a preset number of good blocks in a NandFlash memory into a management list, and allocating a block serial number to each block address; each good block is used for storing a wave recording file; when a recording file is obtained, determining a first good block in a management list based on a preset erasing rule; and writing the recording file into the first good block. The invention manages and uses the good blocks of the NandFlash memory through the management list without using a file management system, thereby avoiding occupying too large RAM on the premise of ensuring the balanced writing of the NandFlash memory.

Description

NandFlash-based wave recording file storage method and device, terminal and storage medium
Technical Field
The invention relates to the technical field of storage, in particular to a recording file storage method, device, terminal and storage medium based on NandFlash.
Background
The fault indicator collection unit needs to record fault recording data for a long time, and usually, nandFlash is used as a data memory, and NandFlash performs write-in operation by using blocks as basic units, so that the defect that the write-in frequency is limited exists, and marked bad blocks may exist when the fault indicator collection unit leaves a factory. In order to ensure the service life of NandFlash, bad blocks need to be identified, the bad blocks need to be avoided, and writing needs to be balanced (the writing times of all the blocks are ensured to be consistent as much as possible).
In view of the above requirements, nandFlash write-in is currently implemented by a file system having a life-span balancing algorithm. However, the file system occupies too large a Random Access Memory (RAM), and the use of the file system causes a series of problems such as increased power consumption of the fault indicator collection unit and longer processing time.
Disclosure of Invention
The invention provides a recording file storage method, a recording file storage device, a recording file storage terminal and a recording file storage medium based on NandFlash, and aims to solve the problem that a file system with a service life balancing algorithm occupies an overlarge RAM of a fault indicator collection unit.
In a first aspect, the invention provides a recording file storage method based on NandFlash, which comprises the following steps:
storing block addresses of a preset number of good blocks in the NandFlash memory into a management list, and allocating a block serial number to each block address; each good block is used for storing a wave recording file;
when a recording file is obtained, determining a first good block in the management list based on a preset erasing rule;
and writing the wave recording file into the first good block.
In one possible implementation, block0 is taken as a block management module.
In one possible implementation, the preset erasure rule is cyclic erasure;
the determining a first good block in the management list based on a preset erasure rule includes:
acquiring block sequence numbers corresponding to the latest wave recording file and the oldest wave recording file in the management list;
and if the distance between the block sequence number of the latest wave recording file and the block sequence number of the oldest wave recording file is less than n-1, taking the next block of the block sequence number of the latest wave recording file as a first good block.
In a possible implementation manner, if the distance between the block sequence number of the latest wave recording file and the block sequence number of the oldest wave recording file is n-1, taking the block where the oldest wave recording file is located as a first good block; wherein n represents the preset number;
the writing the recording file into the first good block includes:
erasing the oldest recording file;
and writing the wave recording file into the first good block.
In one possible implementation, the method further includes:
and if the first good block is detected to be damaged, determining a second good block in the good blocks which are not stored in the management list in the NandFlash memory, and replacing the block address of the first good block in the management list with the block address of the second good block.
In a possible implementation manner, if no good block which is not stored in the management list exists in the NandFlash memory, marking a block address which is stored corresponding to a block sequence number of the first good block as null, and determining the first good block in the management list based on a preset erasing rule again;
correspondingly, the determining the first good block in the management list based on the preset erasure rule includes:
and determining a first good block in the block sequence number of which the block address is not marked to be empty in the management list based on a preset erasing rule.
In a possible implementation manner, before the storing the block addresses of the preset number of good blocks in the NandFlash memory into a management list, the method further includes:
multiplying the storage capacity of the NandFlash memory by the allowable proportion of the bad blocks to obtain the maximum number of the bad blocks;
subtracting the maximum number of the bad blocks from the storage capacity of the NandFlash memory to obtain the minimum number n of good blocks;
and taking the minimum number n of the good blocks as the preset number.
In a possible implementation manner, the storing block addresses of a preset number of good blocks in the NandFlash memory into a management list, and allocating a block sequence number to each block address includes:
and storing the block addresses of a preset number of good blocks in the NandFlash memory into a management list according to the sequence, and sequentially allocating block sequence numbers.
In a second aspect, the present invention provides a recording file storage device based on NandFlash, including:
the list establishing module is used for storing the block addresses of a preset number of good blocks in the NandFlash memory into a management list and allocating a block serial number to each block address; each good block is used for storing a wave recording file;
the address determining module is used for determining a first good block in the management list based on a preset erasing rule when the recording file is obtained;
and the file erasing module is used for writing the wave recording file into the first good block.
In a third aspect, the present invention provides a terminal, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method according to the first aspect or any one of the possible implementation manners of the first aspect.
In a fourth aspect, the invention provides a computer-readable storage medium, in which a computer program is stored, which computer program, when executed by a processor, performs the steps of the method according to the first aspect or any one of the possible implementation manners of the first aspect.
The invention provides a recording file storage method, a device, a terminal and a storage medium based on NandFlash, wherein the method comprises the following steps: storing block addresses of a preset number of good blocks in a NandFlash memory into a management list, and allocating a block serial number to each block address; each good block is used for storing a wave recording file; when a recording file is obtained, determining a first good block in a management list based on a preset erasing rule; and writing the recording file into the first good block. The invention manages and uses the good blocks of the NandFlash memory through the management list without using a file management system, thereby avoiding occupying too large RAM on the premise of ensuring the balanced writing of the NandFlash memory.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a flow chart of the establishment of a management list provided by an embodiment of the present invention;
fig. 2 is a flowchart illustrating an implementation of a recording file storage method based on NandFlash according to an embodiment of the present invention;
fig. 3 is a flowchart illustrating an implementation of a recording file storage method based on NandFlash according to another embodiment of the present invention;
FIG. 4 is a diagram illustrating a structure of a management list provided by an embodiment of the present invention;
FIG. 5 is a diagram illustrating a structure of a management list provided by another embodiment of the present invention;
FIG. 6 is a diagram illustrating a structure of a management list provided by another embodiment of the present invention;
FIG. 7 is a diagram illustrating the relationship between a data structure and a management list according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a recording file storage device based on NandFlash according to an embodiment of the present invention;
fig. 9 is a schematic diagram of a terminal according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following description is made by way of specific embodiments with reference to the accompanying drawings.
In an embodiment of the invention, the NandFlash-based recording file storage method provided by the invention is used for storing a recording file generated by a transient recording type fault indicator. The transient recording type fault indicator is a new power distribution automation product which tends to be mature in recent years, has the functions of remote transmission of fault indication signals and high-sampling-rate recording, is started by combining electric field sensing recording, can transmit a synchronous waveform back when a low-current grounding system is grounded in a single phase, captures a transient process, and positions the single-phase grounding fault which is difficult to distinguish by a traditional method through a background system by a waveform similarity principle. The transient recording type fault indicator can generate recording data periodically, and NandFlash is usually used as a data memory. In order to guarantee the service life of the NandFlash, the NandFlash writing is required to be realized through a file system with a service life balancing algorithm. But migrating a file system with a life-balancing algorithm, the RAM requirement is about one percent of the memory capacity. The failure indicator collection unit RAM capacity is typically only a few tens of KB, requiring extended memory to address the RAM capacity issue. The fault indicator collection unit is powered by solar energy and a maintenance-free storage battery main and standby, the power consumption of the whole collection unit at present has strict requirements, and the power consumption is not more than 0.3VA under the condition of no communication on line. The expansion of the RAM can greatly increase the power consumption of the whole convergence unit. The power consumption can be reduced only by the way of CPU frequency reduction, and the running speed of the CPU is generally more than ten MHz. The recording data files of the fault indicator have the characteristics of large quantity and large capacity of a single file, and the running speed of a CPU (central processing unit) of more than ten MHz can cause a series of problems of long starting time of a collecting unit, slow access of the recording data and the like.
If a file system without a life-span balancing algorithm is used, such a file system has a relatively small RAM requirement, such as FAT16, but the absence of a life-span balancing algorithm is very disadvantageous for NandFlash. NorFlash memories can only be selected, but NorFlash has much smaller capacity and higher cost than NandFlash. If the mode of uploading the recording data in real time is used, the collection unit does not need to store the historical recording data file. However, when a continuous fault occurs on the line, the 4G communication cannot ensure that each recording data can be uploaded quickly, and the RAM space of the collecting unit cannot ensure that all real-time recording data are cached. The incomplete waveform data can seriously affect the accuracy of the subsequent ground fault analysis.
In addition, bad blocks are divided into two categories: one is that at the time of shipment, i.e., the new unused NandFlash is purchased, it may contain bad blocks. Such bad blocks that exist when leaving the factory are called factory (masked) bad blocks or initial/invalid blocks, and before leaving the factory, corresponding marks are made to mark as bad blocks. The second type is called generated in the using process, because the using process time is long, when a block is erased, an error is generated, the block is bad, and a bad block is also found and marked in the program running process, and the block is called a word-out bad block. As the erase-write life of other good blocks are not very different except that the block0 has a very long life, in order to avoid generating more bad blocks and prolong the service life of the bad blocks, the block management and the balanced management of the block use are needed when the NandFlash is used.
Fig. 1 shows a process for initializing the NandFlash memory and establishing a management list, which is implemented by a ferroelectric device. And the ferroelectric equipment judges whether the NandFlash memory is powered on for the first time through a Flag mark, wherein the Flag mark is 0 to indicate that the NandFlash memory is powered on for the first time, and the Flag mark is 1 to indicate that the NandFlash memory is not powered on for the first time. When the NandFlash memory is powered on for the first time, the ferroelectric equipment carries out whole-chip query on the NandFlash memory and establishes a management list.
Fig. 2 shows a processing flow after acquiring the recording file. The method specifically comprises the following steps: after a fault recording event is obtained, obtaining the next block sequence number of the stored latest recording file from the management list, and then writing the obtained fault recording event into the block sequence number; if the writing fails, updating the block address corresponding to the block sequence number, and continuously writing the block sequence number; if the block address cannot be updated, the block sequence number is replaced and a new block sequence number is written. And after the writing is finished, updating the block sequence number of the stored latest recording file in the ferroelectric equipment.
Referring to fig. 1, it shows a flowchart of an implementation of the method for storing a recording file based on NandFlash according to the embodiment of the present invention, which is detailed as follows:
step 101, storing block addresses of a preset number of good blocks in a NandFlash memory into a management list, and allocating a block serial number to each block address; wherein, each good block is used for storing a recording file.
In this embodiment, the wave recording file refers to a file obtained by the transient wave recording type fault indicator by synchronously synthesizing wave recording data of the phase a, phase B, and phase C acquisition units in the power system, and the wave recording file is analyzed to find a single-phase ground fault which is difficult to be determined by the conventional fault positioning method. According to the specification, the recording range of the fault indicator comprises not less than 4 cycles before starting and 8 cycles after starting, and the sampling rate is not less than 12.8kHz, namely not less than 256 sampling points per cycle. A file containing ABC three-phase recording needs to occupy about 80KB of storage space. The NandFlash memory takes a block as a minimum erasing unit, and the commonly used NandFlash is generally divided into 1024/2048/4096 blocks, and the commonly used block size is 128KB/256KB and the like. With this calculation, it is most reasonable for a recording file to occupy one block.
The block address in this embodiment refers to a serial number of each block in the NandFlash memory, and may be used to find a corresponding block for writing. The management list includes a mapping relationship between the block address and the block number, and the order of use of each block can be managed based on the mapping relationship.
Step 102, when the recording file is obtained, determining a first good block in a management list based on a preset erasing rule.
In this embodiment, the block addresses and the block serial numbers in the management list are in a one-to-one correspondence, and a corresponding block address can be found and written by selecting a block serial number as a first good block in the management list. And proper block sequence numbers can be selected through the preset erasing rules, so that the use degree of each block is balanced after the first good block is written. For example, the block numbers may be sorted, the obtained recording files may be written into the good blocks in sequence according to the order of the block numbers, the recording file written earliest may be erased, and the recording file obtained latest may be written into the block that has just been left empty.
And 103, writing the recording file into the first good block.
In this embodiment, the first good block may be free or may have a recording file, and if the recording file does not exist in the first good block, the first good block is an unused block, and the recording file may be directly written into the first good block. If the wave recording file exists in the first good block, the existing wave recording file is a file needing to be erased, and after the existing wave recording file needs to be erased, a new wave recording file is written into the first good block.
In one possible implementation, block0 is taken as a block management module.
In this embodiment, the management list needs to be updated many times in the block management process, and block0 is usually the block with the longest lifetime among the blocks of the memory, and the management list is stored in block0, which can ensure the reliability of block management.
In one possible implementation, the preset erasure rule is cyclic erasure;
determining a first good block in the management list based on a preset erasing rule, comprising:
acquiring block sequence numbers corresponding to the latest wave recording file and the oldest wave recording file in the management list;
and if the distance between the block sequence number of the latest recording file and the block sequence number of the oldest recording file is less than n-1, taking the next block of the block sequence number of the latest recording file as a first good block.
In this embodiment, the block sequence numbers of the blocks in the management list may be sequentially incremented, and the distance between two block sequence numbers may be calculated by the difference therebetween. The distance between the block sequence number of the latest wave recording file and the block sequence number of the oldest wave recording file can reflect the number of wave recording files between the latest wave recording file and the oldest wave recording file, if the distance between the block sequence number of the latest wave recording file and the block sequence number of the oldest wave recording file is less than n-1, it indicates that all blocks in the current memory are not completely occupied, namely, the wave recording file is not stored in the next block of the block sequence number of the latest wave recording file, and the wave recording file can be used as a first good block to write the newly obtained wave recording file into the first good block.
In a possible implementation manner, if the distance between the block sequence number of the latest wave recording file and the block sequence number of the oldest wave recording file is n-1, the block where the oldest wave recording file is located is taken as a first good block; wherein n represents a preset number;
writing the recording file into the first good block, including:
erasing the oldest recording file;
and writing the recording file into the first good block.
In this embodiment, if the distance between the block number of the latest recording file and the block number of the oldest recording file is n-1, which indicates that all blocks in the current memory are occupied, the oldest recording file should be erased to obtain a block with no data written therein, and then the newly obtained recording file is written into the block.
In one possible implementation, the method further includes:
and if the first good block is detected to be damaged, determining a second good block in the good blocks which are not stored in the management list in the NandFlash memory, and replacing the block address of the first good block in the management list with the block address of the second good block.
In this embodiment, in the process of establishing the management list, the blocks to be managed are all good blocks, but in the subsequent use, each block may be erased and written many times, and a bad block may appear. At the time of erasing or writing, if the block being erased is found to be damaged, it needs to be marked as a bad block and a good block is determined for replacement use among good blocks that are not stored to the management list.
In a possible implementation manner, if no good block which is not stored in the management list exists in the NandFlash memory, marking a block address which is stored corresponding to a block sequence number of the first good block as null, and determining the first good block in the management list based on a preset erasing rule again;
correspondingly, determining the first good block in the management list based on the preset erasing rule includes:
and determining a first good block in the block sequence number blocks of which the block addresses are not marked to be empty in the management list based on a preset erasing rule.
In this embodiment, most of the good blocks in the memory are already stored in the management list, the number of the good blocks which are not stored in the management list and can be used for replacement is small, if all the remaining good blocks are already replaced in the management list, and a bad block appears in the management list at this time, the good blocks cannot be replaced, the block sequence number corresponding to the bad block in the management list cannot be used again, and marking the block as empty can avoid repeated erasing and detecting of the block in subsequent use, and avoid reduction of erasing and writing efficiency.
In one possible implementation manner, before storing block addresses of a preset number of good blocks in the NandFlash memory into the management list, the method further includes:
multiplying the storage capacity of the NandFlash memory by the allowable proportion of the bad blocks to obtain the maximum number of the bad blocks;
subtracting the maximum number of bad blocks from the storage capacity of the NandFlash memory to obtain the minimum number n of good blocks;
and taking the minimum number n of good blocks as a preset number.
In the embodiment, the NandFlash standard specification allows the existence of bad blocks, and normally, the bad block is allowed as long as the proportion of the bad blocks is less than 2% of the total capacity, that is, the allowable proportion of the bad blocks is 2%. Therefore, by using this characteristic, taking GD5F1GQ4UCYIG (1Gb, 128MB,1024 blocks, block size: 128K) as an example, the maximum number of bad blocks is 20, the minimum number n of good blocks is 1004, and the NandFlash memory can store 1003 recording files after removing block0 as a block management module. The minimum number of good blocks is determined by using the steps of the embodiment, so that most of the good blocks can be contained in the management list during initialization, and excessive bad blocks do not exist.
In a possible implementation manner, storing block addresses of a preset number of good blocks in a NandFlash memory into a management list, and allocating a block sequence number to each block address includes:
and storing the block addresses of a preset number of good blocks in the NandFlash memory into a management list according to the sequence, and sequentially allocating block sequence numbers.
In this embodiment, the sequence refers to the block address sequence of each block in the NandFlash memory, and may specifically be from small to large, or from large to small. For example, after the block0 is used as the block management module, first store the block 1 to the management list, and assign the block number 1, then store the block 2 to the management list, and assign the block number 2, and so on, until the number of blocks stored in the management list reaches the preset number, the establishment of the management list is completed.
In a specific embodiment, taking GD5F1GQ4UCYIG as an example, the step of storing the recording file is as follows:
1. when the equipment is electrified and initialized for the first time, the NandFlash memory is subjected to whole piece query, and the block sequence numbers (except block 0) of 1003 good blocks are stored in a management list ManagerList. The list is 1004, the serial numbers 0-1002 store the block numbers of the blocks, the serial number 1003 stores the inquired maximum block serial number, and finally the list is written into the NandFlash block 0. The mapping relationship in the management list at this time is as shown in fig. 4.
2. If a bad Block appears in the Block in the list in the subsequent operation process, the Block is replaced by an unoccupied good Block, for example, block4 is damaged, the largest good Block sequence number 1009 is read from the sequence number 1003, the good Block is inquired from 1010, the found good Block is placed in the table with the sequence number 2 instead of Block4, and at this time, the value in the table of 1003 is also updated. The mapping relationship in the management list at this time is as shown in fig. 5.
3. When all the remaining blocks are bad blocks, if no extra good blocks are redistributed when the bad blocks appear in the good block distribution table again, the numerical value in the sequence number can be marked as NULL at the moment, the condition that the fault wave recording event in the sequence number is empty is shown, and the event in the next sequence number is continuously inquired. The mapping relationship in the management list at this time is as shown in fig. 6.
4. When the fault indicator equipment generates fault recording data, the data is stored in NandFlash in units of blocks, a data structure for managing the serial number of a fault recording file is stored in the ferroelectric equipment, the head and the tail of an event serial number are indicated in the data structure, the end points to the oldest serial number of the fault recording event, the head points to the newest serial number of the fault recording event, and the serial numbers are circularly processed from 0 to 1002 and correspond to the table serial numbers of the block management list. Therefore, all blocks in the NandFlash can be erased and written circularly when fault recording data is processed, and the aim of using the NandFlash in a balanced manner is fulfilled. Wherein the pointing relationship of the data structure to the management list is shown in fig. 7.
The method for storing the recording file based on the NandFlash provided by the embodiment of the invention comprises the following steps: storing block addresses of a preset number of good blocks in a NandFlash memory into a management list, and allocating a block serial number to each block address; each good block is used for storing a wave recording file; when a recording file is obtained, determining a first good block in a management list based on a preset erasing rule; and writing the recording file into the first good block. The invention manages and uses the good blocks of the NandFlash memory through the management list without using a file management system, thereby avoiding occupying too large RAM on the premise of ensuring the balanced writing of the NandFlash memory.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by functions and internal logic of the process, and should not limit the implementation process of the embodiments of the present invention in any way.
The following are embodiments of the apparatus of the invention, reference being made to the corresponding method embodiments described above for details which are not described in detail therein.
Fig. 8 is a schematic structural diagram of a recording file storage device based on NandFlash according to an embodiment of the present invention, and for convenience of description, only the relevant parts related to the embodiment of the present invention are shown, which is detailed as follows:
as shown in fig. 8, the NandFlash-based recording file storage device 8 includes:
the list establishing module 81 is used for storing the block addresses of a preset number of good blocks in the NandFlash memory into a management list and allocating a block serial number to each block address; each good block is used for storing a wave recording file;
the address determining module 82 is configured to determine a first good block in the management list based on a preset erasing rule when the recording file is acquired;
and the file erasing module 83 is configured to write the recording file into the first good block.
In one possible implementation, block0 is taken as a block management module.
In one possible implementation, the preset erasure rule is cyclic erasure;
the address determination module 82 is specifically configured to:
acquiring block sequence numbers corresponding to the latest wave recording file and the oldest wave recording file in the management list;
and if the distance between the block sequence number of the latest recording file and the block sequence number of the oldest recording file is less than n-1, taking the next block of the block sequence number of the latest recording file as a first good block.
In one possible implementation, the address determining module 82 is specifically configured to:
if the distance between the block sequence number of the latest wave recording file and the block sequence number of the oldest wave recording file is n-1, taking the block where the oldest wave recording file is located as a first good block; wherein n represents a preset number;
the file erasing module 83 is specifically configured to:
erasing the oldest recording file;
and writing the recording file into the first good block.
In a possible implementation manner, the NandFlash-based recording file storage device 8 further includes:
and the address replacement module is used for determining a second good block in the good blocks which are not stored in the management list in the NandFlash memory when the first good block is detected to be damaged, and replacing the block address of the first good block in the management list with the block address of the second good block.
In one possible implementation, the address replacement module is further configured to:
if no good block which is not stored in the management list exists in the NandFlash memory, marking a block address which is stored corresponding to the block sequence number of the first good block as null;
correspondingly, the address determination module 82 is further configured to:
and determining a first good block in the block sequence number blocks of which the block addresses are not marked to be empty in the management list based on a preset erasing rule.
In a possible implementation manner, the list establishing module 81 is further configured to:
before storing block addresses of a preset number of good blocks in a NandFlash memory into a management list, multiplying the storage capacity of the NandFlash memory by the allowable proportion of bad blocks to obtain the maximum number of bad blocks;
subtracting the maximum number of bad blocks from the storage capacity of the NandFlash memory to obtain the minimum number n of good blocks;
the minimum number n of good blocks is taken as the preset number.
In a possible implementation manner, the list establishing module 81 is specifically configured to:
and storing the block addresses of a preset number of good blocks in the NandFlash memory into a management list according to the sequence, and sequentially allocating block sequence numbers.
The recording file storage device based on the NandFlash provided by the embodiment of the invention comprises: the list establishing module is used for storing the block addresses of a preset number of good blocks in the NandFlash memory into a management list and allocating a block serial number to each block address; each good block is used for storing a wave recording file; the address determining module is used for determining a first good block in the management list based on a preset erasing rule when the recording file is obtained; and the file erasing module is used for writing the wave recording file into the first good block. The invention manages and uses the good blocks of the NandFlash memory through the management list without using a file management system, thereby avoiding occupying too large RAM on the premise of ensuring the balanced writing of the NandFlash memory.
Fig. 9 is a schematic diagram of a terminal according to an embodiment of the present invention. As shown in fig. 9, the terminal 9 of this embodiment includes: a processor 90, a memory 91 and a computer program 92 stored in said memory 91 and executable on said processor 90. The processor 90 implements the steps in each of the NandFlash-based recording file storage method embodiments described above when executing the computer program 92. Alternatively, the processor 90 implements the functions of the modules/units in the above-described device embodiments when executing the computer program 92.
Illustratively, the computer program 92 may be partitioned into one or more modules/units that are stored in the memory 91 and executed by the processor 90 to implement the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 92 in the terminal 9.
The terminal 9 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal 9 may include, but is not limited to, a processor 90, a memory 91. It will be appreciated by those skilled in the art that fig. 9 is only an example of a terminal 9 and does not constitute a limitation of the terminal 9 and may comprise more or less components than those shown, or some components may be combined, or different components, for example the terminal may further comprise input output devices, network access devices, buses, etc.
The Processor 90 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 91 may be an internal storage unit of the terminal 9, such as a hard disk or a memory of the terminal 9. The memory 91 may also be an external storage device of the terminal 9, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) and the like provided on the terminal 9. Further, the memory 91 may also include both an internal storage unit and an external storage device of the terminal 9. The memory 91 is used for storing the computer program and other programs and data required by the terminal. The memory 91 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal and method may be implemented in other ways. For example, the above-described apparatus/terminal embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the method according to the embodiments of the present invention may also be implemented by instructing relevant hardware by a computer program, where the computer program may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of the various embodiments of the recording file storage method based on NandFlash. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U.S. disk, removable hard disk, magnetic diskette, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signal, telecommunications signal, and software distribution medium, etc. It should be noted that the computer readable medium may contain suitable additions or subtractions depending on the requirements of legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media may not include electrical carrier signals or telecommunication signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (8)

1. A recording file storage method based on NandFlash is characterized by comprising the following steps:
storing block addresses of a preset number of good blocks in a NandFlash memory into a management list, and allocating a block serial number to each block address; each good block is used for storing a wave recording file;
when a recording file is obtained, determining a first good block in the management list based on a preset erasing rule;
writing the wave recording file into the first good block;
before storing the block addresses of the preset number of good blocks in the NandFlash memory into a management list, the method further comprises the following steps:
multiplying the storage capacity of the NandFlash memory by the allowable proportion of the bad blocks to obtain the maximum number of the bad blocks;
subtracting the maximum number of the bad blocks from the storage capacity of the NandFlash memory to obtain the minimum number n of good blocks;
taking the minimum number n of the good blocks as the preset number;
the preset erasing rule is cyclic erasing;
the determining a first good block in the management list based on a preset erasure rule includes:
acquiring block sequence numbers corresponding to the latest wave recording file and the oldest wave recording file in the management list;
and if the distance between the block sequence number of the latest wave recording file and the block sequence number of the oldest wave recording file is less than n-1, taking the next block of the block sequence number of the latest wave recording file as a first good block.
2. The NandFlash-based recording file storage method according to claim 1, wherein if the distance between the block number of the newest recording file and the block number of the oldest recording file is n-1, the block where the oldest recording file is located is taken as a first best block; wherein n represents the preset number;
writing the recording file into the first good block, including:
erasing the oldest recording file;
and writing the wave recording file into the first good block.
3. The NandFlash-based wave recording file storage method according to claim 1, further comprising:
and if the first good block is detected to be damaged, determining a second good block in the good blocks which are not stored in the management list in the NandFlash memory, and replacing the block address of the first good block in the management list with the block address of the second good block.
4. The NandFlash-based recording file storage method according to claim 3, wherein if no good block which is not stored in the management list exists in the NandFlash memory, the block address corresponding to the block sequence number of the first good block is marked as empty, and the first good block is determined in the management list again based on a preset erasing rule;
correspondingly, the determining the first good block in the management list based on the preset erasure rule includes:
and determining a first good block in the block sequence number of which the block address is not marked to be empty in the management list based on a preset erasing rule.
5. The NandFlash-based recording file storage method according to claim 1, wherein the storing block addresses of a preset number of good blocks in the NandFlash memory into a management list, and allocating a block sequence number to each block address, comprises:
and storing the block addresses of a preset number of good blocks in the NandFlash memory into a management list according to the sequence, and sequentially allocating block sequence numbers.
6. A recording file storage device based on NandFlash is characterized by comprising:
the list establishing module is used for storing the block addresses of a preset number of good blocks in the NandFlash memory into a management list and allocating a block serial number to each block address; each good block is used for storing a wave recording file;
the address determining module is used for determining a first good block in the management list based on a preset erasing rule when the recording file is obtained;
the file erasing module is used for writing the wave recording file into the first good block;
the list building module is further configured to:
before storing block addresses of a preset number of good blocks in a NandFlash memory into a management list, multiplying the storage capacity of the NandFlash memory by the allowable ratio of bad blocks to obtain the maximum number of bad blocks;
subtracting the maximum number of bad blocks from the storage capacity of the NandFlash memory to obtain the minimum number n of good blocks;
taking the minimum number n of good blocks as a preset number;
the preset erasing rule is cyclic erasing;
the address determination module is specifically configured to:
acquiring block sequence numbers corresponding to the latest wave recording file and the oldest wave recording file in the management list;
and if the distance between the block sequence number of the latest recording file and the block sequence number of the oldest recording file is less than n-1, taking the next block of the block sequence number of the latest recording file as a first good block.
7. A terminal comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of the preceding claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 5 above.
CN202211432629.4A 2022-11-16 2022-11-16 NandFlash-based wave recording file storage method, device, terminal and storage medium Active CN115495024B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211432629.4A CN115495024B (en) 2022-11-16 2022-11-16 NandFlash-based wave recording file storage method, device, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211432629.4A CN115495024B (en) 2022-11-16 2022-11-16 NandFlash-based wave recording file storage method, device, terminal and storage medium

Publications (2)

Publication Number Publication Date
CN115495024A CN115495024A (en) 2022-12-20
CN115495024B true CN115495024B (en) 2023-03-10

Family

ID=85115853

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211432629.4A Active CN115495024B (en) 2022-11-16 2022-11-16 NandFlash-based wave recording file storage method, device, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN115495024B (en)

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101051522A (en) * 2006-04-04 2007-10-10 北京锐科天智科技有限责任公司 Method for improving using life of storage and hardware device
CN101667189A (en) * 2009-05-06 2010-03-10 和芯微电子(四川)有限公司 NANDFLASH management method based on FAT file system
CN102929795A (en) * 2012-10-31 2013-02-13 飞天诚信科技股份有限公司 NandFlash bad block management method
CN104360958A (en) * 2014-12-09 2015-02-18 哈尔滨工业大学 Bad block management system and bad block management method based on block reservation area replacement
CN104615546A (en) * 2015-02-13 2015-05-13 小米科技有限责任公司 File data management method and device
CN105225696A (en) * 2015-10-15 2016-01-06 广东九联科技股份有限公司 A kind of bad block detection method of Set Top Box nandflash chip
CN105702300A (en) * 2016-01-11 2016-06-22 浙江大学 NAND Flash fault tolerant system based on FPGA (Field Programmable Gate Array)
CN106844079A (en) * 2016-12-28 2017-06-13 中国北方车辆研究所 The FLASH bad block managements system and management method of a kind of armored vehicle
CN107247563A (en) * 2017-07-06 2017-10-13 济南浪潮高新科技投资发展有限公司 A kind of block message mark implementation method of NAND FLASH chips
CN109633331A (en) * 2018-12-27 2019-04-16 中国南方电网有限责任公司 A kind of date storage method and fault wave recording device
CN110297606A (en) * 2019-06-28 2019-10-01 深圳忆联信息系统有限公司 Bad block management method, device and computer equipment based on solid state hard disk
CN110795044A (en) * 2019-10-31 2020-02-14 深圳市友华通信技术有限公司 Bad block management method and system for NAND Flash memory
CN111309678A (en) * 2020-02-22 2020-06-19 呼和浩特市奥祥电力自动化有限公司 Data circulation storage method and network message recording and analyzing device
CN113553003A (en) * 2021-06-17 2021-10-26 厦门大手控制技术有限公司 Data storage device and parking lot data storage system

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622306B (en) * 2012-02-21 2014-11-26 中颖电子股份有限公司 Bad block management method for storage device
CN102637461B (en) * 2012-03-07 2014-12-03 山东华芯半导体有限公司 Start method supporting bad block flash memory scanning
CN104091617B (en) * 2014-06-17 2017-05-03 深圳市江波龙电子有限公司 Flash memory equipment detection method and apparatus thereof
CN112711501B (en) * 2020-12-30 2023-04-25 杭州国芯科技股份有限公司 Method for managing bad blocks when NAND Flash is used as memory
CN114546292B (en) * 2022-02-28 2023-12-15 深圳市风云实业有限公司 Method and system for managing nand flash bad blocks

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101051522A (en) * 2006-04-04 2007-10-10 北京锐科天智科技有限责任公司 Method for improving using life of storage and hardware device
CN101667189A (en) * 2009-05-06 2010-03-10 和芯微电子(四川)有限公司 NANDFLASH management method based on FAT file system
CN102929795A (en) * 2012-10-31 2013-02-13 飞天诚信科技股份有限公司 NandFlash bad block management method
CN104360958A (en) * 2014-12-09 2015-02-18 哈尔滨工业大学 Bad block management system and bad block management method based on block reservation area replacement
CN104615546A (en) * 2015-02-13 2015-05-13 小米科技有限责任公司 File data management method and device
CN105225696A (en) * 2015-10-15 2016-01-06 广东九联科技股份有限公司 A kind of bad block detection method of Set Top Box nandflash chip
CN105702300A (en) * 2016-01-11 2016-06-22 浙江大学 NAND Flash fault tolerant system based on FPGA (Field Programmable Gate Array)
CN106844079A (en) * 2016-12-28 2017-06-13 中国北方车辆研究所 The FLASH bad block managements system and management method of a kind of armored vehicle
CN107247563A (en) * 2017-07-06 2017-10-13 济南浪潮高新科技投资发展有限公司 A kind of block message mark implementation method of NAND FLASH chips
CN109633331A (en) * 2018-12-27 2019-04-16 中国南方电网有限责任公司 A kind of date storage method and fault wave recording device
CN110297606A (en) * 2019-06-28 2019-10-01 深圳忆联信息系统有限公司 Bad block management method, device and computer equipment based on solid state hard disk
CN110795044A (en) * 2019-10-31 2020-02-14 深圳市友华通信技术有限公司 Bad block management method and system for NAND Flash memory
CN111309678A (en) * 2020-02-22 2020-06-19 呼和浩特市奥祥电力自动化有限公司 Data circulation storage method and network message recording and analyzing device
CN113553003A (en) * 2021-06-17 2021-10-26 厦门大手控制技术有限公司 Data storage device and parking lot data storage system

Also Published As

Publication number Publication date
CN115495024A (en) 2022-12-20

Similar Documents

Publication Publication Date Title
CN1126037C (en) Acess control for memory having a limited reasure frequency
CN105760113A (en) High-speed storage equipment based on NAND flash memory and file management method
CN101963912A (en) Implementation method for storing and checking hardware configuration information of system
CN111125033A (en) Space recovery method and system based on full flash memory array
CN109918352B (en) Memory system and method of storing data
CN109558333A (en) Solid storage device NameSpace with variable additional storage space (OP)
CN115292266A (en) High-reliability log storage method based on memory
CN105717833B (en) Intelligent environment protection number adopts instrument mainboard and working method
CN113704140A (en) Solid state disk address mapping method and device
CN111857574A (en) Write request data compression method, system, terminal and storage medium
CN113760187B (en) Method, system, terminal and storage medium for generating deduplication IO thread
CN114780448A (en) Method and device for quickly copying data, computer equipment and storage medium
CN115495024B (en) NandFlash-based wave recording file storage method, device, terminal and storage medium
CN109840048A (en) Store command processing method and its storage equipment
CN109426436A (en) Rubbish recovering method and device based on variable length bulk
CN111124313A (en) Data reading and writing method and device for power acquisition terminal and electronic equipment
CN114518848B (en) Method, device, equipment and medium for processing stored data
CN115543185B (en) Data storage management method, system, device and computer readable storage medium
WO2020000669A1 (en) Data code analysis method and apparatus
CN115617800A (en) Data reading method and device, electronic equipment and storage medium
CN111522512A (en) Optimized cold and hot data separation method and device, computer equipment and storage medium
CN117149672B (en) Disk array card cache configuration and reading methods and devices and disk array card
CN105659216A (en) Cache directory processing method and directory controller of multi-core processor system
CN117951084B (en) Data writing method and device of file system, storage medium and electronic equipment
CN109165172B (en) Cache data processing method and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant