[go: up one dir, main page]

CN110688084B - First-in first-out FLASH data storage method, system and terminal - Google Patents

First-in first-out FLASH data storage method, system and terminal Download PDF

Info

Publication number
CN110688084B
CN110688084B CN201910975277.9A CN201910975277A CN110688084B CN 110688084 B CN110688084 B CN 110688084B CN 201910975277 A CN201910975277 A CN 201910975277A CN 110688084 B CN110688084 B CN 110688084B
Authority
CN
China
Prior art keywords
data
writing
searching
reading
valid
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
CN201910975277.9A
Other languages
Chinese (zh)
Other versions
CN110688084A (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.)
SHENZHEN LANDU AUTOMOBILE ELECTRIC CONTROL TECHNOLOGY CO LTD
Original Assignee
SHENZHEN LANDU AUTOMOBILE ELECTRIC CONTROL 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 SHENZHEN LANDU AUTOMOBILE ELECTRIC CONTROL TECHNOLOGY CO LTD filed Critical SHENZHEN LANDU AUTOMOBILE ELECTRIC CONTROL TECHNOLOGY CO LTD
Priority to CN201910975277.9A priority Critical patent/CN110688084B/en
Publication of CN110688084A publication Critical patent/CN110688084A/en
Application granted granted Critical
Publication of CN110688084B publication Critical patent/CN110688084B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F5/00Methods or arrangements for data conversion without changing the order or content of the data handled
    • G06F5/06Methods or arrangements for data conversion without changing the order or content of the data handled for changing the speed of data flow, i.e. speed regularising or timing, e.g. delay lines, FIFO buffers; over- or underrun control therefor
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • 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)
  • Read Only Memory (AREA)

Abstract

The invention relates to the technical field of automobile electronics and Internet of vehicles, in particular to a first-in first-out FLASH data storage method, a first-out FLASH data storage system and a terminal, wherein the first-in first-out FLASH data storage method comprises the following steps: defining a variable-length data block; searching a blank area, writing a data block into the forefront end of the blank area, and marking the data block as valid; after the writing is completed, the read-back check is performed to determine whether the writing is successful; if not, rewriting the whole data area to 0; if successful, the re-input data is written into the next blank area in the following way. The first-in first-out FLASH data storage method, the first-out FLASH data storage system and the terminal can enable all blocks of the FLASH memory to be used uniformly, so that partial blocks are premature in failure.

Description

