CN111290716A - Abrasion balance processing method based on Norflash - Google Patents
Abrasion balance processing method based on Norflash Download PDFInfo
- Publication number
- CN111290716A CN111290716A CN202010146991.XA CN202010146991A CN111290716A CN 111290716 A CN111290716 A CN 111290716A CN 202010146991 A CN202010146991 A CN 202010146991A CN 111290716 A CN111290716 A CN 111290716A
- Authority
- CN
- China
- Prior art keywords
- sector
- erasing
- erasing times
- norflash
- dmax
- 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.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input 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/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/0644—Management of space entities, e.g. partitions, extents, pools
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input 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/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0679—Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
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)
- Techniques For Improving Reliability Of Storages (AREA)
Abstract
Description
技术领域technical field
本发明涉及嵌入式数据存储领域,特别是一种基于Norflash的磨损平衡处理方法。The invention relates to the field of embedded data storage, in particular to a Norflash-based wear leveling processing method.
背景技术Background technique
基于成本考量,目前很多嵌入式系统都采用单片Norflash存储介质来存储程序和数据,一般采用的Norflash空间都非常小,在几十K-几M之间。Based on cost considerations, many embedded systems currently use a single-chip Norflash storage medium to store programs and data. Generally, the Norflash space used is very small, ranging from tens of K to several M.
Norflash含有多个扇区,每个扇区可以进行单独并多次编程,只要每次写入的数据可将1写成0即可。例如0xff可以写成0xfe,0xfe可以再写成0xfc,但如果需要将0写成1时,例如需要将0xfe写成0xff,则需要擦除整个扇区再重写。Norflash contains multiple sectors, and each sector can be programmed individually and multiple times, as long as the data written each time can write 1 to 0. For example, 0xff can be written as 0xfe, and 0xfe can be written as 0xfc, but if 0 needs to be written as 1, for example, 0xfe needs to be written as 0xff, the entire sector needs to be erased and then rewritten.
Norflash的每个扇区的寿命是单独计算,一般来说有10W次擦除次数。The life of each sector of Norflash is calculated separately, generally speaking, there are 10W erasing times.
为避免部分扇区过快过早终结寿命,通常都用磨损平衡算法来保证所有扇区的寿命均衡。In order to prevent some sectors from terminating their life too quickly and prematurely, a wear leveling algorithm is usually used to ensure that the lifespan of all sectors is balanced.
为了实现磨损平衡,通常的做法,在flash中划出一部分功能区域用于记录每个扇区的擦除次数,例如图1,其中图1中1,2,3……为扇区编号。In order to achieve wear leveling, it is common practice to delineate a part of the functional area in the flash to record the erasure times of each sector, such as Figure 1, where 1, 2, 3... are sector numbers in Figure 1.
当系统需要用到空闲扇区写记录数据时,需要查询记录的扇区寿命信息,从中挑选出合适的扇区。When the system needs to use the free sector to write recorded data, it needs to query the recorded sector life information, and select a suitable sector from it.
这种做法有明显的缺点:This approach has obvious disadvantages:
(1) 这些功能区域本身也有寿命问题,为了支持这些大量的擦除记录需求,则需要大量的功能区域,这样就造成比较大的空间浪费。(1) These functional areas themselves also have a lifespan problem. In order to support these large-scale erasing and recording requirements, a large number of functional areas are required, which results in a relatively large waste of space.
(2)在不同使用场景下,功能区域之间的寿命实际上并不平衡,例如用于记录寿命的区域可能会比数据区域的寿命更短。(2) In different usage scenarios, the lifespan between functional areas is actually not balanced. For example, the lifespan of the area used for recording lifespan may be shorter than that of the data area.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本发明的目的是提供一种基于Norflash的磨损平衡处理方法,能够在基于磨损平衡情况下,分配各个扇区的寿命,最大程度上实现扇区间的磨损平衡。In view of this, the purpose of the present invention is to provide a Norflash-based wear leveling processing method, which can allocate the life of each sector based on the wear leveling condition, and realize the wear leveling among the sectors to the greatest extent.
本发明采用以下方案实现:一种基于Norflash的磨损平衡处理方法,The present invention adopts the following scheme to realize: a kind of wear leveling treatment method based on Norflash,
在Norflash每个扇区被使用前,将每个扇区的擦除次数分别记录于对应扇区的前部或后部;当需要用到新的扇区时,扫描目前所有扇区擦除次数情况,将扇区擦除的偏差值与设定阈值比较,选取空闲扇区。Before each sector of Norflash is used, record the erasing times of each sector in the front or rear of the corresponding sector; when a new sector needs to be used, scan the erasing times of all current sectors In this case, compare the deviation value of sector erasing with the set threshold, and select a free sector.
进一步地,令嵌入式系统每个扇区对应的擦除次数分别为C1、C2...Cn,其中,n为扇区的编号;Cmax表示系统中最大的擦除次数,Cmin表示系统中最小的擦除次数,令扇区擦除次数的偏差值为D,D=Cmax-Cmin;设置一个系统擦除次数最大偏差值Dmax,Dmax的范围为扇区擦除寿命的百分1至千分1;即只允许系统中最大的擦除次数偏差值Cmax-Cmin<=Dmax;Further, let the erasing times corresponding to each sector of the embedded system be C 1 , C 2 . . . Cn respectively, where n is the number of the sector; Cmax represents the maximum erasing times in the system, and Cmin represents the system The minimum number of erasing in the system, let the deviation value of the number of erasures of the sector be D, D=Cmax-Cmin; set a maximum deviation value of the number of erasing of the system Dmax, the range of Dmax is 1% of the erasing life of the sector to 1% 1 thousand points; that is, only the maximum erasure times deviation value Cmax-Cmin<=Dmax in the system is allowed;
当系统需要新扇区时,判断当前系统的D值,当D<设定的阀值Dmax时,则从系统随机分配一个扇区;当D>=设定的阀值Dmax时,则分配Cmin对应的扇区给系统使用;若查找到的扇区内容为空,则给系统使用;如果此扇区有有效数据,则先将有效数据转移至其他扇区后再给系统使用。When the system needs a new sector, the D value of the current system is judged. When D < the set threshold Dmax, a sector is randomly allocated from the system; when D>= the set threshold Dmax, Cmin is allocated The corresponding sector is used by the system; if the content of the found sector is empty, it is used by the system; if there is valid data in this sector, the valid data will be transferred to other sectors before being used by the system.
与现有技术相比,本发明具有以下有益效果:Compared with the prior art, the present invention has the following beneficial effects:
(1)本发明取扇区的前部或后部取某段区域记录该扇区的擦除次数。这样,每个扇区的擦除次数被准确记录下。并在每次系统启动时,将这些信息记录于内存中。这样做可以很快检索到所有扇区的擦除信息。(1) The present invention takes the front part or the rear part of the sector to take a certain area to record the erasing times of the sector. In this way, the number of erasures of each sector is accurately recorded. And each time the system starts, the information is recorded in the memory. Doing so quickly retrieves erasure information for all sectors.
(2)本发明当D<Dmax时,可以随机获取一个可用扇区,减少每次都定位最小擦除次数的扇区,可以大幅提高查询嵌入式系统运行的效率,即系统不需要花费大量时间来查找合适的可用的扇区。(2) When D<Dmax, the present invention can randomly acquire an available sector, reduce the number of sectors with the minimum number of erasures located each time, and greatly improve the efficiency of querying the operation of the embedded system, that is, the system does not need to spend a lot of time to find a suitable available sector.
附图说明Description of drawings
图1为本发明实施例现有技术中扇区划分记录擦除次数的示意图。FIG. 1 is a schematic diagram of sector division recording and erasing times in the prior art according to an embodiment of the present invention.
图2为本发明实施例的扇区划分时在扇区后部记录擦除次数的示意图。FIG. 2 is a schematic diagram of recording and erasing times at the rear of the sector during sector division according to an embodiment of the present invention.
图3为本发明实施例的扇区划分时在扇区前部记录擦除次数的示意图。3 is a schematic diagram of recording and erasing times at the front of a sector during sector division according to an embodiment of the present invention.
具体实施方式Detailed ways
下面结合附图及实施例对本发明做进一步说明。The present invention will be further described below with reference to the accompanying drawings and embodiments.
应该指出,以下详细说明都是例示性的,旨在对本申请提供进一步的说明。除非另有指明,本文使用的所有技术和科学术语具有与本申请所属技术领域的普通技术人员通常理解的相同含义。It should be noted that the following detailed description is exemplary and intended to provide further explanation of the application. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.
需要注意的是,这里所使用的术语仅是为了描述具体实施方式,而非意图限制根据本申请的示例性实施方式。如在这里所使用的,除非上下文另外明确指出,否则单数形式也意图包括复数形式,此外,还应当理解的是,当在本说明书中使用术语“包含”和/或“包括”时,其指明存在特征、步骤、操作、器件、组件和/或它们的组合。It should be noted that the terminology used herein is for the purpose of describing specific embodiments only, and is not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly dictates otherwise, the singular is intended to include the plural as well, furthermore, it is to be understood that when the terms "comprising" and/or "including" are used in this specification, it indicates that There are features, steps, operations, devices, components and/or combinations thereof.
本实施例提供一种基于Norflash的磨损平衡处理方法,在Norflash每个扇区被使用前,将每个扇区的擦除次数分别记录于对应扇区的前部或后部;当需要用到新的扇区时,扫描目前所有扇区擦除次数情况,将扇区擦除的偏差值与设定阈值比较,选取空闲扇区。This embodiment provides a Norflash-based wear leveling processing method. Before each sector of Norflash is used, the erasing times of each sector are respectively recorded in the front or rear of the corresponding sector; When a new sector is created, scan the current erasing times of all sectors, compare the deviation value of sector erasing with the set threshold, and select a free sector.
在本实施例中,令嵌入式系统每个扇区对应的擦除次数分别为C1、C2...Cn,其中,n为扇区的编号;,假设Cmax表示嵌入式系统中擦除次数的最大值,Cmin表示嵌入式系统中擦除次数的最小值,假设嵌入式系统的扇区擦除偏差值为D,则D=Cmax-Cmin;根据需要设置一个系统擦除次数最大偏差值Dmax,即只允许系统中最大的擦除次数Cmax-Cmin<=Dmax;典型的取Dmax为扇区擦除寿命的1/100 – 1/1000,以达到最佳的性能和寿命开销。例如扇区的擦除寿命为10万次,则Dmax可取值为100-1000之间。In this embodiment, the erasing times corresponding to each sector of the embedded system are respectively C 1 , C 2 . . . Cn, where n is the number of the sector; assuming that Cmax represents the erasure in the embedded system The maximum number of times, Cmin represents the minimum number of erasing times in the embedded system. Assuming that the sector erasure deviation value of the embedded system is D, then D=Cmax-Cmin; set a maximum deviation value of the system erasing times as needed Dmax, that is, only the maximum erasure times Cmax-Cmin<=Dmax is allowed in the system; Dmax is typically taken as 1/100 – 1/1000 of the erasure life of the sector to achieve the best performance and life overhead. For example, if the erasing life of a sector is 100,000 times, the value of Dmax can be between 100 and 1000.
当系统需要新扇区时,判断当前系统的D值,当D<设定的阀值Dmax时,则从系统随机分配一个扇区;当D>=设定的阀值Dmax时,则分配Cmin对应的扇区给系统使用;若查找到的扇区内容为空,则给系统使用;如果此扇区有有效数据,则先将有效数据转移至其他扇区后再给系统使用。When the system needs a new sector, the D value of the current system is judged. When D < the set threshold Dmax, a sector is randomly allocated from the system; when D>= the set threshold Dmax, Cmin is allocated The corresponding sector is used by the system; if the content of the found sector is empty, it is used by the system; if there is valid data in this sector, the valid data will be transferred to other sectors before being used by the system.
本实施例的做法是利用Norflash可多次编程特点,把擦除次数记录在扇区本身的前置或后置部分,这些扇区的擦除信息就跟着自身的扇区走。目的就是避免Cmax-Cmin >Dmax。这样处理的优点:在基于磨损平衡情况下,分配各个扇区的寿命,最大程度上实现扇区间的磨损平衡。The method of this embodiment is to use the feature of Norflash that can be programmed multiple times to record the number of erasures in the front or rear part of the sector itself, and the erasure information of these sectors follows their own sectors. The purpose is to avoid Cmax-Cmin > Dmax. The advantage of this processing is that in the case of wear leveling, the life of each sector is allocated, and the wear leveling between sectors is achieved to the greatest extent.
如图2、图3所示,C1表示该扇区的擦除次数。取扇区的前部或后部取某段区域记录该扇区的擦除次数。这样,每个扇区的擦除次数被准确记录下。As shown in Figure 2 and Figure 3, C1 represents the erasing times of the sector. Take the front or rear of the sector and take a certain area to record the erasing times of the sector. In this way, the number of erasures of each sector is accurately recorded.
并在每次系统启动时,将这些信息记录于内存中。这样做可以很快检索到所有扇区的擦除信息。And each time the system starts, the information is recorded in the memory. Doing so quickly retrieves erasure information for all sectors.
以上所述仅为本发明的较佳实施例,凡依本发明申请专利范围所做的均等变化与修饰,皆应属本发明的涵盖范围。The above descriptions are only preferred embodiments of the present invention, and all equivalent changes and modifications made according to the scope of the patent application of the present invention shall fall within the scope of the present invention.
Claims (2)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010146991.XA CN111290716A (en) | 2020-03-05 | 2020-03-05 | Abrasion balance processing method based on Norflash |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010146991.XA CN111290716A (en) | 2020-03-05 | 2020-03-05 | Abrasion balance processing method based on Norflash |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111290716A true CN111290716A (en) | 2020-06-16 |
Family
ID=71031059
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010146991.XA Pending CN111290716A (en) | 2020-03-05 | 2020-03-05 | Abrasion balance processing method based on Norflash |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111290716A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1652089A (en) * | 2004-02-06 | 2005-08-10 | 三星电子株式会社 | Method of Remapping Flash Memory |
US20070255889A1 (en) * | 2006-03-22 | 2007-11-01 | Yoav Yogev | Non-volatile memory device and method of operating the device |
US20090292839A1 (en) * | 2008-05-22 | 2009-11-26 | Sang-Jin Oh | Semiconductor memory device, memory system and data recovery methods thereof |
CN107908364A (en) * | 2017-11-13 | 2018-04-13 | 中国电子科技集团公司第三十研究所 | A kind of embedded file system based on norflash |
-
2020
- 2020-03-05 CN CN202010146991.XA patent/CN111290716A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1652089A (en) * | 2004-02-06 | 2005-08-10 | 三星电子株式会社 | Method of Remapping Flash Memory |
US20070255889A1 (en) * | 2006-03-22 | 2007-11-01 | Yoav Yogev | Non-volatile memory device and method of operating the device |
US20090292839A1 (en) * | 2008-05-22 | 2009-11-26 | Sang-Jin Oh | Semiconductor memory device, memory system and data recovery methods thereof |
CN107908364A (en) * | 2017-11-13 | 2018-04-13 | 中国电子科技集团公司第三十研究所 | A kind of embedded file system based on norflash |
Non-Patent Citations (1)
Title |
---|
罗智、沈晨蕾、高璐、张素辉: "NAND Flash损耗均衡算法研究", 《全国抗恶劣环境计算机第二十届学术年会论文集》 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10209902B1 (en) | Method and apparatus for selecting a memory block for writing data, based on a predicted frequency of updating the data | |
JP4399029B2 (en) | System data control method and architecture with automatic wear leveling in semiconductor non-volatile mass storage memory | |
US8086787B2 (en) | Wear leveling method, and storage system and controller using the same | |
US6675281B1 (en) | Distributed mapping scheme for mass storage system | |
JP4511576B2 (en) | Memory system | |
US8250286B2 (en) | Block management method, and storage system and controller using the same | |
US8200904B2 (en) | System and method for clearing data from a cache | |
US7882300B2 (en) | Apparatus and method for managing nonvolatile memory | |
US7654466B2 (en) | Semiconductor memory card, semiconductor memory control apparatus, and semiconductor memory control method | |
CN100487672C (en) | Method and apparatus for splitting a logical block | |
JP5006940B2 (en) | Non-volatile memory initiative wear leveling | |
KR100644602B1 (en) | Reimaging Control Method for Flash Memory and Its Structure | |
JP4611024B2 (en) | Method and apparatus for grouping pages in a block | |
EP0691008B1 (en) | Flash memory mass storage architecture | |
US6772274B1 (en) | Flash memory system and method implementing LBA to PBA correlation within flash memory array | |
JP4822440B2 (en) | Internal maintenance schedule request for non-volatile memory systems | |
US20140122774A1 (en) | Method for Managing Data of Solid State Storage with Data Attributes | |
US8417872B2 (en) | Write and merge methods in memory card systems for reducing the number of page copies | |
US9086805B2 (en) | Dynamic tracking of storage region operating parameters | |
KR20090077538A (en) | Semiconductor memory device and its wear management method | |
US20100030987A1 (en) | Data storing location managing method and data storage system | |
WO2011068109A1 (en) | Storage device and memory controller | |
US20100161890A1 (en) | Cache management method and cache device using sector set | |
US20200210345A1 (en) | Non-volatile memory device using efficient page collection mapping in association with cache and method of operating the same | |
CN111290716A (en) | Abrasion balance processing method based on Norflash |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200616 |
|
RJ01 | Rejection of invention patent application after publication |