[go: nahoru, domu]

CN102063379B - Data storage method of FLASH memory - Google Patents

Data storage method of FLASH memory Download PDF

Info

Publication number
CN102063379B
CN102063379B CN201010609536.5A CN201010609536A CN102063379B CN 102063379 B CN102063379 B CN 102063379B CN 201010609536 A CN201010609536 A CN 201010609536A CN 102063379 B CN102063379 B CN 102063379B
Authority
CN
China
Prior art keywords
data
sector
write
dsb
block
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
CN201010609536.5A
Other languages
Chinese (zh)
Other versions
CN102063379A (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.)
Tianjin Yaan Technology Co Ltd
Original Assignee
Tianjin Yaan Technology 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 Tianjin Yaan Technology Co Ltd filed Critical Tianjin Yaan Technology Co Ltd
Priority to CN201010609536.5A priority Critical patent/CN102063379B/en
Publication of CN102063379A publication Critical patent/CN102063379A/en
Application granted granted Critical
Publication of CN102063379B publication Critical patent/CN102063379B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

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

Abstract

The invention relates to a data storage method of a FLASH memory, comprising the following steps: (1) allocating N sectors as storage sectors in a FLASH, equally dividing each sector into a plurality of data storage blocks, and writing a data empty identifier into an identification data storage block in each sector; (2) changing the data empty identifier of the identification data storage block of the sector required to be written with data into a data valid identifier, and writing data into other data storage blocks sequentially; (3) continuously writing data into the next sector after the sector is written; and (4) repeating the steps (2) and (3) until the sector N-1 is written. In the invention, data is written into multiple sectors sequentially, the data which is written at the last time, is continuously increased and has the same index number is valid when the data is modified, other data is valid, and the current sector into which the data is written is erased only when one empty sector is residual, thus greatly reducing the erasing frequency of the FLASH and prolonging the life of the FLASH.

Description

