CN100533408C - Flashmemory safety read-write method - Google Patents

Flashmemory safety read-write method Download PDF

Info

Publication number
CN100533408C
CN100533408C CNB2006100729163A CN200610072916A CN100533408C CN 100533408 C CN100533408 C CN 100533408C CN B2006100729163 A CNB2006100729163 A CN B2006100729163A CN 200610072916 A CN200610072916 A CN 200610072916A CN 100533408 C CN100533408 C CN 100533408C
Authority
CN
China
Prior art keywords
data
flash memory
file
file header
write
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.)
Expired - Fee Related
Application number
CNB2006100729163A
Other languages
Chinese (zh)
Other versions
CN1851672A (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.)
Feitian Technologies Co Ltd
Original Assignee
Beijing Feitian Technologies 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 Beijing Feitian Technologies Co Ltd filed Critical Beijing Feitian Technologies Co Ltd
Priority to CNB2006100729163A priority Critical patent/CN100533408C/en
Publication of CN1851672A publication Critical patent/CN1851672A/en
Application granted granted Critical
Publication of CN100533408C publication Critical patent/CN100533408C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)
  • Read Only Memory (AREA)

Abstract

Said method contains flush memory to proceed erasing operation using erasing block, file storing erasing block adopting log structure recorded file header added data object form, according to file header to proceed read write operation to file. The data modification is written in new physical address not original physical address. Even if in power down status in writing data process, system can very easy recover systematical data through rescanning and checking file header log information validity. Flush memory malposition writing method can ensure flush memory abrasion balance capable of effectively saving system memory and raising system performance.

Description

