CN113157211B - Storage method for information record of embedded system - Google Patents

Storage method for information record of embedded system Download PDF

Info

Publication number
CN113157211B
CN113157211B CN202110426325.6A CN202110426325A CN113157211B CN 113157211 B CN113157211 B CN 113157211B CN 202110426325 A CN202110426325 A CN 202110426325A CN 113157211 B CN113157211 B CN 113157211B
Authority
CN
China
Prior art keywords
data
record
cache
information
buf
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
CN202110426325.6A
Other languages
Chinese (zh)
Other versions
CN113157211A (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.)
Wuhan Zhuomu Technology Co.,Ltd.
Original Assignee
Wuhan Zmvision 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 Wuhan Zmvision Technology Co ltd filed Critical Wuhan Zmvision Technology Co ltd
Priority to CN202110426325.6A priority Critical patent/CN113157211B/en
Publication of CN113157211A publication Critical patent/CN113157211A/en
Application granted granted Critical
Publication of CN113157211B publication Critical patent/CN113157211B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0616Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0619Improving the reliability of storage systems in relation to data integrity, e.g. data losses, bit errors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0653Monitoring storage devices or systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Computer Security & Cryptography (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a storage method of embedded system information record, comprising the following steps: initializing the system by mapping the CACHE to the correct data block; writing the data to be written into the data block; recording the retrieval process of the data; the addition, modification, and deletion of data are recorded. The invention manages all data records in the form of the micro-file, thereby facilitating the random size change and the addition and deletion management of a plurality of records; managing a plurality of FLASH blocks through a verification algorithm to achieve the purpose of wear balance; the safe atomic operation ensures the data safety; data redundancy is improved to achieve higher reliability. The invention is especially suitable for the working environment of various embedded environments, specially deals with various trivial small information records, has the advantages of less required resources, high reliability, simple and direct use and provides powerful storage technical support for constructing stable and reliable embedded application environments.

Description

Storage method for information record of embedded system
Technical Field
The invention relates to the field of data storage, in particular to a storage method for information records of an embedded system.
Background
Small records of onboard information and configuration data in the embedded system have the characteristic of small size and many information fragments, and cannot be lost during the flashing and use processes. In the current technical scheme, the information is generally organized and packaged into a structural body, then two blocks are divided from the FLASH, the data of the structural body is sequentially written into the two blocks, and the latter block plays a backup function, so that the information loss caused by accidental power failure during erasing is prevented.
The defects of the prior art are that for trivial information data, the flexibility is lacked on a FLASH physical block only by using the form of a structural body to directly map, the change of the data size and the compatibility of adding and deleting data items relate to the definition change of the structural body, and the manageability convenience is lacked; secondly, frequently updated application scenarios can increase the probability of damage to the FLASH block, and this approach does not provide enough preparation for FLASH wear.
Disclosure of Invention
In view of the above, the present invention has been made to provide a storage method of an embedded system information record that overcomes or at least partially solves the above problems.
In order to solve the technical problem, the embodiment of the application discloses the following technical scheme:
a storage method of embedded system information records comprises the following steps:
s100, initializing a system by mapping CACHE to a correct data block;
s200, writing the data to be written into a data block;
s300, recording the data retrieval process;
s400, recording the addition, modification and deletion of data;
further, in S100, a specific method for initializing the system is as follows:
s101, initializing the CACHE into an empty data block, wherein the information serial number is 0, and the information serial number 0 is a reserved value which is smaller than the information serial number in any real data block, so that the initialized CACHE is ensured to have the lowest exchange sequence;
s102, judging whether unread data blocks exist or not, if not, jumping to S105, otherwise, reading the next data block into the BUF;
s103, checking whether the characteristic numerical values and the check values in the BUF are correct in sequence, if not, ignoring, and returning to S102;
s104, when the information sequence number in the BUF is larger than the information sequence number of the CACHE, exchanging the BUF and the CACHE pointer to represent that the CACHE is exchanged into data with higher version; continuing to execute S102;
and S105, completing CACHE mapping and completing system initialization.
Further, in S200, the method for writing new data into the data block includes:
s201, preparing new data ready to be written in the BUF;
s202, acquiring a current information serial number CACHE _ K from a CACHE, wherein the CACHE _ K represents the highest information serial number of a current system and assigns the highest information serial number to the information serial number K in the BUF;
s203, increasing the information sequence number K in the BUF, namely K = K +1, so that new data has a higher exchange sequence;
s204, judging whether the increased information sequence number meets a formula K < CACHE _ K + M, wherein M represents the total number of the data blocks, and if the increased information sequence number meets the formula, executing S305; if the formula is not satisfied, the writing fails, no available data block exists, and the whole process is exited;
s205, after updating the check value of the BUF data block, calculating a write-in position offset S according to a position offset formula, and writing BUF data into a # S block of the system area;
s206, judging whether a bad block is encountered, returning to S303 if the bad block is encountered, and otherwise continuing to S307;
s207, through atom exchange of CACHE and BUF pointers, the CACHE still keeps the complete data with the highest information sequence number, and the writing process is completed.
Further, the position offset S is formulated as:
S=K MOD M;
wherein S is position deviation, K is information sequence number, M is data block total number, and MOD represents modulus operator.
Further, in S300, the specific method of S300 is:
s301, reading a block information header in the CACHE, acquiring the total number of records as a constraint condition of iteration, initializing a record access pointer P as a first record position, and setting the iteration number R as 0;
s302, checking whether the iteration times R reach the total record number or not, and if not, executing S303; if the result is reached, the search is failed, no record of the designated number exists in the CACHE, and the process is exited;
s303, reading the record pointed by the P, and acquiring the record number T and the record length L of the record;
s304, comparing whether T is the information number to be retrieved, if yes, jumping to S306, and if not, continuing to S305;
s305, increasing the iteration number, wherein R = R +1, recording the jump of the pointer to the next position P = P + L, and jumping to S302 to continue the iteration;
s306, recording the retrieved position, returning a pointer and a length for copying.
Further, in S400, the specific method of S400 is:
s401, initializing a BUF to be a null data block, setting a recording pointer P to point to a CACHE first record, setting a recording pointer Q to point to a BUF first record, and setting an iterator R to be 0;
s402, checking whether the iterator R is equal to the total number of CACHE records, if so, returning a null pointer, otherwise, returning the record pointed by the P;
s403, checking whether the record pointer returned by the S402 is valid, if yes, continuing to the S404, otherwise, jumping to the S407;
s404, reading the record number T and the record length L pointed by the P, checking whether the T is a number which needs to be modified or deleted in the operation, if so, jumping to S406, and otherwise, continuing to S405;
s405, copying the record pointed by the P to a position Q, and revising a Q pointer to point to the next record, namely Q = Q + L;
s406, increasing the iterator by one, wherein R = R +1, and meanwhile revising the P pointer to point to the next record, and jumping to S402;
s407, when all the irrelevant records are copied from the CACHE to the BUF, if the operation is 'delete', jumping to S410, and if 'add' or 'modify', continuing to S408;
s408, checking whether the residual space of the data block is enough to write a new record, if so, exiting the process, otherwise, continuing the S409;
s409, writing the new record into a position Q;
and S410, the data block in the BUF is ready.
Furthermore, the data block is composed of a fixed block information head and a plurality of variable information records; the block header data includes a characteristic value, a check value, an information sequence number, and a total number of records.
Further, the characteristic value is a conventional 32-bit unsigned integer used for directly excluding data blocks not belonging to the system; the information sequence number is a 32-bit unsigned integer which is increased by 1 every time the data block is written, and the information sequence number cannot be circulated in the FLASH life cycle and is used for distinguishing the precedence relationship of the information blocks; the total number of records is the total number of data records present in the block; the check value is a value calculated from the header to the CRC32 of all data at the end of the last record.
The technical scheme provided by the embodiment of the invention has the beneficial effects that at least:
the invention discloses a storage method of embedded system information records, which manages all data records in a micro-file form, and is convenient for random size change and addition and deletion management of a plurality of records; managing a plurality of FLASH blocks through a verification algorithm to achieve the purpose of wear balance; the safe atomic operation ensures the data safety; data redundancy is improved to achieve higher reliability. The invention is especially suitable for the working environment of various embedded environments, specially deals with various trivial information records, has the advantages of less required resources, high reliability and simple and direct use, and provides powerful storage technical support for constructing stable and reliable embedded application environments.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention. In the drawings:
fig. 1 is a flowchart of a method for storing an embedded system information record in embodiment 1 of the present invention;
FIG. 2 is a flowchart of a logic for initializing a system according to embodiment 1 of the present invention;
FIG. 3 is a logic flow diagram illustrating a process of writing new data into a data block according to embodiment 1 of the present invention;
FIG. 4 is a logic flow diagram of recording data retrieval in embodiment 1 of the present invention;
fig. 5 is a logic flow diagram of adding, modifying or deleting records to generate a new data block in embodiment 1 of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In order to solve the problems in the prior art, the embodiment of the invention provides a method.
Example 1
The embodiment discloses a storage method of embedded system information record, as shown in fig. 1, including:
s100, initializing a system by mapping CACHE to a correct data block; specifically, in this embodiment, the data block is the basic unit for block erasure, a single data block must be completely written into the block device, and only a part of the data block will be considered as invalid by the system. A pair of memory areas dedicated to data block processing are a read map CACHE and a read-write buffer BUF, respectively, which have the same capacity as the data blocks. The CACHE can greatly improve the access efficiency, and can support multi-thread concurrent access at any time, and any external record reading is to copy data from the CACHE directly; the BUF is used in the internal processing of the system, and all the record writing outside is copied to the BUF.
In this embodiment, a data block is composed of a fixed block header and a number of variable information records. The block header data includes a characteristic value, a check value, an information sequence number, and a total number of records. Wherein the characteristic value is a predetermined 32-bit unsigned integer for directly excluding data blocks not belonging to the system; the information sequence number is a 32-bit unsigned integer which increases 1 by each time the data block is written, and the information sequence number cannot be circulated in the service life of the FLASH and is used for distinguishing the precedence relationship of the information blocks; the total number of records is the total number of data records present in the block; the check value is the data filled with 0 at the position where the check value itself is located when calculating the CRC32 (cyclic redundancy check) calculation value of all data from the header to the last recording end).
Specifically, as shown in fig. 2 and S100, a specific method for initializing the system is as follows:
s101, initializing the CACHE into an empty data block, wherein the information serial number is 0, and the information serial number 0 is a reserved value which is smaller than the information serial number in any real data block, so that the initialized CACHE is ensured to have the lowest exchange sequence;
s102, judging whether unread data blocks exist or not, if not, jumping to S105, otherwise, reading the next data block into the BUF;
s103, checking whether the characteristic numerical values and the check values in the BUF are correct or not in sequence, if not, ignoring, and returning to S102;
s104, when the information sequence number in the BUF is larger than the information sequence number of the CACHE, exchanging the BUF and the CACHE pointer to represent that the CACHE is exchanged into data with higher version; continuing to execute S102;
and S105, completing CACHE mapping and completing system initialization.
And S200, writing the data to be written into a data block. In this embodiment S200, as shown in fig. 3, the method for writing new data into a data block includes:
s201, preparing new data ready to be written in the BUF;
s202, acquiring a current information serial number CACHE _ K from a CACHE, wherein the CACHE _ K represents the highest information serial number of a current system, and assigning the highest information serial number to the information serial number K in the BUF;
s203, increasing the information sequence number K in the BUF, namely K = K +1, so that new data has a higher exchange sequence;
s204, judging whether the increased information sequence number meets a formula K < CACHE _ K + M, wherein M represents the total number of the data blocks, and if the increased information sequence number meets the formula, executing S305; if the formula is not satisfied, the writing fails, no available data block exists, and the whole process is exited;
s205, after updating the check value of the BUF data block, calculating a write-in position offset S according to a position offset formula, and writing BUF data into a # S block of the system area; the positional offset S is formulated as:
S=K MOD M;
wherein S is position deviation, K is information sequence number, M is data block total number, and MOD represents modulus operator.
S206, judging whether a bad block is encountered, returning to S303 if the bad block is encountered, and otherwise continuing to S307;
s207, through atom exchange of CACHE and BUF pointers, the CACHE still keeps complete data of the highest information sequence number, and the writing process is completed.
And S300, recording the data retrieval process. In this embodiment S300, as shown in fig. 4, the specific method of S300 is:
s301, reading a block information header in CACHE, acquiring the total number of records as a limit condition of iteration, initializing a record access pointer P as a first record position, and setting the iteration number R as 0;
s302, checking whether the iteration times R reach the total recorded number or not, and if not, executing S303; if the number of the designated number is reached, the retrieval is failed, no record of the designated number exists in CACHE, and the process is exited;
s303, reading the record pointed by the P, and acquiring the record number T and the record length L of the record;
s304, comparing whether the T is the information number to be retrieved, if yes, jumping to S306, and if not, continuing to S305;
s305, increasing the iteration number, wherein R = R +1, recording the jump of the pointer to the next position P = P + L, and jumping to S302 to continue the iteration;
s306, recording the retrieved position, and returning a pointer and a length for copying.
And S400, recording the addition, modification and deletion of the data. In this embodiment S400, as shown in fig. 5, the specific method of S400 includes:
s401, initializing a BUF to be a null data block, setting a recording pointer P to point to a CACHE first record, setting a recording pointer Q to point to a BUF first record, and setting an iterator R to be 0;
s402, checking whether the iterator R is equal to the total number of CACHE records or not, if so, returning a null pointer, and otherwise, returning the record pointed by the P;
s403, checking whether the record pointer returned by the S402 is valid, if so, continuing to the S404, otherwise, jumping to the S407;
s404, reading the record number T and the record length L pointed by P, checking whether the T is a number which needs to be modified or deleted in the operation, if so, jumping to S406, otherwise, continuing to S405;
s405, copying the record pointed by the P to a position Q, and revising a Q pointer to point to the next record, namely Q = Q + L;
s406, increasing the iterator by one, wherein R = R +1, and revising the P pointer to point to the next record, and jumping to S402;
s407, when all the irrelevant records are copied from the CACHE to the BUF, if the operation is 'delete', jumping to S410, and if 'add' or 'modify', continuing to S408;
s408, checking whether the residual space of the data block is enough to write a new record, if so, exiting the process, otherwise, continuing to S409;
s409, writing the new record into a position Q;
and S410, the data block in the BUF is ready.
It can be seen from the above specific flow of S400 that the unified flow of adding, modifying and deleting records is to copy the unrelated record from CACHE to BUF, and then determine whether to add a new record to BUF to achieve the goal.
The flow is very simple to implement, does not generate any space debris, and is easy to calculate whether the residual space is abundant. In terms of fault tolerance, there is no impact on "deleting" or "modifying" a record that does not exist at all, nor is there any error in "adding" an existing record.
The storage method for the information record of the embedded system has the following advantages:
1. the method can not be broken down, and a plurality of data blocks are subjected to checksum comparison and fair competition, and then the most appropriate data is selected and mapped into the CACHE. The election system avoids the permanent crash of the file system caused by the external impact on the central management data structure of the file system;
2. the block operation of the method is atomic, and the history data cannot be destroyed by accidentally interrupted writing, namely, the block operation is completely successful, a new data block is mapped into a CACHE because of having the highest information sequence number and correct verification, or the new data block is directly ignored when being unsuccessful, and the CACHE still maps the last history data;
3. and automatically managing the erasing wear of the physical blocks. The service life of FLASH is prolonged when frequent updating is carried out. In actual use, the number of the physical blocks can be reasonably configured according to application conditions to balance the abrasion times, so that the service life of the physical blocks in the system is longer than the life cycle of equipment;
4. the bad block tolerance is high. In the total M data blocks, the maximum can bear M-2 bad blocks without causing abnormal work;
5. natural redundancy. The rest records except the latest record have 1 to M redundancies, and the longer the historical deposit records, the larger the redundancy number of the records, the less chance to lose from the system;
6. the backup is simple. Although the redundancy in the system is safe, the situation of backup is simple, and the situation of writing once is adjusted, so that the problem of what bad blocks are written to and where the bad blocks are written to is not concerned at all;
7. migration is facilitated. Directly marking out a new area from the equipment, writing CACHE into any available data block, and reinitializing from the new area;
8. the record access speed based on CACHE is very high, and multithreading concurrency is supported even if new data is being written;
9. the management of records based on numbers is very convenient, resembles a single directory of small file systems, and is completely independent of variations in the type, size and amount of data recorded.
In summary, the storage method for information records of an embedded system disclosed in this embodiment manages all data records in the form of micro files, so as to facilitate any size change and add/delete management of many records; managing a plurality of FLASH blocks through a verification algorithm to achieve the purpose of wear balance; the safe atomic operation ensures the data safety; data redundancy is improved to achieve higher reliability. The invention is especially suitable for the working environment of various embedded environments, specially deals with various trivial small information records, has the advantages of less required resources, high reliability, simple and direct use and provides powerful storage technical support for constructing stable and reliable embedded application environments.
It should be understood that the specific order or hierarchy of steps in the processes disclosed is an example of exemplary approaches. Based upon design preferences, it is understood that the specific order or hierarchy of steps in the processes may be rearranged without departing from the scope of the present disclosure. The accompanying method claims present elements of the various steps in a sample order, and are not meant to be limited to the specific order or hierarchy presented.
In the foregoing detailed description, various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting an intention that the claimed embodiments of the subject matter require more features than are expressly recited in each claim. Rather, as the following claims reflect, invention lies in less than all features of a single disclosed embodiment. Thus, the following claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. Of course, the processor and the storage medium may reside as discrete components in a user terminal.
For a software implementation, the techniques described herein may be implemented with modules (e.g., procedures, functions, and so on) that perform the functions described herein. The software codes may be stored in memory units and executed by processors. The memory unit may be implemented within the processor or external to the processor, in which case it can be communicatively coupled to the processor via various means as is known in the art.
What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising" is interpreted when employed as a transitional word in a claim. Furthermore, any use of the term "or" in the specification of the claims is intended to mean a "non-exclusive or".