A kind of date storage method of FLASH memory
Technical field
The invention belongs to technical field of data storage, especially a kind of date storage method of FLASH memory.
Background technology
FLASH memory (programmable read only memory, hereinafter referred to as FLASH) be a kind of novel semi-conductor storer that Intel Company released in 1988, there is non-volatile storage characteristics, be called for short flash memory, such ROM (read-only memory) has that integrated level is high, reading speed is fast, single power supply, to programme the remarkable advantage such as often again, FLASH memory, as non-volatile data memory device, is widely used in embedded system.FLASH in single chip microcomputer can online programming, also can storage program run time data, but need first to wipe when revising the data in FLASH, the data both having revised a byte also first will wipe the total data of this sector, byte place, and then write data.Traditional wiring method adopts following process: 1. Backup Data all data in a sector; 2. in Backup Data, revise the data that will change; 3. all data of the FLASH actual sector at obliterated data place; 4. amended Backup Data is write back in the FLASH sector of just erasing.The deficiency that said method exists is: 1. often a byte of changing in sector all will wipe the data of whole sector, and 2. some data needs frequent amendment, and the sector at this data place can be frequently erased.It can thus be appreciated that traditional FLASH wiring method needs frequent obliterated data, but the erasing times of FLASH is limited, uses classic method to carry out serviceable life that the write of data and amendment can reduce FLASH greatly.
Summary of the invention
The object of the invention is to overcome the deficiencies in the prior art, provide a kind of scientific and reasonable, easy and simple to handle and effectively can reduce the erasable number of times of FLASH memory, improve the date storage method of the FLASH memory in FLASH memory serviceable life.
The technical scheme that the present invention takes is:
A date storage method for FLASH memory, is characterized in that: comprise the following steps:
(1) in FLASH, distribute N number of sector is memory sector, and each sector is divided into multiple DSB data store block, and the content in the identification data storage block in each sector is data for empty mark;
(2) will the data of the identification data storage block of the sector writing data be needed effectively to identify for empty mark becomes data, and order write data in other each DSB data store block;
(3), after writing a full sector, continue to next sector write data;
(4) repeating step (2) ~ (3), until write full N-1 sector, when writing data in last empty sector, adopting following steps:
1. the in the end identification data storage block of an empty sector interior write backup mark;
2. read the current valid data write the earliest in sector, and these data are write in last empty sector;
3. current writing all data in sector the earliest and write data for empty mark in identification data storage block is wiped;
4. effectively identify becoming data from backup mark in the identification data storage block storing last empty sector former of data and continue to write data in this sector;
5. when this sector write full after, repeat step 1. ~ 4., constantly update the data in each sector, the data realizing FLASH memory store.
And the N number of sector in described step (1) is continuous or discontinuous sector.
And described identification data storage block is the first DSB data store block in each sector or last DSB data store block.
And, the size of each DSB data store block in the sector in described step (1) is identical and other DSB data store block except identification data storage block is all divided into index area and data field, in the method for each DSB data store block write data be: data are write the data field of this DSB data store block by the index area call number of data being write this DSB data store block.
And, the method 2. reading the current valid data write in sector the earliest in step of described step (4) is: read all data in this sector, the call number of more each data, the data of same index number are effective with the data write for the last time, other abandons, and then the call number of data after screening is compared with the data in other sector, be effective with the data write for the last time, other abandons.
Advantage of the present invention and good effect are:
The present invention is sequentially written in data in multiple sector, just continue during Update Table to increase and the data automatically identifying the last write of same index number are effective, other is invalid, only just can clash the current sector writing data the earliest when residue empty sector, more sector is used, erasable fewer to FLASH when visual data stores.When frequent amendment a few data, only need to write data, certain sector erasable that need not repeat, greatly reduces the erasable number of times of FLASH, improves the life-span of FLASH.Wherein the size of DSB data store block and the number of sector can define according to the size of data and Modification Frequency, also FLASH can be divided into zones of different, each region adopts different block sizes and sector number to store data, and operating any instant of FLASH, the abnormal end caused due to situations such as power-off all can not obliterated data.
Embodiment
Below in conjunction with embodiment, the present invention is further described, and following embodiment is illustrative, is not determinate, can not limit protection scope of the present invention with following embodiment.
A date storage method for FLASH memory, comprises the following steps:
(1) in FLASH, distribute N number of sector is memory sector, and each sector is divided into multiple DSB data store block, and the content in the identification data storage block in each sector is data for empty mark;
N number of sector in step (1) can be continuous print, also can be discontinuous.When for discontinuous sector, can calculate according to the start address of sector and side-play amount, the location of each sector can be realized by the computerized algorithm of routine.
The size of each DSB data store block in the sector in step (1) is identical and other DSB data store block except identification data storage block is all divided into index area and data field, in the method for each DSB data store block write data be: the data field first data being write this DSB data store block, then the index area call number of data being write this DSB data store block.If powering down chips after write call number, data are no write also, does not more just know after powering on that whether real data are.The benefit then writing call number is: powering down chips during write data or when not writing index after write data, all positions of call number are " 1 " (default value when namely sector is wiped free of), represent the data invalid in this DSB data store block.
(2) will the data of the identification data storage block of the sector writing data be needed effectively to identify for empty mark becomes data, and order write data in other each DSB data store block;
(3), after writing a full sector, continue to next sector write data;
(4) repeating step (2) ~ (3), until write full N-1 sector, when writing data in last empty sector, adopting following steps:
1. the in the end identification data storage block of an empty sector interior write backup mark;
2. read the current valid data write the earliest in sector, and these data are write in last empty sector;
3. current writing all data in sector the earliest and write data for empty mark in identification data storage block is wiped;
4. effectively identify becoming data from backup mark in the identification data storage block storing last empty sector former of data and continue to write data in this sector;
5. when this sector write full after, repeat step 1. ~ 4., constantly update the data in each sector, the data realizing FLASH memory store.
The method 2. reading the current valid data write in sector the earliest in step of step (4) is: read all data in this sector, the call number of more each data, the data of same index number are effective with the data write for the last time, other abandons, and then the call number of data after screening is compared with the data in other sector, be effective with the data write for the last time, other abandons.
Identification data storage block in above steps is the first DSB data store block in each sector or last DSB data store block.
Application Example
During monopod video camera monitoring, want the cradle head preset positions that recording user is arranged, generally to store 128 preset point (1 to 128), during storage, each presetting bit is stored as one piece, preset item is as call number (two bytes), data field stores the data of presetting bit, be respectively horizontal level (two bytes), upright position (two bytes), camera zoom (two bytes), it can thus be appreciated that the size of DSB data store block in each sector is Eight characters joint, shared by byte shared by call number in all DSB data store block in all sectors and data, byte is all identical.Its structure is in table 1:
Call number (two bytes) Data (six bytes)
Table 1: the definition of the DSB data store block in each sector
In this application embodiment, data are stored in the in-chip FLASH of single-chip microcomputer, use the STM32 single-chip microcomputer of STMicw Electronics, the sector-size of in-chip FLASH is 1024 bytes, 128 points will take the storage space of 2k, but the space selected when realizing must be greater than 2k, the larger erasing times that more can reduce FLASH in space.Continuous print eight sector storage are selected, eight sector called after S0, S1, S2, S3, S4, S5, S6, S7 respectively during specific implementation.Identification data storage block in this application embodiment chooses the first DSB data store block, and the sectors status wherein write uses following data representation respectively: data are that sky is designated 0xffff, and data are effectively designated 0x0, and backup is designated 0xfefe.FLASH has different characteristics, if the word bit of correspondence is become " 0 " from " 1 " during some writes, first need not wipe, can write direct, and what have can change other number into from " FF " after erasing, then may change " 0 " into need not wipe.So realize the amendment of the first DSB data store block state in each sector, namely become " backup mark " from " data are empty mark ", or become " valid data mark " from " backup mark ", do not need to wipe this FLASH sector.
Storing data is all empty with the first eight sector, and in the first DSB data store block of each sector, all write invalid data mark, write effective Data Identification by the first DSB data store block of S0 sector after system initialization, and order writes data in each DSB data store block.
Data write, change and the process read:
Write call number 1, data 1;
Write call number 2, data 2;
Write call number 3, data 3;
Write call number 4, data 4;
The data of amendment call number 2: additional call number is 2, and data content is the data of 3;
Write call number 5, data 5;
Write call number 90, data 100;
Read call number 3 data, at this moment sense data is 3;
Read call number 2 data, at this moment sense data is 3;
The data of amendment call number 2: additional call number is 2, and data content is the data of 9;
Read call number 2 data, at this moment sense data is 9;
Storage organization after write is in table 2:
Storage organization in table 2:S0 sector
When S0 writes full data, write data in first DSB data store block of S1 and effectively identify, and write data in remaining DSB data store block.Repeat said process, until S6 writes full.When S6 writes a full space-time sector only surplus S7, then when writing data, adopt following steps:
1. in the first DSB data store block write backup mark of S7.
2. read the current valid data write the earliest in the S0 of sector, and these data are write in last empty sector, concrete grammar is: read all data in S0, the call number of more each data, the data of same index number are effective with the data write for the last time, other abandons, and then the call number of data after screening is compared with the data in other sector (S1 ~ S6), be effective with the data write for the last time, other abandons, in valid data write S7 after final screening, the data structure in S0 and S7 is in table 3 and table 4.
3. all data in the sector of write the earliest (S0) that erasing is current also write data for empty mark in the first DSB data store block;
4. effectively identify becoming data from backup mark in the first DSB data store block storing last empty sector (S7) former of data and continue to write data in this sector;
5., when S7 writes completely, the now current sector of write is the earliest S1, is backed up in S0 by the valid data in S1, then continues to write full S0, then the like, the data achieving FLASH memory store.
S7
The data stored in table 3:S7
S0
The data stored in table 4:S0
The sector number storing data in the present invention can be defined by the user, can find out the more erasing times that more can reduce sector in the sector of definition.Also the life-span of FLASH can not be reduced because of the record of a certain index of frequent amendment, because the life-span is only relevant with total erasable number of times.The size of block and the number of block can be defined by the user, the number of definition block size and block can be carried out according to the frequency of size of data and amendment, also FLASH can be divided into zones of different, each district uses the present invention to adopt different block sizes and block number to store data.In any instant of operation FLASH, the abnormal end caused due to situations such as power-off all can not obliterated data.