First-in first-out FLASH data storage method, system and terminal
Technical Field
The invention relates to the technical field of automobile electronics and Internet of vehicles, in particular to a first-in first-out FLASH data storage method, a system and a terminal.
Background
In the automotive electronics and networking fields, TBOX box devices report generated data to a remote server in real time. However, when the wireless network is not smooth, the data generated during the period needs to be temporarily stored on a FLASH memory chip on the device in a cyclic coverage manner. FLASH has a limited number of erasures, which requires a reasonable strategy to use FLASH, otherwise, the FLASH may cause a whole page fault due to premature failure of part of the page.
In the prior art, strategies for FLASH management comprise file systems such as FAT and the like; they fail to make the FLASH memory blocks uniformly usable, resulting in partial blocks premature senility; in addition, the content of the management part occupies too much space and occupies too much space for data storage.
In order to solve the problems, the invention provides a first-in first-out FLASH data storage method, a system and a terminal.
Disclosure of Invention
The invention solves the technical problem of providing a first-in first-out FLASH data storage method, a system and a terminal. The first-in first-out FLASH data storage method, the first-out FLASH data storage system and the terminal can enable all blocks of the FLASH memory to be used uniformly, so that partial blocks are premature in failure.
In order to solve the technical problems, the technical scheme provided by the invention is as follows:
a first-in first-out FLASH data storage method includes:
defining a variable-length data block;
searching a blank area, writing a data block into the forefront end of the blank area, and marking the data block as valid;
after the writing is completed, the read-back check is performed to determine whether the writing is successful;
if not, rewriting the whole data area to 0;
if successful, the re-input data is written into the next blank area in the following way.
Preferably, the composition of the data block is: the beginning of a specified content, the middle contains the total length of the data block, the valid flag of the data block, the data content, and the data check code ends. Defining a data block has the advantage that insertion of data is facilitated, and by searching the data block, the search process is facilitated.
Preferably, the data storage method further includes a data reading process, and the data reading process includes:
searching the data block which is written first and marked as valid;
marking it as invalid and checking whether the modification is successful;
if the change is not successful, rewriting the whole data area to 0;
if the marking is successful, continuing to read the following valid data.
Further preferably, the writing and reading of the data both include a searching process, and the searching process specifically includes determining the current condition of the FLASH memory:
reading a part of data of the head of the FLASH memory, and recording as Dh; the end of the memory reads a part of data forward, which is marked as Dt; and judging the service conditions of Dh and Dt. Wherein the length of the part of data is the maximum effective length of one data block.
Further preferably, the use cases of the judgment Dh and Dt specifically are:
if Dh is unused and Dt is unused, writing the data into the head, and no readable data exists;
if Dh is not used and Dt is used, writing the data into the head, and searching the first block of valid data from beginning to end during reading;
if Dh is used and Dt is not used, searching for blank area writing from the head, and reading valid data from the head;
if Dh is used and Dt is used, writing and reading from the head to search for a blank area, judging whether a first data block mark is valid, searching for valid data from tail to head if yes, and searching for valid data from head to tail if no. The system can realize reasonable and uniform use of the FLASH memory by the searching method, and prevent premature senility of partial blocks.
It is further preferred that the entire area is rewritten to 0 when a bad block is encountered during the seek.
Further preferably, after the searching, after determining the writing point and the reading point, the writing point and the next reading point are saved to the memory variable, and are directly used when writing or reading is performed again. This is directly used and adjusted when writing or searching next time, avoiding searching again.
A first-in first-out FLASH data storage system comprising:
the definition module: the definition module is used for defining a variable-length data block;
and (3) a searching module: the searching module is used for searching the blank area, writing the data block into the forefront end of the blank area and marking the data block as valid;
and a judging module: the judging module is used for reading back to check whether the writing is successful after the writing is completed; if not, rewriting the whole data area to 0; if successful, the re-input data is written into the next blank area in the following way.
Preferably, the definition module is configured to define a variable-length data block, where the data block is composed of: the beginning of a specified content, the middle contains the total length of the data block, the valid flag of the data block, the data content, and the data check code ends.
Preferably, the storage system further includes a data reading module, and the reading process of the data reading module includes:
searching the data block which is written first and marked as valid;
marking it as invalid and checking whether the modification is successful;
if the change is not successful, rewriting the whole data area to 0;
if the marking is successful, continuing to read the following valid data.
Further preferably, the data system further includes a search module, and the search process of the search module is specifically determining the current situation of the FLASH memory:
reading a part of data of the head part of the memory, and recording as Dh; the end of the memory reads a part of data forward, which is marked as Dt; and judging the service conditions of Dh and Dt.
Further preferably, the use cases of the judgment Dh and Dt specifically are:
if Dh is unused and Dt is unused, writing the data into the head, and no readable data exists;
if Dh is not used and Dt is used, writing the data into the head, and searching the first block of valid data from beginning to end during reading;
if Dh is used and Dt is not used, searching for blank area writing from the head, and reading valid data from the head;
if Dh is used and Dt is used, writing and reading from the head to search for a blank area, judging whether a first data block mark is valid, searching for valid data from tail to head if yes, and searching for valid data from head to tail if no. The searching method can uniformly use all the blocks of the memory, thereby preventing the memory from premature senility.
Further preferably, the searching module rewrites the whole area to 0 when a bad block is encountered in the searching process.
Further preferably, after the searching, after determining the writing point and the reading point, the next writing point and the next reading point are saved to the memory variable, and are directly used when writing or reading is performed again.
A computer readable storage medium storing computer program instructions adapted to be loaded by a processor and to perform a first-in first-out FLASH data storage method.
A mobile terminal comprises a processor and a memory, wherein the processor is used for executing a program stored in the memory so as to realize a first-in first-out FLASH data storage method.
Compared with the prior art, the invention has the following beneficial effects: the method of the invention can well lead each block of the FLASH memory to be used uniformly, prevent partial blocks from premature senility, simultaneously prevent the space occupied by the content of the management part from excessively large proportion, and squeeze the space occupied by the data storage. The device can make each block of the whole memory be erased and used uniformly through the algorithm, and bad blocks can be skipped effectively, so that the safety of data is ensured.
Drawings
The invention will be further described with reference to the drawings and examples.
Fig. 1 is a flow chart of a first-in first-out FLASH data storage method according to the present invention;
fig. 2 is a block diagram of a first-in first-out FLASH data storage system according to the present invention.
Detailed description of the preferred embodiments
The invention will now be described in further detail with reference to the accompanying drawings. The figures are simplified schematic representations which illustrate the basic flow diagrams of the invention by way of illustration only, and which therefore show only the flow associated with the invention.
Example 1
As shown in fig. 1, the present invention is a method for storing FLASH data in first out, which specifically includes:
s1, defining a variable-length data block;
s2, searching a blank area, writing the data block into the forefront end of the blank area, and marking the data block as valid;
s3, after the writing is completed, the read-back check is performed to determine whether the writing is successful;
s4, if the data area is unsuccessful, rewriting the whole data area to be 0;
s5, if successful, the re-input data is written into the next blank area in a downstream mode.
The data storage process comprises the following steps:
step S1: defining a variable length data block, said data block having the composition: the beginning of a specified content, the middle contains the total length of the data block, the valid flag of the data block, the data content, and the data check code ends.
Step S2: and searching a blank area, writing the data block into the forefront end of the blank area, marking the data block as valid, and searching the whole FLASH memory before writing.
Step S3: after the writing is completed, the read-back check is performed to determine whether the writing is successful;
step S4: if not, rewriting the whole data area to 0;
step S5: if successful, the re-input data is written into the next blank area in the following way.
Example 2
The first-in first-out FLASH data storage method also comprises a data reading process, wherein the data reading process comprises the following steps:
searching the data block which is written first and marked as valid;
marking it as invalid and checking whether the modification is successful;
if the change is not successful, rewriting the whole data area to 0;
if the marking is successful, continuing to read the following valid data.
The writing and reading of the data comprise searching processes, and the searching processes specifically comprise determining the current condition of FLASH:
reading a part of data of the head part of the memory, and recording as Dh; the end of the memory reads a part of data forward, which is marked as Dt; and judging the use condition of Dh and Dt, wherein the length defined by a part of data is the maximum effective length of one data block.
The use cases of the judgment Dh and the judgment Dt can be divided into four types, and the use cases are specifically as follows:
(1) If Dh is unused and Dt is unused, it means that the memory is empty, i.e., data has not been written. In this case, the header is written when the data is written, and no readable data is read when the data is read.
(2) If Dh is not used and Dt is used, it means that the front part of the memory is empty and the rear part is full of data. In this case, when writing data, the head is written, and then if the blank area is used up, the next block area is erased to be the blank area, and the first block of valid data is searched from the beginning to the end when reading for the next writing.
(3) If Dh is used and Dt is not used, it means that the front part of the memory is full of data and the rear part is empty. For this case, when writing data, searching a blank area from tail to head during writing, writing the data into a start area of the blank area after finding, and then erasing the next block as the blank area for next writing if the blank area is used up; reading the valid data from the head at the time of reading;
(4) If Dh is used and Dt is used, it means that the front part of the memory is full, the middle part is empty, and the rear part is full. For this case, the blank area is searched from beginning to end during writing, the data is written into the initial area of the blank area after finding, and then if the blank area is used up, the next block is erased to be the blank area for the next writing; when the bad block is encountered in the searching process of checking the first block number of the memory, the whole area is rewritten into 0. Searching and reading the first block of valid data from beginning to end according to whether the mark is valid or not and if not; if so, searching for "valid" data from tail to head, and encountering invalid data, i.e., blank area or data marked as not "valid", is stopped, and the first block of "valid" data following the invalid data is the data that should be read.
By the searching method, all the blocks of the FLASH memory can be well and evenly used, partial premature senility of the blocks is avoided, the storage space is reasonably managed, and writing and searching of data are facilitated.
And when the searching module encounters a bad block in the searching process, the whole area is rewritten into 0.
After the writing point and the reading point are determined after the searching, the writing point and the next reading point are saved to the memory variable, and are directly used when writing or reading is performed again.
Example 3
As shown in fig. 2, the present invention provides a FLASH data storage system of first in first out:
definition module 1: the definition module is used for defining a variable-length data block;
the searching module 2: the searching module is used for searching the blank area, writing the data block into the forefront end of the blank area and marking the data block as valid;
and a judging module 3: the judging module is used for reading back to check whether the writing is successful after the writing is completed; if not, rewriting the whole data area to 0; if successful, the re-input data is written into the next blank area in the following way.
The system for data also comprises a searching module, wherein the searching process of the searching module is specifically to determine the current condition of the FLASH memory:
reading a part of data of the head part of the memory, and recording as Dh; the end of the memory reads a part of data forward, which is marked as Dt; and judging the service conditions of Dh and Dt.
Further preferably, the use cases of the judgment Dh and Dt specifically are:
if Dh is unused and Dt is unused, writing the data into the head, and no readable data exists;
if Dh is not used and Dt is used, writing the data into the head, and searching the first block of valid data from beginning to end during reading;
if Dh is used and Dt is not used, searching for blank area writing from the head, and reading valid data from the head;
if Dh is used and Dt is used, writing and reading from the head to search for a blank area, judging whether a first data block mark is valid, searching for valid data from tail to head if yes, and searching for valid data from head to tail if no.
And when the searching module encounters a bad block in the searching process, the whole area is rewritten into 0.
The invention also includes a computer readable storage medium having stored thereon computer program instructions adapted to be loaded by a processor and to perform a first-in first-out FLASH data storage method.
The invention also comprises a mobile terminal which comprises a processor and a memory, wherein the processor is used for executing a program stored in the memory so as to realize a first-in first-out FLASH data storage method.
The foregoing detailed description is directed to embodiments of the invention, and is not intended to limit the scope of the invention, but rather to cover all modifications and variations within the scope of the invention.