A kind of safety read-write method of flash memory
Technical field
The present invention relates to a kind of safety read-write method of flash memory, relate in particular to a kind of safety read-write method that is used for embedded system.
Background technology
Along with developing rapidly and widespread use of embedded system, need a kind of can repeatedly the programming in a large number, capacity is big, reads and writes, wipes quick and easy, simple, and peripheral components is few, cheap non-volatile memory device.Flash memory (Flash Memory) storage medium arises at the historic moment under this background demand.It is a kind of storer of based semiconductor, still can keep internal information after having system's power down, and online functional characteristics such as erasable, is a kind of novel storer of alternative EEPROM storage medium.And its read or write speed is faster than EEPROM, and cost is lower under the situation of same capability.Just because of it has characteristics such as low operating voltage, low-power consumption, high capacity, erasable speed be fast, so flash memory (Flash Memory) is just becoming an important composition unit in the embedded system.
Yet some characteristics of flash memory (Flash Memory) have caused its deficiency, particularly its read-write operation on using to do anti-power down protection and have handled the never well solution of this difficult problem.
The characteristic that flash memory (Flash Memory) is different from other storage medium mainly contains following:
1) the minimum addressing unit of flash memory is byte (byte), rather than the sector on the disk (sector).This means can be from any skew (offset) read data of a flash memory, but does not show that operation also is that unit carries out with the byte to flash memory wiping/writing.
2) (be wiped free of, but also do not have write operation to take place) when a flash memory is in clean state, each (bit) on this piece flash all is logical one.
3) each on the flash memory (bit) can be set to logical zero by write operation.Logical zero is set to logical one and but can not step-by-step (bit) operates, and can only carry out erasable operation for unit by erasable block (eraseblock).When in an erasable block, storing,, to change over 1 again, then must wipe whole block earlier, could revise then in case a certain position in a certain erasable block is write 0.From the upper strata, the erasable function of finishing is exactly interior each of erasable block all to be reseted put (reset) one-tenth logical one.
4) be limited the serviceable life of flash memory.Specifically, be that maximum erasable number of times by erasable block decides the serviceable life of flash memory.Surpassed maximum erasable number of times, this erasable block has just become bad piece (bad block).Therefore for fear of certain erasable block by excessively erasable, to such an extent as to it reaches maximum erasable number of times prior to other erasable block, we should be evenly distributed on each erasable block erasable operation under the little prerequisite that influences performance of trying one's best.This process is called abrasion equilibration (wear leveling).
Because these characteristics of flash media, file system operates at present when will be rewritten the sector of a block device on the flash memory, normally these erasable block ground, place, sector data are read in the internal memory, be placed in the buffer memory (buffer), then content corresponding with this sector in the buffer memory is replaced with new content, again this erasable block is carried out erasable operation, the data in will cushioning at last write back this erasable block.
The shortcoming of this implementation is clearly: efficient is low, will rewrite data on the whole erasable block to the renewal of a sector, also causes the very big waste of memory headroom; Abrasion equilibration is not provided, and those data place erasable blocks by frequent updating will at first become bad piece; Very dangerous, be easy to cause losing of data.If superincumbent operation between last two steps unexpected power down (power loss) has taken place, the data in the so whole erasable block have just all been lost.This is unacceptable in the unexpected recurrent embedded system of power down.
Summary of the invention
The problem to be solved in the present invention is to overcome wearing and tearing imbalance in the middle of the operation of above-mentioned flash reading and writing, dangerous and shortcoming that EMS memory occupation is too much, the method at the safe read-write of flash memory that a kind of safety, abrasion equilibration is provided and has saved internal memory.
The technical scheme that technical solution problem of the present invention is taked is: a kind of safety read-write method of flash memory, based on the dislocation read-write, the dislocation read-write is with respect to common one's own department or unit read-write of adopting.The method of the memory write at so-called one's own department or unit is to write the content that needs modification on the storage block of the former data of storage that process is wiped again, and specific operation process is described in detail in background technology.Dislocation reading/writing method most critical be exactly when the data in the flash memory are made amendment not on original physical address, but write on new physical address.Flash memory is that unit carries out erase operation with the erasable block, and file is stored in above the erasable block with the form that file header adds data volume, to the rewriting step of flash memory is:
1) reads corresponding fileinfo according to file header information;
2) in the middle of internal memory, the data that need in the data volume to revise are changed into the data content of needs, the revised file header;
3) look for one not use or wiped the back not have the memory block of using again, the amended content in the internal memory is write corresponding position in this new memory block by the file organization form;
Described file header adopts log-structured record, and it comprises filename, address offset, data volume length, file total length, file header check code, access time, version number.
Same file with version number new be valid data, when reading fileinfo, retrieval version number new file reads.
In the process of write data power down taking place, by rescaning flash memory, checks according to the file header check code legitimacy of each file journalization information to revert to the last revision valid data.
The erasable block of flash memory is remaining not for a long time, and system can trigger the garbage reclamation function.By the scanning document header, the validity of each data above the erasable block can be known by system, when data of storing above erasable block when all being invalid, system just can erasable again this erasable block to recycle it.When if adjacent erasable block valid data each other can be merged into an erasable block, system can merge them automatically.
The present invention has following superior effect:
1. can the safe and effective purpose that reaches flash memory write, even the situation of power down takes place in the process of write data, system checks the legitimacy of each file journalization information by rescaning flash media, also the data of recovery system easily.
2. can the erasable block of these data of storage all need not wiped and write again then one time in order to rewrite some data, can effectively avoid frequent erasable some erasable blocks, to such an extent as to it reaches maximum erasable number of times prior to other erasable block, thereby play abrasion equilibration, improve the flash memory effect in serviceable life.
3. do not need to read and write again whole erasable block at every turn, the use amount that can effectively save Installed System Memory, thus improve system performance.
Embodiment
Below in conjunction with specific embodiment the present invention is described in further detail:
The present invention is the thought based on the dislocation read-write that adopts, and dislocation is with respect to former common one's own department or unit of adopting.The method of the memory write at so-called one's own department or unit is to write the content that needs modification on the storage block of the former data of storage that process is wiped again, and specific operation process is described in detail in the above.
The key of dislocation read-write be exactly when the data in the flash memory are made amendment not on original physical address, but write on new physical address.The benefit of this method maximum is exactly can not wipe whole erasable block in order to revise some places, again read and write data then, do not need frequent erasable certain fixing erasable block like this, simultaneously do not need to take too much memory size yet, and under certain mechanism, can reach the purpose of anti-power down effectively.For this has adopted a log-structured method to the file that is stored in flash memory,, be easy to realize that the dislocation safety at flash memory writes based on a kind of like this method of log management.Following mask body is set forth the realization principle of whole process.
System data is stored in above the flash memory with the form that file header adds data volume.The file header daily record comprises: filename, address offset, data volume length, file total length, file header check code, access time, version number (can also expand according to concrete should being used for).As following table 1:
Table 1
Figure C200610072916D00081
Now be explained as follows respectively:
Filename: the ID of file;
Address offset: the start address of write operation;
Data volume length: file data body length;
The file total length: the file total length comprises the length of file header and data volume;
Access time: system visits the time of this journal file;
File header check code: the check code of include file head, the reliability of assurance file;
Version number: safeguard an ordering relation that belongs to above-mentioned file header all elements.
This ordering relation is most important in the whole operation process, introduces this ordering relation below in detail.
Version number: 1 skew: 0 length: 200 data: AAAAA From being offset 0 ' A ' that begins to write 200 bytes
Version number: 2 skews: 200 length: 200 data: BBBBBB From being offset 200 ' B ' that begin to write 200 bytes
Version number: 3 skews: 175 length: 50 data: CCCCCC From being offset 175 ' C ' that begin to write 50 bytes
As above shown in the table, suppose that certain file has three version numbers, it is respectively version number 1,2,3, they are respectively 0,200,175 at the corresponding address skew, data length is 200,200,50, write data and be respectively A, B, C, then after system reads file header information from flash memory, can generate following map information:
Figure C200610072916D00091
Figure C200610072916D00101
Figure C200610072916D00102
Being operating as of version 1 from being offset 0 ' A ' that begins to write 200 bytes, being operating as of version 2 from being offset 200 ' B ' that begin to write 200 bytes, being operating as of version 3 from being offset 175 ' C ' that begin to write 50 bytes, need to prove that the offset address here all is for logical address, and in fact the file of three versions writes on above the different physical addresss, and they do not exist overlapping above physical address.According to this map information table, system just knows to corresponding memory block and removes to read corresponding file content.Same file with version number high be valid data, therefore, the valid data of this file are 50 bytes ' C ' from logic skew 175 to 225 of version 3 at last.
When needs are rewritten certain file, do not remove to manage the storage physical address of former file, redistribute a memory block, or the form that adds data volume by file header is write above the flash memory, only file header log information is made corresponding change, and system just can read amended file content according to the scanning log information like this.Specific operation process is as follows:
1) system changes the data that need in the data volume to revise into the data content of needs in the middle of internal memory;
2) look for a clean memory block (not using or wiping the back does not have to use) again, write in this new memory block corresponding local by the file organization form the amended content in the internal memory;
3) write the part log information, for example address offset, data volume length, file total length, access time, file header check code etc.;
4) new version number is set and adds 1 for master this shop.
Above technical scheme can be known and find out, the safe and effective purpose that reaches flash reading and writing of method energy that the dislocation of the flash memory that the present invention adopts is write, even the situation of power down takes place in the process of write data, system is by rescaning flash media, check the legitimacy of each file journalization information, also the data of recovery system easily.If the erasable block of flash memory is remaining not for a long time in addition, system can trigger the garbage reclamation function.By the scanning document header, the validity of each data above the erasable block can be known by system, when data of storing above erasable block when all being invalid, system just can erasable again this erasable block to recycle it.And if adjacent erasable block valid data each other more after a little while, system also can merge them automatically.
By above operation, can find that file content has been rewritten as predetermined value safely, just write on other above physical address, whenever power down takes place in the middle of this process can not cause losing of data, thereby reached the purpose that safety is write, and the method write of dislocation also can effectively guarantee abrasion equilibration, can not cause it to become bad piece in advance because of frequent erasable some erasable blocks.Because do not need to read and write frequently whole erasable block, can save Installed System Memory effectively simultaneously, improve system performance.