Claims (1)

1. a date storage method for FLASH memory, is characterized in that: comprise the following steps:
(1) in FLASH, distribute N number of sector is memory sector, and each sector is divided into multiple DSB data store block, and the content in the identification data storage block in each sector is data for empty mark;
(2) will the data of the identification data storage block of the sector writing data be needed effectively to identify for empty mark becomes data, and order write data in other each DSB data store block;
(3), after writing a full sector, continue to next sector write data;
(4) repeat step (2) ~ (3), until write full N-1 sector, when writing data in last empty sector, employing following steps:
1. the in the end identification data storage block of an empty sector interior write backup mark;
2. read the current valid data write the earliest in sector, and these data are write in last empty sector;
3. current writing all data in sector the earliest and write data for empty mark in identification data storage block is wiped;
4. effectively identify becoming data from backup mark in the identification data storage block storing last empty sector former of data and continue to write data in this sector;
5. when this sector write full after, repeat step 1. ~ 4., constantly update the data in each sector, the data realizing FLASH memory store;
Described step (1) in N number of sector be continuous or discontinuous sector;
Described identification data storage block is the first DSB data store block in each sector or last DSB data store block;
Described step (1) in sector in the size of each DSB data store block identical and other DSB data store block except identification data storage block is all divided into index area and data field, in the method for each DSB data store block write data be: the data field first data being write this DSB data store block, then the index area call number of data being write this DSB data store block;
Described step the method 2. reading the current valid data write in sector the earliest in step is (4): read all data in this sector, the call number of more each data, the data of same index number are effective with the data write for the last time, other abandons, and then the call number of data after screening is compared with the data in other sector, be effective with the data write for the last time, other abandons.
CN201010609536.5A 2010-12-28 2010-12-28 Data storage method of FLASH memory Active CN102063379B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201010609536.5A CN102063379B (en) 2010-12-28 2010-12-28 Data storage method of FLASH memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201010609536.5A CN102063379B (en) 2010-12-28 2010-12-28 Data storage method of FLASH memory

