CN108228095B - Method for recording real-time information based on Flash - Google Patents
Method for recording real-time information based on Flash Download PDFInfo
- Publication number
- CN108228095B CN108228095B CN201711360567.XA CN201711360567A CN108228095B CN 108228095 B CN108228095 B CN 108228095B CN 201711360567 A CN201711360567 A CN 201711360567A CN 108228095 B CN108228095 B CN 108228095B
- Authority
- CN
- China
- Prior art keywords
- item
- address
- current
- real
- data
- 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
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/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0604—Improving or facilitating administration, e.g. storage management
-
- 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/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0608—Saving storage space on storage systems
-
- 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
-
- 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)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Techniques For Improving Reliability Of Storages (AREA)
Abstract
The invention belongs to the embedded computer application technology, and particularly relates to a real-time information recording method based on Flash. The information record takes data items as a unit, and the data items are divided into four types of null record items, startup information items, real-time information items and invalid items. Two sectors with adjacent addresses are selected in the FLASH space to form an information recording area, and the recording mode of switching the two sectors is adopted, so that the latest recording information is always stored in the information recording area and cannot be completely erased. A buffer area is set at the tail end of each sector, and the initialization retrieval algorithm is matched, so that the phenomenon that the execution of a program is interfered due to erasing operation in the running process is avoided, and sufficient space for recording real-time information is ensured in one-time power-on running. The invention has strong real-time performance and good universality, can save the cost of purchasing the external EEPROM and has certain positive effect on the miniaturization of the embedded system. The method is applied to a control unit of an electric control excavator and a loader, the operation is stable and reliable, and good effects are achieved.
Description
Technical Field
The invention belongs to the embedded computer application technology, and particularly relates to a real-time information recording method based on Flash.
Background
During the operation of the embedded systems such as navigation, flight control, servo, etc., it is often necessary to record some information, such as start-up information, parameters, fault information, etc., in real time in the nonvolatile memory. Electrically Erasable Programmable Read Only Memory (EEPROM) is well suited to storing such information due to its flexibility of use, and is widely used in various embedded systems.
Due to unprecedented high-efficiency integration performance, a System On a Chip (soc) has become a necessary trend in the development of current microelectronic chips, and is increasingly applied to embedded systems such as automotive electronics and servo control. Many systems on chip do not have an integrated on-chip EEPROM, but instead have an integrated on-chip Flash for storing non-volatile programs and data. The method realizes real-time information recording based on an on-chip Flash memory, can save the cost of purchasing an external EEPROM, and plays a positive role in the miniaturization of an embedded system.
Because the hardware realization mechanism of Flash and EEPROM is different, the operation mode is also different. EEPROM can be programmed in units of bits without the need for an erase operation. The bit of FLASH can only change from 1 to 0, cannot override the programming, must be erased before programming, and can only be erased by sector. Frequent erasing can shorten the service life of Flash and increase the data writing time. Due to the differences of the operation modes, different methods are needed to realize real-time information recording in Flash.
Disclosure of Invention
The purpose of the invention is: the method for recording real-time information based on FLASH is provided for an embedded system which is not integrated with EEPROM and is integrated with FLASH.
The technical scheme adopted by the invention is as follows:
a method for real-time information recording based on Flash comprises the following steps:
1. a method for real-time information recording based on Flash is characterized by comprising the following steps:
step 1: defining the data structure and type of the data item, wherein the data item consists of a data item mark, data item content and a data item check part, and dividing the data item into four types according to the data item mark: the system comprises a null record item, a start information item, a real-time information item and an invalid item, wherein the four types of data items have the same length;
step 2: selecting FLASH sectors and dividing the space, selecting two sectors with adjacent addresses in the FLASH space to form a data recording area, and setting the fixed-length space at the tail end of each sector as a buffer area;
and step 3: initializing and searching the data recording area, searching the whole data recording area when the system is electrified and initialized to obtain the current writable address and the latest starting information item address;
and 4, step 4: writing the start information item, and performing the write-in operation of the start information item once after the initial retrieval of the data recording area;
and 5: writing in the real-time information item, wherein the writing operation of the real-time information item is carried out in the running process of the system;
step 6: and reading the data item, namely reading the data item from the specified address at any time after the system is powered on.
2. The method for real-time information recording based on Flash according to claim 1, wherein the step 3 specifically comprises the following steps:
step 3.1, initializing the current writable address and the latest starting information item address as the starting address of the first sector, and initializing the current retrieval item address as the starting address of the first sector;
step 3.2, inquiring the data item mark of the current retrieval item, judging whether the current retrieval item is an empty record item, if so, executing step 3.3, and if not, executing step 3.4;
3.3, judging whether the current search item is in the buffer area, if so, erasing another sector, writing the residual space of the sector into an invalid item, setting the initial address of the other sector as the current writable address, and if not, executing the step 3.5;
step 3.4, judging whether the current item is a starting information item, if so, setting the current retrieval address as the latest starting information item address, updating the current retrieval address as the next data item address, returning to the step 3.2 for execution, and if not, updating the current retrieval address as the next data item address, returning to the step 3.2 for execution;
step 3.5, judging whether the next item of the current search item is an empty record item, if so, setting the address of the current search item as the current writable address, if not, setting a fault mark of a recording area, erasing the sector, and setting the initial address of the sector as the current writable address;
and 3.6 if no empty record item is retrieved in the whole record area, setting a record area fault mark, erasing the first sector and setting the initial address of the first sector as the current writable address.
3. The method for real-time information recording based on Flash according to claim 1, wherein the step 4 specifically comprises the following steps:
step 4.1, acquiring a starting information item recorded during the last system power-on initialization from the address of the latest starting information item;
and 4.2, processing the starting information item recorded during the last system power-on initialization, generating the starting information item of the system power-on initialization, writing the starting information item into the current writable address, and updating the current writable address to be the address of the next data item.
4. The method for real-time information recording based on Flash according to claim 1, wherein the step 5 specifically comprises the following steps:
judging whether the current writable address is the last data item address of the sector, if so, directly returning the real-time information item without writing; if not, writing the real-time information item into the current writable address, and updating the current writable address to be the next data item address.
5. The method for real-time information recording based on Flash according to claim 1, wherein the step 6 specifically comprises the following steps:
step 6.1, judging whether the data item is an empty record item or an invalid information item according to the data item mark, if so, returning the empty item or the invalid item mark, and if not, executing step 6.2;
and 6.2, checking the data item, returning the content of the current data item and the reading success mark when the checking is successful, and returning the checking failure mark when the checking is failed.
The invention has the advantages and beneficial effects that:
the recording mode of switching two sectors is adopted, so that the latest recorded information can be always stored in the information recording area under normal conditions and can not be completely erased; the length of the buffer area represents the maximum number of data items which can be recorded in each system operation, the setting of the buffer area is matched with the recording area initialization retrieval method, possible erasing operation can be carried out in advance to the time of power-on initialization, the phenomenon that normal execution of a program is interfered due to the erasing operation in the operation process can be avoided, and enough space for recording real-time information in one system operation can be ensured.
The invention has strong real-time performance and good universality, can save the cost of purchasing the external EEPROM and has certain positive effect on the miniaturization of the embedded system. The method is applied to a control unit of an electric control excavator and a loader, the operation is stable and reliable, and good effects are achieved.
Drawings
FIG. 1 is a schematic diagram of a recording space of a real-time information recording method based on FLASH;
FIG. 2 is a flowchart of an initialization search of a data recording area;
FIG. 3 is a flow chart of real-time information item writing;
FIG. 4 is a flow chart of data item reading.
Detailed Description
With reference to fig. 1, 2, 3, and 4, a development board based on an MPC5644 processor is selected as an embodiment, 2M Bytes Flash is integrated in the MPC5644, and two adjacent sectors with proper addresses and lengths are selected for real-time information recording. The method comprises the following specific implementation steps:
step 1): the data structure and type of the data item is defined. The data item is composed of three parts of a data item mark (first byte), data item content and data item check (tail byte). Data items are classified into four types according to data item flags: a null entry (0xFF), a startup information entry (0x55), a real-time information entry (0xAA), and an invalid entry (0x 00). The four types of data items are the same in length and are integer multiples of 4.
Step 2): and selecting FLASH sectors and dividing the space. Two adjacent sectors, namely a sector L8 and a sector L9, are selected from the FLASH space to form a data recording area. Each sector is 64K Bytes in size, the last 8K Bytes of each sector is set as a buffer, and the space diagram in FLASH is shown in fig. 1.
Step 3): and initializing and searching the data recording area. The entire data recording area is retrieved at power-on initialization of the system to obtain the current writable address CUR _ ADDR and the latest start information item address ST _ INFO _ ADDR. The search flow is as shown in fig. 2 and includes the following 6 steps.
Step 3.1) initializes both CUR _ ADDR and ST _ INFO _ ADDR to the start address of the first sector, and initializes the current search entry address to the first sector start address.
And 3.2) inquiring the data item mark of the current retrieval item, and judging whether the current retrieval item is an empty record item. If so, step 3.3) is performed. If not, execute 3.4).
And 3.3) judging whether the current retrieval item is in the buffer area, if so, erasing another sector, writing the residual space of the sector into an invalid item, and setting the initial address of the other sector as CUR _ ADDR. If not, step 3.5 is performed.
Step 3.4) judging whether the current item is a starting information item, if so, setting the current retrieval address as ST _ INFO _ ADDR, updating the current retrieval address to be the next data item address, and returning to the step 3.2 for execution. If not, the current retrieval address is updated to the address of the next data item, and the process returns to the step 3.2 for execution.
And 3.5) judging whether the next item of the current retrieval item is an empty record item. If yes, setting the address of the current search item to CUR _ ADDR. If not, the fault mark of the recording area is set, the local sector is erased, and the initial address of the local sector is set as CUR _ ADDR.
And 3.6) if no empty record item is retrieved in the whole record area, setting a record area fault mark, erasing the first sector and setting the initial address of the first sector as CUR _ ADDR.
Step 4): the writing of the information item is initiated. After the initial search of the data recording area, a write operation of the startup information item is performed. And acquiring the starting information item recorded during the last system power-on initialization from the ST _ INFO _ ADDR, generating the starting information item of the system power-on initialization after processing, writing the starting information item into the address of the CUR _ ADDR, and updating the CUR _ ADDR to be the address of the next data item.
Step 5): writing of real-time information items. And writing the real-time information item according to the requirement in the running process of the system. The real-time information item writing operation flow is as shown in fig. 3, before writing, it is determined whether or not the CUR _ ADDR is the last data item address of the local sector, and if so, the real-time information item is not written any more, and the real-time information item is directly returned. If not, writing a real-time information item into the CUR _ ADDR, and updating the CUR _ ADDR to be the address of the next data item.
Step 6): reading of the data item. At any time after the system is powered on, the data item is READ from the specific address READ _ ADDR as required, the data item reading flow is as shown in fig. 4, firstly, whether the data item is an empty record item or an invalid information item is judged according to the data item mark, and if so, the empty item or the invalid item mark is returned. If not, the data item is verified, the content of the data item and the reading success mark are returned when the verification is successful, and the verification failure mark is returned when the verification is failed.
Claims (4)
1. A method for real-time information recording based on Flash is characterized by comprising the following steps:
step 1: defining the data structure and type of the data item, wherein the data item consists of a data item mark, data item content and a data item check part, and dividing the data item into four types according to the data item mark: the system comprises a null record item, a start information item, a real-time information item and an invalid item, wherein the four types of data items have the same length;
step 2: selecting FLASH sectors and dividing the space, selecting two sectors with adjacent addresses in the FLASH space to form a data recording area, and setting the fixed-length space at the tail end of each sector as a buffer area;
and step 3: initializing and searching the data recording area, searching the whole data recording area when the system is electrified and initialized to obtain the current writable address and the latest starting information item address;
step 3.1, initializing the current writable address and the latest starting information item address as the starting address of the first sector, and initializing the current retrieval item address as the starting address of the first sector;
step 3.2, inquiring the data item mark of the current retrieval item, judging whether the current retrieval item is an empty record item, if so, executing step 3.3, and if not, executing step 3.4;
3.3, judging whether the current search item is in the buffer area, if so, erasing another sector, writing the residual space of the sector into an invalid item, setting the initial address of the other sector as the current writable address, and if not, executing the step 3.5;
step 3.4, judging whether the current item is a starting information item, if so, setting the current retrieval address as the latest starting information item address, updating the current retrieval address as the next data item address, returning to the step 3.2 for execution, and if not, updating the current retrieval address as the next data item address, returning to the step 3.2 for execution;
step 3.5, judging whether the next item of the current search item is an empty record item, if so, setting the address of the current search item as the current writable address, if not, setting a fault mark of a recording area, erasing the sector, and setting the initial address of the sector as the current writable address;
step 3.6 if no empty record item is retrieved in the whole recording area, setting a recording area fault mark, erasing the first sector, and setting the initial address of the first sector as the current writable address;
and 4, step 4: writing the start information item, and performing the write-in operation of the start information item once after the initial retrieval of the data recording area;
and 5: writing in the real-time information item, wherein the writing operation of the real-time information item is carried out in the running process of the system; step 6: and reading the data item, namely reading the data item from the specified address at any time after the system is powered on.
2. The method for real-time information recording based on Flash according to claim 1, wherein the step 4 specifically comprises the following steps:
step 4.1, acquiring a starting information item recorded during the last system power-on initialization from the address of the latest starting information item;
and 4.2, processing the starting information item recorded during the last system power-on initialization, generating the starting information item of the system power-on initialization, writing the starting information item into the current writable address, and updating the current writable address to be the address of the next data item.
3. The method for real-time information recording based on Flash according to claim 1, wherein the step 5 specifically comprises the following steps:
judging whether the current writable address is the last data item address of the sector, if so, directly returning the real-time information item without writing; if not, writing the real-time information item into the current writable address, and updating the current writable address to be the next data item address.
4. The method for real-time information recording based on Flash according to claim 1, wherein the step 6 specifically comprises the following steps:
step 6.1, judging whether the data item is an empty record item or an invalid information item according to the data item mark, if so, returning the empty item or the invalid item mark, and if not, executing step 6.2;
and 6.2, checking the data item, returning the content of the current data item and the reading success mark when the checking is successful, and returning the checking failure mark when the checking is failed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711360567.XA CN108228095B (en) | 2017-12-15 | 2017-12-15 | Method for recording real-time information based on Flash |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711360567.XA CN108228095B (en) | 2017-12-15 | 2017-12-15 | Method for recording real-time information based on Flash |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108228095A CN108228095A (en) | 2018-06-29 |
CN108228095B true CN108228095B (en) | 2021-02-09 |
Family
ID=62652354
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711360567.XA Active CN108228095B (en) | 2017-12-15 | 2017-12-15 | Method for recording real-time information based on Flash |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108228095B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114356792B (en) * | 2021-11-18 | 2023-03-10 | 国电南瑞三能电力仪表(南京)有限公司 | Electric energy meter frozen data storage method based on FLASH pre-erasing technology and electric energy meter |
CN114489478A (en) * | 2021-12-20 | 2022-05-13 | 山西转型综改示范区华纳方盛科技有限公司 | Data storage method of data recorder, data storage module and data recorder |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1821978A (en) * | 2006-01-16 | 2006-08-23 | 深圳创维-Rgb电子有限公司 | Method for operating data in non-volatile storage in embedded system |
CN102508784A (en) * | 2011-11-02 | 2012-06-20 | 杭州海康威视数字技术股份有限公司 | Data storage method of flash memory card in video monitoring equipment, and system thereof |
CN105068116A (en) * | 2015-08-20 | 2015-11-18 | 中国石油集团川庆钻探工程有限公司地球物理勘探公司 | Three-dimensional seismic interpretation data storage method |
CN105138655A (en) * | 2015-08-31 | 2015-12-09 | 深圳市茁壮网络股份有限公司 | Data storage and reading method and device |
CN105183392A (en) * | 2015-09-18 | 2015-12-23 | 广州日滨科技发展有限公司 | Method for storing fixed-length data on FLASH |
CN105426317A (en) * | 2015-10-29 | 2016-03-23 | 宁波卓奥电子科技有限公司 | Storage method for storing user data into Flash and read method |
CN106502839A (en) * | 2016-10-27 | 2017-03-15 | 武汉奥泽电子有限公司 | A kind of storage method and system based on automobile BCMFlash |
CN106776106A (en) * | 2016-11-11 | 2017-05-31 | 南京南瑞集团公司 | A kind of date storage method based on NandFlash |
-
2017
- 2017-12-15 CN CN201711360567.XA patent/CN108228095B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1821978A (en) * | 2006-01-16 | 2006-08-23 | 深圳创维-Rgb电子有限公司 | Method for operating data in non-volatile storage in embedded system |
CN102508784A (en) * | 2011-11-02 | 2012-06-20 | 杭州海康威视数字技术股份有限公司 | Data storage method of flash memory card in video monitoring equipment, and system thereof |
CN105068116A (en) * | 2015-08-20 | 2015-11-18 | 中国石油集团川庆钻探工程有限公司地球物理勘探公司 | Three-dimensional seismic interpretation data storage method |
CN105138655A (en) * | 2015-08-31 | 2015-12-09 | 深圳市茁壮网络股份有限公司 | Data storage and reading method and device |
CN105183392A (en) * | 2015-09-18 | 2015-12-23 | 广州日滨科技发展有限公司 | Method for storing fixed-length data on FLASH |
CN105426317A (en) * | 2015-10-29 | 2016-03-23 | 宁波卓奥电子科技有限公司 | Storage method for storing user data into Flash and read method |
CN106502839A (en) * | 2016-10-27 | 2017-03-15 | 武汉奥泽电子有限公司 | A kind of storage method and system based on automobile BCMFlash |
CN106776106A (en) * | 2016-11-11 | 2017-05-31 | 南京南瑞集团公司 | A kind of date storage method based on NandFlash |
Also Published As
Publication number | Publication date |
---|---|
CN108228095A (en) | 2018-06-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8041879B2 (en) | Flash memory backup system and method | |
US7480760B2 (en) | Rotational use of memory to minimize write cycles | |
KR100906519B1 (en) | Unusable block management within a non-volatile memory system | |
JP4129381B2 (en) | Nonvolatile semiconductor memory device | |
JP5421127B2 (en) | Nonvolatile memory with dynamic multimode operation | |
US7761652B2 (en) | Mapping information managing apparatus and method for non-volatile memory supporting different cell types | |
US8205070B2 (en) | Device bootup from a NAND-type non-volatile memory | |
US7818492B2 (en) | Source and shadow wear-leveling method and apparatus | |
US20050057973A1 (en) | Runtime flash device detection and configuration for flash data management software | |
US7725646B2 (en) | Method of using a flash memory for a circular buffer | |
US9563553B2 (en) | Data storing method and embedded system | |
US20150006939A1 (en) | Management method for nonvolatile memory system following power-off | |
KR100370893B1 (en) | Flash memory unit and control method of flash memory | |
KR20140133427A (en) | Method for managing data stored in flash memory and associated memory device and controller | |
CN113885808B (en) | Mapping information recording method, memory control circuit unit and memory device | |
US9870826B2 (en) | Memory apparatus and data access method thereof by using multiple memories for lifetime extension | |
CN108228095B (en) | Method for recording real-time information based on Flash | |
US8046529B2 (en) | Updating control information in non-volatile memory to control selection of content | |
JP4794530B2 (en) | Semiconductor device and mobile phone | |
CN109426443B (en) | Memory control apparatus and method | |
JP2008251154A (en) | Nonvolatile semiconductor memory device | |
KR100692982B1 (en) | NAND type flash memory for recording bad block information | |
JP2006323499A (en) | Semiconductor device | |
US20060282626A1 (en) | Memory device and method of controlling operation of the memory device | |
JP2009276883A (en) | Semiconductor auxiliary storage device |
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 |