Claims (5)

1. A method for storing information records of an embedded system is characterized by comprising the following steps:
s100, initializing a system by mapping CACHE to a correct data block;
s200, writing the data to be written into a data block; in S200, the method for writing new data into the data block includes:
s201, preparing new data ready to be written in the BUF;
s202, acquiring a current information serial number CACHE _ K from a CACHE, wherein the CACHE _ K represents the highest information serial number of a current system and assigns the highest information serial number to the information serial number K in the BUF;
s203, increasing the information sequence number K in the BUF, namely K = K +1, so that new data has a higher exchange sequence;
s204, judging whether the increased information sequence number meets a formula K < CACHE _ K + M, wherein M represents the total number of the data blocks, and if the increased information sequence number meets the formula, executing S205; if the formula is not satisfied, the writing fails, no available data block exists, and the whole process is exited;
s205, after updating the check value of the BUF data block, calculating a writing position offset S according to a position offset formula, and writing BUF data into a # S block of a system area;
s206, judging whether a bad block is encountered, returning to S203 if the bad block is encountered, and otherwise continuing to S207;
s207, through atom exchange of CACHE and BUF pointers, the CACHE still keeps complete data with the highest information sequence number, and the writing process is completed;
s300, recording the retrieval process of the data; the specific method of S300 is as follows:
s301, reading a block information header in CACHE, acquiring the total number of records as a limit condition of iteration, initializing a record access pointer P as a first record position, and setting the iteration number R as 0;
s302, checking whether the iteration times R reach the total recorded number or not, and if not, executing S303; if the result is reached, the search is failed, no record of the designated number exists in the CACHE, and the process is exited;
s303, reading the record pointed by the P, and acquiring the record number T and the record length L of the record;
s304, comparing whether T is the information number to be retrieved, if yes, jumping to S306, and if not, continuing to S305;
s305, increasing the iteration number, wherein R = R +1, recording the jump of the pointer to the next position P = P + L, and jumping to S302 to continue the iteration;
s306, recording the retrieved position, and returning a pointer and a length for copying;
s400, recording the addition, modification and deletion of data; the specific method of S400 is as follows:
s401, initializing a BUF into a null data block, setting a recording pointer P to point to a CACHE first record, setting a recording pointer Q to point to a BUF first record, and setting an iterator R to be 0;
s402, checking whether the iterator R is equal to the total number of CACHE records, if so, returning a null pointer, otherwise, returning the record pointed by the P;
s403, checking whether the record pointer returned by the S402 is valid, if so, continuing to the S404, otherwise, jumping to the S407;
s404, reading the record number T and the record length L pointed by P, checking whether the T is a number which needs to be modified or deleted in the operation, if so, jumping to S406, otherwise, continuing to S405;
s405, copying the record pointed by the P to a position Q, and revising a Q pointer to point to the next record, namely Q = Q + L;
s406, increasing the iterator by one, wherein R = R +1, and revising the P pointer to point to the next record, and jumping to S402;
s407, when all the irrelevant records are copied from the CACHE to the BUF, if the operation is 'delete', jumping to S410, and if 'add' or 'modify', continuing to S408;
s408, checking whether the residual space of the data block is enough to write a new record, if so, exiting the process, otherwise, continuing to S409;
s409, writing the new record into a position Q;
and S410, the data block in the BUF is ready.
2. The method of claim 1, wherein the information record of the embedded system is stored,
in S100, a specific method for initializing the system is as follows:
s101, initializing the CACHE into an empty data block, wherein the information serial number is 0, and the information serial number 0 is a reserved value which is smaller than the information serial number in any real data block, so that the initialized CACHE is ensured to have the lowest exchange sequence;
s102, judging whether unread data blocks exist or not, if not, jumping to S105, otherwise, reading the next data block into the BUF;
s103, checking whether the characteristic numerical values and the check values in the BUF are correct in sequence, if not, ignoring, and returning to S102;
s104, when the information sequence number in the BUF is larger than that of the CACHE, exchanging the BUF and the CACHE pointer to represent that the CACHE is exchanged into data with a higher version; continuing to execute S102;
and S105, completing CACHE mapping and completing system initialization.
3. The method for storing the information record of the embedded system according to claim 1, wherein the position offset S is expressed by the formula:
S=KMODM;
wherein S is position deviation, K is information sequence number, M is data block total number, and MOD represents the modulus operator.
4. A storage method of an embedded system information record according to claim 1, characterized in that the data block is composed of a fixed block header and a number of variable information records; the block header data includes a characteristic value, a check value, an information sequence number, and a total number of records.
5. The method of claim 4, wherein the characteristic value is a predetermined 32-bit unsigned integer for directly excluding data blocks not belonging to the system; the information sequence number is a 32-bit unsigned integer which is increased by 1 every time the data block is written, and the information sequence number cannot be circulated in the FLASH life cycle and is used for distinguishing the precedence relationship of the information blocks; the total number of records is the total number of data records present in the block; the check value is a value calculated from all data CRC32 from the header to the last recording end.
CN202110426325.6A 2021-04-20 2021-04-20 Storage method for information record of embedded system Active CN113157211B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110426325.6A CN113157211B (en) 2021-04-20 2021-04-20 Storage method for information record of embedded system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110426325.6A CN113157211B (en) 2021-04-20 2021-04-20 Storage method for information record of embedded system