Publications (2)

Publication Number Publication Date
CN102063379A CN102063379A (en) 2011-05-18
CN102063379B true CN102063379B (en) 2015-01-07

Family

ID=43998664

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201010609536.5A Active CN102063379B (en) 2010-12-28 2010-12-28 Data storage method of FLASH memory

Country Status (1)

Country Link
CN (1) CN102063379B (en)

Families Citing this family (27)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102572330A (en) * 2010-12-29 2012-07-11 厦门华侨电子股份有限公司 Method for reading, writing and erasing data of liquid crystal television Flash chip
CN102306125B (en) * 2011-08-17 2016-04-06 深圳市共进电子股份有限公司 A kind of data erasing-writing method of FLASH memory
CN102508784B (en) * 2011-11-02 2015-01-07 杭州海康威视数字技术股份有限公司 Data storage method of flash memory card in video monitoring equipment, and system thereof
CN102662833B (en) * 2012-03-21 2014-12-03 天津书生软件技术有限公司 Method for managing test cases
CN102968383B (en) * 2012-12-13 2015-08-19 蚌埠依爱消防电子有限责任公司 A kind of method in raising FLASH serviceable life for fire alarm system
CN104699727B (en) * 2014-01-15 2017-12-22 杭州海康威视数字技术股份有限公司 A kind of date storage method and device
CN103778067A (en) * 2014-02-11 2014-05-07 珠海市金邦达保密卡有限公司 Object processing method and device of Java card and Java card
CN104978148A (en) * 2014-04-09 2015-10-14 瑞萨电子(中国)有限公司 Data writing method and device and data reading method and device
CN104462280A (en) * 2014-11-27 2015-03-25 国网上海市电力公司 Data information storage and fast inquiry method used for embedded system
CN104715102B (en) * 2014-12-30 2018-05-08 华立科技股份有限公司 The design method of intelligent electric energy meter load curve based on dichotomy
CN105159601B (en) * 2015-08-07 2018-12-07 杭州海兴电力科技股份有限公司 A method of improving Flash erasing and writing life
CN108629927A (en) * 2017-03-23 2018-10-09 惠尔丰(中国)信息系统有限公司 A kind of optimization method of the memory of low dump machine
CN107608630B (en) * 2017-09-07 2020-09-04 四川九洲北斗导航与位置服务有限公司 Data reading and writing method and device
CN108255436A (en) * 2018-01-25 2018-07-06 广东美的制冷设备有限公司 Data access method, access device, home appliance and readable storage medium storing program for executing
CN109002399B (en) * 2018-07-09 2021-05-18 北京智芯微电子科技有限公司 Method for recording embedded equipment event
CN109240622B (en) * 2018-09-26 2021-10-08 潍柴动力股份有限公司 Method and system for writing EEPROM data
CN109634581B (en) * 2018-11-08 2022-01-04 中国航空工业集团公司洛阳电光设备研究所 Data storage method based on STM32F103ZET6 and eMMC card
CN109947364A (en) * 2019-02-01 2019-06-28 浙江蓝点动力科技有限公司 A kind of method for storing real-time data in FLASH/EEPROM
CN110007856B (en) * 2019-03-05 2020-08-04 四川九洲电器集团有限责任公司 Data storage method and device and flash memory chip
CN112463020A (en) * 2019-09-09 2021-03-09 杭州海康威视数字技术股份有限公司 Data access method, device and equipment based on Flash
CN110825587A (en) * 2019-11-01 2020-02-21 浙江互灵科技有限公司 Simple log system based on MCU and log management method
CN112286893B (en) * 2020-09-23 2023-02-24 宁波水表(集团)股份有限公司 Log processing method and device applied to embedded terminal
CN112732522A (en) * 2020-12-31 2021-04-30 东风汽车集团有限公司 Configurable log storage and analysis method and system for vehicle-mounted MCU
CN112817527B (en) * 2021-01-21 2024-06-04 深圳市显控科技股份有限公司 Power-down data storage method, singlechip and computer-readable storage medium
CN113220239A (en) * 2021-05-24 2021-08-06 厦门四信通信科技有限公司 Erasing and writing method, device and equipment for flash storage and readable storage medium
CN113721847A (en) * 2021-08-18 2021-11-30 深圳市京泉华智能电气有限公司 Sector-based data writing method and related equipment
CN115291813B (en) * 2022-10-08 2023-04-07 苏州浪潮智能科技有限公司 Data storage method and device, data reading method and device, and equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5740396A (en) * 1995-02-16 1998-04-14 Mitsubishi Denki Kabushiki Kaisha Solid state disk device having a flash memory accessed by utilizing an address conversion table to convert sector address information to a physical block number
CN1272716C (en) * 2002-12-04 2006-08-30 联发科技股份有限公司 Data management method and configuration manner for memory
CN101546294A (en) * 2009-04-30 2009-09-30 青岛海信宽带多媒体技术有限公司 Method for storing data in Flash memory
CN101556556A (en) * 2009-05-22 2009-10-14 炬力集成电路设计有限公司 Data storage method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7167944B1 (en) * 2000-07-21 2007-01-23 Lexar Media, Inc. Block management for mass storage

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5740396A (en) * 1995-02-16 1998-04-14 Mitsubishi Denki Kabushiki Kaisha Solid state disk device having a flash memory accessed by utilizing an address conversion table to convert sector address information to a physical block number
CN1272716C (en) * 2002-12-04 2006-08-30 联发科技股份有限公司 Data management method and configuration manner for memory
CN101546294A (en) * 2009-04-30 2009-09-30 青岛海信宽带多媒体技术有限公司 Method for storing data in Flash memory
CN101556556A (en) * 2009-05-22 2009-10-14 炬力集成电路设计有限公司 Data storage method and device