Claims (8)

1, a kind of safety read-write method of flash memory, flash memory is that unit carries out erase operation with the erasable block, file is stored in above the erasable block with the form that the file header that adopts log-structured record adds data volume, wherein, record in the file header comprises filename, data volume address offset, data volume length and version number, to the rewriting step of file in the flash memory is:
1) scanning flash memory, the file header of retrieving novel version number;
2) described file header and corresponding data volume are read in the internal memory;
3) in internal memory, revise and need the data revised in the described data volume, upgrade version number in the described file header;
4) redistribute one according to the size of amended file header and data volume in the internal memory and do not use or wiped the back not have the erasable block that uses, amended described data volume and described file header are write described erasable block.
2. the safety read-write method of flash memory as claimed in claim 1, it is characterized in that: described file header also comprises file total length, file header check code, access time.
3. the safety read-write method of flash memory as claimed in claim 1 is characterized in that: the scanning internal memory, identical file with version number new be valid data.
4. as the safety read-write method of claim 2 or 3 described flash memories, it is characterized in that: in the process of write data, power down takes place, by rescaning flash memory, check the legitimacy of each file journalization information, restore data according to the file header check code.
5. the safety read-write method of flash memory as claimed in claim 3 is characterized in that: scan flash memory, retrieve the new file of version number and read.
6. the safety read-write method of flash memory as claimed in claim 1 is characterized in that: upgrade that version number adds 1 for version number is set for master this shop in the described file header.
7. the safety read-write method of flash memory as claimed in claim 5, it is characterized in that: by the scanning document header, check the validity of each data above the erasable block, when data of storing above the erasable block all are the data of invalid storage, just wipe this erasable block to recycle it again.
8. the safety read-write method of flash memory as claimed in claim 5 is characterized in that: can merge into an erasable block when adjacent erasable block valid data each other and just combine.
CNB2006100729163A 2006-04-05 2006-04-05 Flashmemory safety read-write method Expired - Fee Related CN100533408C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2006100729163A CN100533408C (en) 2006-04-05 2006-04-05 Flashmemory safety read-write method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2006100729163A CN100533408C (en) 2006-04-05 2006-04-05 Flashmemory safety read-write method