Publications (2)

Publication Number Publication Date
CN113157211A CN113157211A (en) 2021-07-23
CN113157211B true CN113157211B (en) 2022-11-18

Family

ID=76869122

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110426325.6A Active CN113157211B (en) 2021-04-20 2021-04-20 Storage method for information record of embedded system

Country Status (1)

Country Link
CN (1) CN113157211B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567225A (en) * 2011-12-28 2012-07-11 北京握奇数据系统有限公司 Method and device for managing system memory
CN104657132A (en) * 2009-12-17 2015-05-27 株式会社东芝 Semiconductor system, semiconductor device, and electronic device initializing method
CN108021471A (en) * 2016-11-04 2018-05-11 三星电子株式会社 The method of data storage device, data handling system and manufaturing data storage device
CN109308269A (en) * 2017-07-26 2019-02-05 华为技术有限公司 A kind of EMS memory management process and device
US10409507B1 (en) * 2016-10-31 2019-09-10 Marvell International Ltd. Methods and apparatus for implementing virtual dynamic library loading in embedded systems
CN111930309A (en) * 2020-07-31 2020-11-13 中国人民解放军海军工程大学 File circular storage method and device based on data blocking technology
CN112596808A (en) * 2020-12-16 2021-04-02 微网智控(北京)科技有限公司 Parameter storage mechanism of embedded system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106527969B (en) * 2016-09-21 2017-09-19 中国科学院地质与地球物理研究所 A kind of Nand Flash memorizer reading/writing method in a balanced way of life-span

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657132A (en) * 2009-12-17 2015-05-27 株式会社东芝 Semiconductor system, semiconductor device, and electronic device initializing method
CN102567225A (en) * 2011-12-28 2012-07-11 北京握奇数据系统有限公司 Method and device for managing system memory
US10409507B1 (en) * 2016-10-31 2019-09-10 Marvell International Ltd. Methods and apparatus for implementing virtual dynamic library loading in embedded systems
CN108021471A (en) * 2016-11-04 2018-05-11 三星电子株式会社 The method of data storage device, data handling system and manufaturing data storage device
CN109308269A (en) * 2017-07-26 2019-02-05 华为技术有限公司 A kind of EMS memory management process and device
CN111930309A (en) * 2020-07-31 2020-11-13 中国人民解放军海军工程大学 File circular storage method and device based on data blocking technology
CN112596808A (en) * 2020-12-16 2021-04-02 微网智控(北京)科技有限公司 Parameter storage mechanism of embedded system

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
基于缓存机制的NAND FLASH XIP存储系统;郝记生等;《计算机工程与设计》;20070708(第13期);全文 *
嵌入式系统中的CACHE问题;陈曦等;《电子技术应用》;20031030(第09期);全文 *
嵌入式系统的高速缓存管理;钟锐等;《电脑知识与技术》;20080423(第12期);全文 *