Also Published As

Publication number Publication date
CN102063379A (en) 2011-05-18

Similar Documents

Publication Publication Date Title
CN102063379B (en) Data storage method of FLASH memory
US8037232B2 (en) Data protection method for power failure and controller using the same
US8583860B2 (en) Block management method for flash memory and controller and storage system using the same
US8046526B2 (en) Wear leveling method and controller using the same
US20180260317A1 (en) Method for managing the copying and storing of data in garbage collection, memory storage device and memory control circuit unit using the same
US8001317B2 (en) Data writing method for non-volatile memory and controller using the same
CN101937319B (en) Memory systems and mapping methods thereof
US8055873B2 (en) Data writing method for flash memory, and controller and system using the same
KR101497860B1 (en) Memory address translation
US9141476B2 (en) Method of storing system data, and memory controller and memory storage apparatus using the same
US10162554B2 (en) System and method for controlling a programmable deduplication ratio for a memory system
US20100095046A1 (en) Method and apparatus for improving small write performance in a non-volatile memory
US9075707B2 (en) Data writing method and data storage device
JP4666081B2 (en) MEMORY CONTROLLER, FLASH MEMORY SYSTEM HAVING MEMORY CONTROLLER, AND FLASH MEMORY CONTROL METHOD
US9009442B2 (en) Data writing method, memory controller and memory storage apparatus
JP2010182266A (en) Memory controller, flash memory system equipped with the same, and control method of flash memory
CN101499315A (en) Average abrasion method of flash memory and its controller
TWI450271B (en) Method for managing a plurality of blocks of a flash memory, and associated memory device and controller thereof
US20100306456A1 (en) Method for even utilization of a plurality of flash memory chips
TWI463311B (en) Data storing method and apparatus applied to flash memory storage device
US8724401B2 (en) Data stripes and addressing for flash memory devices
US8417909B2 (en) Block management and data writing method, and flash memory storage system and controller using the same
TWI386800B (en) Methods for handling data updating of a flash memory and the related memory cards
JP2007179479A (en) Memory controller and flash memory system
TW201310237A (en) Flash memory storage device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C53 Correction of patent of invention or patent application
CB02 Change of applicant information