Publications (2)

Publication Number Publication Date
CN1851672A CN1851672A (en) 2006-10-25
CN100533408C true CN100533408C (en) 2009-08-26

Family

ID=37133151

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2006100729163A Expired - Fee Related CN100533408C (en) 2006-04-05 2006-04-05 Flashmemory safety read-write method

Country Status (1)

Country Link
CN (1) CN100533408C (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101458658B (en) * 2007-12-13 2011-07-06 中芯国际集成电路制造(上海)有限公司 Data storage method and apparatus for flash memory
WO2009103181A1 (en) * 2008-02-18 2009-08-27 中兴通讯股份有限公司 Device for implementing file system on nandflash of mobile terminal
CN101526927B (en) * 2008-03-07 2011-02-02 北京华虹集成电路设计有限责任公司 Data processing method and data processing device of Flash file system
CN101710237B (en) * 2008-12-30 2012-10-24 深圳市江波龙电子有限公司 Equipment production flow using flash memory as storage medium
CN101526921B (en) * 2008-12-31 2014-07-30 飞天诚信科技股份有限公司 Method and device for writing data
CN101707633B (en) * 2009-11-27 2012-08-22 山东中创软件商用中间件股份有限公司 Message-oriented middleware persistent message storing method based on file system
CN102012849B (en) * 2010-11-19 2012-10-24 中国人民大学 Flash memory-based database restoring method
CN102487395B (en) * 2010-12-01 2014-11-05 北京闪联云视信息技术有限公司 Method, device and system for realizing data access
CN102789404A (en) * 2011-05-20 2012-11-21 北京同方微电子有限公司 Method for storing anti-dropping data during updating of integrated circuit (IC) card data
CN106802923B (en) * 2016-12-19 2020-05-19 华中科技大学 File updating method and system based on solid-state disk
CN109857718A (en) * 2019-02-01 2019-06-07 广州亚美信息科技有限公司 A kind of Journal File System applied to embedded system
US10990316B2 (en) * 2019-06-28 2021-04-27 Western Digital Technologies, Inc. Log-based storage for different data types in non-volatile memory

Also Published As

Publication number Publication date
CN1851672A (en) 2006-10-25

Similar Documents

Publication Publication Date Title
CN100533408C (en) Flashmemory safety read-write method
CN101689140B (en) Memory system
CN101681314B (en) Memory system
CN101425041B (en) Optimizing method for establishing FAT file systems on NAND FLASH memory
CN100356347C (en) Safety writing method for flash memory
CN101169751B (en) System with flash memory device and data recovery method thereof
CN100435115C (en) Non-volatile memory and method with non-sequential update block management
US8312204B2 (en) System and method for wear leveling in a data storage device
TWI393140B (en) Methods of storing data in a non-volatile memory
JP5317690B2 (en) Memory system
US20150309927A1 (en) Hybrid Non-Volatile Memory System
CN102737715B (en) For the method for power fail safeguard of data of NOR flash memory
CN100449549C (en) Method for building file systems on NAND flash memory in embedded system
CN100501868C (en) Method for realizing memory file system based on NAND Flash
CN101681299A (en) Memory system
CN101539891A (en) Embedded type flash memory, storage system and method for power fail safeguard of data
US20100306447A1 (en) Data updating and recovering methods for a non-volatile memory array
CN105718530A (en) File storage system and file storage control method thereof
CN104346287A (en) Trim mechanism using multi-level mapping in a solid-state media
KR100845552B1 (en) Method for address mapping in Flash Translation LayerFTL
US20100306456A1 (en) Method for even utilization of a plurality of flash memory chips
EP2264602A1 (en) Memory device for managing the recovery of a non volatile memory
US20070005929A1 (en) Method, system, and article of manufacture for sector mapping in a flash device
CN100456263C (en) Method for treating broken block when using flash memory in tax-controlled cashing machine
CN101526922B (en) Flash data access method and device thereof

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C56 Change in the name or address of the patentee

Owner name: FEITIAN CHENGXIN TECHNOLOGY CO., LTD.

Free format text: FORMER NAME:

CP03 Change of name, title or address

Address after: 100085 Beijing city Haidian District Xueqing Road No. 9 Ebizal building B block 17 layer

Patentee after: Feitian Technologies Co.,Ltd.

Address before: 100083, Haidian District, Xueyuan Road, Beijing No. 40 research, 7A building, 5 floor

Patentee before: FEITIAN TECHNOLOGIES Co.,Ltd.

CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20090826

CF01 Termination of patent right due to non-payment of annual fee