Also Published As

Publication number Publication date
CN113157211A (en) 2021-07-23

Similar Documents

Publication Publication Date Title
US5406529A (en) Flash non-volatile memory
US6219752B1 (en) Disk storage data updating method and disk storage controller
CN101124639B (en) System and method of accessing non-volatile computer memory
US6381176B1 (en) Method of driving remapping in flash memory and flash memory architecture suitable therefor
EP1739535B1 (en) File system storing transaction records in flash-like media
US6865658B2 (en) Nonvolatile data management system using data segments and link information
KR100849446B1 (en) Storage device, memory managing apparatus, memory managing method, and computer-readable recording medium
US8996791B2 (en) Flash memory device, memory control device, memory control method, and storage system
US20090327804A1 (en) Wear leveling in flash storage devices
EP1927920A2 (en) Semiconductor memory system having a snapshot function
EP1744247A2 (en) Optimized startup verification of file system integrity
CN112463724B (en) Data processing method and system for lightweight file system
JPH02292798A (en) Flash eeprom system
JP2007310636A (en) Data storage device and data storage method
CN103914667B (en) Safety electrically erasable programmable read only memory (EEPROM) reading method and system thereof
CN108804045A (en) A kind of bad block table method for building up and relevant apparatus
CN109918024B (en) Storage management method and device, single-chip microcomputer equipment and readable storage medium
JP4968342B2 (en) RAID controller and RAID system
CN112463020A (en) Data access method, device and equipment based on Flash
CN103544995B (en) A kind of bad track repairing method and bad track repairing device
US20090164869A1 (en) Memory architecture and configuration method thereof
CN113157211B (en) Storage method for information record of embedded system
JPH07302175A (en) Semiconductor disk device
CN110187837A (en) A kind of file access method, device and file system
CN114518845A (en) Data storage method, device, medium and equipment

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

Address after: 430073 No. 006, 20th floor, business project (China Pharmaceutical Technology Trading Market), No. 1, xiyaojian Road, north of Gaoxin Avenue and Heying Road, East Lake New Technology Development Zone, Wuhan City, Hubei Province

Patentee after: Wuhan Zhuomu Technology Co.,Ltd.

Country or region after: China

Address before: A2-32-05, 2nd floor, Guannan science and Technology Industrial Park, Guandong street, Donghu New Technology Development Zone, Wuhan, Hubei Province

Patentee before: WUHAN ZMVISION TECHNOLOGY Co.,Ltd.

Country or region before: China