Address after: 300384 Tianjin City Huayuan Industrial Zone Ziyuan Road No. 8

Applicant after: TIANJIN YAAN TECHNOLOGY Co.,Ltd.

Address before: Zi Yuan Road 300384 Tianjin city Nankai District Huayuan Industrial Park No. 8

Applicant before: Tianjin Yaan Technology Electronic Co.,Ltd.

COR Change of bibliographic data

Free format text: CORRECT: APPLICANT; FROM: YAAN SCIENCE + TECHNOLOGY ELECTRONIC CO., LTD., TIANJIN TO: TIANJIN YA'AN TECHNOLOGY CO., LTD.

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
CP03 Change of name, title or address

Address after: 300384 in Tianjin Binhai Huayuan Industrial Zone (outer ring) eight Haitai Huake Road No. 6

Patentee after: TIANJIN YAAN TECHNOLOGY Co.,Ltd.

Address before: 300384 Tianjin City Huayuan Industrial Zone Ziyuan Road No. 8

Patentee before: TIANJIN YAAN TECHNOLOGY Co.,Ltd.

PP01 Preservation of patent right
PP01 Preservation of patent right

Effective date of registration: 20190701

Granted publication date: 20150107

PD01 Discharge of preservation of patent
PD01 Discharge of preservation of patent

Date of cancellation: 20220701

Granted publication date: 20150107

PP01 Preservation of patent right
PP01 Preservation of patent right

Effective date of registration: 20220701

Granted publication date: 20150107