Claims (7)

1. A first-in first-out FLASH data storage method is characterized by comprising the following steps:
defining a variable-length data block;
searching a blank area, writing a data block into the forefront end of the blank area, and marking the data block as valid;
after the writing is completed, the read-back check is performed to determine whether the writing is successful;
if not, rewriting the whole data area to 0;
if successful, the re-input data is written into the next blank area in a downstream way;
the data storage method also comprises a data reading process, wherein the data reading process comprises the following steps of:
searching the data block which is written first and marked as valid;
marking it as invalid and checking whether the modification is successful;
if the change is not successful, rewriting the whole data area to 0;
if the marking is successful, continuing to read the effective data;
the writing and reading of the data comprise searching processes, and the searching processes specifically comprise determining the current condition of the FLASH memory:
reading a part of data of the head of the FLASH memory, and recording as Dh; the end of the memory reads a part of data forward, which is marked as Dt; judging the service conditions of Dh and Dt;
the use conditions of the judgment Dh and the judgment Dt are specifically as follows:
if Dh is unused and Dt is unused, writing the data into the head, and no readable data exists;
if Dh is not used and Dt is used, writing the data into the head, and searching the first block of valid data from beginning to end during reading;
if Dh is used and Dt is not used, searching for blank area writing from the head, and reading valid data from the head;
if Dh is used and Dt is used, writing and reading from the head to search for a blank area, judging whether a first data block mark is valid, searching for valid data from tail to head if yes, and searching for valid data from head to tail if no.
2. The method for storing FLASH data in first-out according to claim 1, wherein the composition of the data block is: the beginning of a specified content, the middle contains the total length of the data block, the valid flag of the data block, the data content, and the data check code ends.
3. The method for storing FLASH data in first-out according to claim 1, wherein when a bad block is encountered in said searching process, the whole area is rewritten to 0.
4. The method for storing FLASH data in first-out according to claim 1, wherein after the writing point and the reading point are determined after the searching, the writing point and the next reading point are stored in the memory variable and are directly used when writing or reading is performed again.
5. A first-in first-out FLASH data storage system, comprising:
the definition module: the definition module is used for defining a variable-length data block;
and (3) a searching module: the searching module is used for searching the blank area, writing the data block into the forefront end of the blank area and marking the data block as valid;
and a judging module: the judging module is used for reading back to check whether the writing is successful after the writing is completed; if not, rewriting the whole data area to 0; if successful, the re-input data is written into the next blank area in the following way.
6. A computer readable storage medium, characterized in that the computer readable storage medium stores computer program instructions adapted to be loaded by a processor and to perform the method of any of claims 1-4.
7. A mobile terminal comprising a processor and a memory, wherein the processor is configured to execute a program stored in the memory, so as to implement the method of any one of claims 1 to 4.
CN201910975277.9A 2019-10-14 2019-10-14 First-in first-out FLASH data storage method, system and terminal Active CN110688084B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910975277.9A CN110688084B (en) 2019-10-14 2019-10-14 First-in first-out FLASH data storage method, system and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910975277.9A CN110688084B (en) 2019-10-14 2019-10-14 First-in first-out FLASH data storage method, system and terminal

Publications (2)

Publication Number Publication Date
CN110688084A CN110688084A (en) 2020-01-14
CN110688084B true CN110688084B (en) 2023-04-25

Family

ID=69112740

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910975277.9A Active CN110688084B (en) 2019-10-14 2019-10-14 First-in first-out FLASH data storage method, system and terminal

Country Status (1)

Country Link
CN (1) CN110688084B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112579004A (en) * 2020-12-17 2021-03-30 杭州艾芯智能科技有限公司 Method, system, computer equipment and storage medium for quickly deleting flash data

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3244446B2 (en) * 1997-02-27 2002-01-07 三洋電機株式会社 Digital camera
JP2990181B1 (en) * 1998-09-28 1999-12-13 日本電気アイシーマイコンシステム株式会社 Flash memory, microcomputer having flash memory, and method of storing program in flash memory
JP4794530B2 (en) * 2007-10-26 2011-10-19 ルネサスエレクトロニクス株式会社 Semiconductor device and mobile phone
CN101419573A (en) * 2008-12-01 2009-04-29 成都市华为赛门铁克科技有限公司 Storage management method, system and storage apparatus
CN103309619A (en) * 2012-03-16 2013-09-18 国民技术股份有限公司 NAND Flash memory data storage method
CN106776106A (en) * 2016-11-11 2017-05-31 南京南瑞集团公司 A kind of date storage method based on NandFlash

Also Published As

Publication number Publication date
CN110688084A (en) 2020-01-14

Similar Documents

Publication Publication Date Title
US8321481B2 (en) Method for incremental anti-tear garbage collection
US20150317246A1 (en) Memory Reclamation Method and Apparatus
US20090037646A1 (en) Method of using a flash memory for a circular buffer
CN109213448B (en) Method, device, equipment and storage medium for erasing and writing data of smart card
CN109918024B (en) Storage management method and device, single-chip microcomputer equipment and readable storage medium
CN110688084B (en) First-in first-out FLASH data storage method, system and terminal
CN108664208B (en) File additional writing operation method and device based on FLASH memory
KR101826778B1 (en) EEPROM Emulation Method Considering implementation of Flash Life Cycle and Performance Improvement
CN107908500B (en) Bad block identification method and device
CN105867833A (en) Data storage apparatus and data storage method
CN116185563A (en) Software simulation algorithm based on vehicle-gauge microcontroller data flash memory
CN111611000B (en) High-reliability firmware air upgrading method and system
US20110082995A1 (en) Information processing apparatus
CN107704247B (en) Method for reducing size of multi-core firmware
US8095262B2 (en) Vehicular control apparatus and program storage medium
CN109669628B (en) Data storage management method and device based on flash equipment
CN111090542A (en) Abnormal block identification method and device based on abnormal power failure and computer equipment
CN110795275A (en) Abnormal block identification method and device based on abnormal power failure process
CN116126229B (en) EEPROM variable management method and system
CN112905112B (en) Data processing method and system of embedded equipment
CN113918095B (en) Hybrid cross storage method and device for data and electronic equipment
CN117270760B (en) Sequence mapping generation method and device, storage main control chip and storage medium
US20240184453A1 (en) Information processing system, storage medium, and data write count management method
CN112162936B (en) Method and system for dynamically enhancing FLASH erasing times
CN112579003B (en) Key value pair adjustment method, key value pair adjustment device, storage medium and electronic 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
CB02 Change of applicant information

Address after: 518000 building 512, building 12, Shenzhen Bay science and technology ecological park, No. 18, South Science and technology road, high tech Zone, Yuehai street, Nanshan District, Shenzhen City, Guangdong Province

Applicant after: SHENZHEN LANDU AUTOMOBILE ELECTRIC CONTROL TECHNOLOGY Co.,Ltd.

Address before: Room 2-009, majialongtianxia Industrial Park, Yiyuan Road, Nantou street, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: SHENZHEN LANDU AUTOMOBILE ELECTRIC CONTROL TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
CB02 Change of applicant information

Address after: 518000 podium building 512, 514-516, building 12, Shenzhen Bay science and technology ecological park, No. 18, Keji South Road, high tech Zone, Yuehai street, Nanshan District, Shenzhen City, Guangdong Province

Applicant after: SHENZHEN LANDU AUTOMOBILE ELECTRIC CONTROL TECHNOLOGY Co.,Ltd.

Address before: 518000 building 512, building 12, Shenzhen Bay science and technology ecological park, No. 18, South Science and technology road, high tech Zone, Yuehai street, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: SHENZHEN LANDU AUTOMOBILE ELECTRIC CONTROL TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant