CN109254878B - Smart card power-down backup method and data structure based on character writing - Google Patents

Smart card power-down backup method and data structure based on character writing Download PDF

Info

Publication number
CN109254878B
CN109254878B CN201811131296.5A CN201811131296A CN109254878B CN 109254878 B CN109254878 B CN 109254878B CN 201811131296 A CN201811131296 A CN 201811131296A CN 109254878 B CN109254878 B CN 109254878B
Authority
CN
China
Prior art keywords
page
mark
data
pages
writing
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
CN201811131296.5A
Other languages
Chinese (zh)
Other versions
CN109254878A (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.)
Beijing CEC Huada Electronic Design Co Ltd
Original Assignee
Beijing CEC Huada Electronic Design Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing CEC Huada Electronic Design Co Ltd filed Critical Beijing CEC Huada Electronic Design Co Ltd
Priority to CN201811131296.5A priority Critical patent/CN109254878B/en
Publication of CN109254878A publication Critical patent/CN109254878A/en
Application granted granted Critical
Publication of CN109254878B publication Critical patent/CN109254878B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • 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/061Improving I/O performance
    • 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/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0652Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
    • 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)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Computer Security & Cryptography (AREA)
  • Quality & Reliability (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The invention discloses a smart card power-down backup method and a data structure based on word writing, which can eliminate the safety risk of unstable reading after an NVM page is erased and powered down, reduce the erasing and writing times of the NVM in power-down backup and improve the speed of the power-down backup. The data structure provided by the invention is as follows: a page of NVM contains both data and two flags. The method provided by the invention comprises the following steps: when the NVM page is erased and written, after the page is erased, data, a mark 1 and a mark 2 are sequentially written in a hardware word writing mode; and when the page is read and written subsequently, judging the effective states of the two marks based on the data and the writing sequence of the two marks to determine the effectiveness of the page data, determining whether to perform power failure recovery first, eliminating the unstable state through the power failure recovery, and then performing data reading and writing.

Description

Smart card power-down backup method and data structure based on character writing
Technical Field
The invention relates to the technical field of smart cards, in particular to a smart card power-down backup method and a data structure based on writing.
Background
According to the erasing and writing characteristics of the NVM of the smart card chip, hardware word writing operation can be carried out after the whole page is erased, and power failure occurs when the hardware word writing occurs, so that the reading stability of the current word is mainly influenced. The performance of the whole-page hardware word writing only by erasing is basically consistent with the performance of the whole-page erasing once, and the word writing modes in the text are all hardware word writing.
After the NVM page is erased and written down, the page is not stable to read. After the NVM page is erased and written with power failure, data is read correctly in the early stage, unstable states caused by power failure cannot be identified, and data in the page may jump or read unstably in subsequent use, which may cause unknown abnormality of the smart card, even change of transaction balance, and thus, there is a great safety risk.
The existing power failure backup method in the current smart card usually takes the traditional backup as the main point. Generally, when the conventional backup is used for power failure protection, data in the backup area needs to be erased and written first, then the valid flag in the backup area is erased and written to be valid, then the target data is written, and finally the valid flag in the backup area is erased and written to be invalid. According to the conventional backup process, at least 4 NVM erasing operations are required for 1 NVM data update, resulting in poor erasing performance.
At present, in addition to the conventional backup, in order to increase the speed, there is a multi-sector backup in which a data area is divided into two or more sectors, the sectors are backed up with each other, and 1 sector mark is set for each sector. The backup method needs to update the whole target sector when updating data, calculates the CRC of the whole target sector and erases and writes the sector mark. The problem with this backup method using only 1 backup mark is: 1-time target page erasing and writing needs to be carried out for more than 2 times of memory erasing and writing operations, and the CRC of the whole sector needs to be calculated, so that the additional overhead is large; the CRC is used for data verification, so that the collision probability exists, and the problem of reading instability after the NVM page is erased and powered down cannot be solved; the target sector is erased and written each time, and the sector mark page becomes the erase life bottleneck (namely, under the condition that only one page in the sector is erased and written each time, the total accumulated erasing and writing times of each page in the sector is equal to the total erasing and writing times of the sector mark page, so that the total erasing and writing life of each page in the whole sector is greatly reduced).
In the existing power-down backup method of the smart card, the NVM erasing times are more, the overall performance of the smart card is influenced, and particularly the transaction performance is influenced; and some methods cannot solve the problem of unstable reading of the NVM page after the erasing power failure, so that great safety risk exists, and practical popularization cannot be carried out in the safety field.
Disclosure of Invention
Aiming at various defects in the conventional smart card power-down backup method, the invention provides the smart card power-down backup method and the data structure based on the word writing, which can eliminate the safety risk of unstable reading after the NVM page is erased and powered down, reduce the erasing frequency of the NVM in the power-down backup and improve the speed of the power-down backup.
In the invention, each logical page corresponds to a plurality of physical pages, and the physical pages are mirror images. When the logical page is read and written, one mirror image page is identified as effective data of the logical page for reading and writing. The power failure backup data structure comprises three parts, namely page data, a mark 1 and a mark 2, in each page of NVM, wherein the page data comprises user data and a counter of 1 word, the mark 1 and the mark 2 are respectively 1 word, and each logical page of the NVM corresponds to a plurality of (including two) mirror image pages and is mutually backed up. In the smart card chip based on writing, the page data, the mark 1 and the mark 2 are sequentially written into the target page for 3 times in a writing mode, so that reading instability after power failure of an erasing NVM (non volatile memory) can be avoided, collision probability existing in a CRC (cyclic redundancy check) algorithm can be avoided, and the safety and stability of power failure backup of the smart card are greatly enhanced; and the 1-time data update with the power-down backup function is reduced to the erasing and writing time of only 1-time NVM, so that the power-down backup performance can be obviously improved, and particularly the transaction performance of the smart card is improved. The processing method provided by the invention is pioneering, and similar technologies are not found.
In order to realize the purpose of the invention, the technical method adopted by the invention comprises the following steps:
step one, starting single-page erasing.
And step two, reading marks 1 and 2 of all mirror image pages in a plurality of mirror image pages of the NVM logical page, judging whether to carry out power failure recovery according to the effective state of the mirror image pages, finding out a target page with the minimum (oldest) counter after all the pages are stable and effective, carrying out only erasing operation of the whole page according to the characteristic of the NVM erasing operation, and firstly carrying out single erasing operation on the target page by using a whole page erasing mode.
And step three, organizing data to be written into the target page, programming the target page word by word from the page head by using a word writing mode, wherein a counter is placed in one word of the data and is written with other data, and the page counter is ensured to be the maximum counter in all pages before updating plus 1.
And fourthly, writing the mark 1 into an effective value in a word writing mode, and placing the mark 1 into a word, such as the penultimate word of each page.
And step five, writing the mark 2 into an effective value in a word writing mode, and placing the mark 2 into a word, such as the last word of each page.
And step six, ending the single-page erasing.
After the single page of the NVM is erased and written, when the page is subsequently read and written, the effective states of the mark 1 and the mark 2 of each page are firstly read in a plurality of mirror image pages of the NVM logical page, and whether power failure recovery is carried out is judged.
When all the page marks 1 and 2 are valid, the pages are valid pages, and the pages are directly used without power failure recovery; when a certain page mark 1 is valid and a mark 2 is invalid, identifying that the page is an invalid page, possibly writing the mark 1 or the mark 2 in the past and then powering down, and performing power down recovery in order to eliminate the possible unstable state of the mark 1 or the mark 2; when a certain page mark 1 is invalid, the page is an invalid page, and power failure can be caused when data is erased, written or the mark 1 is written before.
After power failure recovery, all mirror image pages become effective pages, and if the effective pages are read, the page with the largest counter (the latest page) is selected for reading; and if the operation is erasing operation, selecting the page with the smallest counter (the oldest page) for erasing, and changing the counter of the target page to the largest counter in all the current pages and adding 1 before erasing.
Power failure recovery flow:
and in the power failure recovery of the invalid page, judging the validity of data in the page according to the valid states of the mark 1 and the mark 2, and performing different recovery processes according to different data validity.
If the mark 1 is valid and the mark 2 is invalid, it indicates that power failure occurs when the page is written with the mark 1 or the mark 2, or because reading instability occurs after the previous write mark 2 is powered down, but the page data is correctly written and stable, the page data is valid, and if the page data is valid and the mark 2 is unstable, the maximum recovery counter is firstly used, and then power failure recovery is performed on the valid data. The operation is as follows:
1) if the page data is read, restoring the page data to the page with the smallest counter in all pages by using a word writing mode, and erasing and writing the power-fail page data in an invalid mode and writing the mark 1 and the mark 2 in an effective mode by using the word writing mode;
2) and if the page is the erasing operation, restoring the page data to the page with the smallest counter in all pages by using a word writing mode, writing the target data of the erasing operation into the power-down page by using the word writing mode, and changing the target page counter into the current largest counter in all pages and adding 1 before erasing.
When the mark 1 is invalid, the page is powered down when data is erased, written or the mark 1 is written, the validity of the data cannot be judged, and if the page data is invalid, the power-off recovery processing is carried out on the invalid data. The operation is as follows:
1) if the page is read, the erasing data of the page is invalid by using a word writing mode, and the word writing marks 1 and 2 are valid;
2) if the operation is an erasing operation, the page is taken as a target page, target data is written into the page by using a word writing mode, and marks 1 and 2 are written to be effective.
Drawings
FIG. 1 is a diagram of a single page NVM data structure of the present invention;
FIG. 2 is a flow chart of single page erase/write according to the present invention;
FIG. 3 is a data structure diagram of the present invention having two sets of data mirror segments;
FIG. 4 is a flow chart of reading data according to the present invention;
FIG. 5 is a flow chart of erasing data according to the present invention;
FIG. 6 shows the data state before erasing a target page according to the present invention;
FIG. 7 shows the data state after erasing a target page according to the present invention.
Detailed Description
The following describes a smart card power-down backup method and a data structure based on writing in further detail with reference to the accompanying drawings and examples. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
A structure diagram of a single-page NVM data structure for power-down backup of a smart card based on word writing is shown in FIG. 1, and includes three parts, namely, page data, a label 1 and a label 2, and the page data includes a counter, in general, the label 1 is the second last word of the whole page, and the label 2 is the first last word of the whole page, so that the sequential programming from front to back during the word writing is facilitated.
Secondly, a single-page erasing flow of the smart card power-down backup method based on word writing, as shown in the attached figure 2, the method comprises the following steps:
s2001, single page erasing operation is started.
S2002, reading the marks 1 and 2 of all the mirror image pages in the plurality of mirror image pages corresponding to the NVM logical page, finding out the target page according to the valid states of the mirror image pages, and performing single erasing operation on the target page by using a whole page erasing mode, wherein both the marks 1 and 2 become invalid (0 xFFFFFFFFFF).
And S2003, organizing data to be written into the target page, and programming the target page word by word from the page head by using a word writing mode, wherein a counter is placed in one word of the data and is written with other data.
S2004, the tag 1 is written as a valid value (0xA55A5AA5) by a word writing method, and the tag 1 is placed in the penultimate word of each page.
S2005, the tag 2 is written as a valid value (0xA55A5AA5) by a word writing method, and the tag 2 is placed in the last to last word of each page.
And S2006, ending the single-page erasing operation.
Third, as shown in fig. 3, the physical data corresponding to the logical segment of the method is divided into two large segments, i.e., an a mirror segment and a B mirror segment, where each page in the two segments corresponds to one another and is backed up by each other, i.e., each NVM logical page corresponds to two physical mirror pages, i.e., a first NVM logical page corresponds to two mirror pages, i.e., an a1 page and a B1 page.
The reading process of the embodiment, as shown in fig. 4, includes the following steps:
s4001, starting data reading.
S4002, reading the mark 1 and the mark 2 in the two mirror pages corresponding to the NVM logical page, if the mark 1 and the mark 2 of the A page and the B page are both valid (0xA55A5AA5), the counters in the two pages are definitely stable and valid, and executing S4006; otherwise, S4003 is executed.
S4003, if one of the a page and the B page has flag 1 valid (0xA55A5AA5) and flag 2 invalid (not 0xA55A5AA5), performing S4004; otherwise, if the flag 1 invalid appears for a certain page, S4005 is executed.
S4004, the page flag 1 is valid (0xA55A5AA5) and flag 2 is invalid (not 0xA55A5AA5), indicating that the page data has been correctly written and stable, the page data is valid. When the page is written with the mark 1 or the mark 2, power failure occurs, or reading instability occurs due to the power failure of the previous mark 2, power failure recovery is carried out, and the unstable state of the page caused by the power failure is eliminated.
S4005, the page flag 1 is invalid (not 0xA55A5AA5), which indicates that the page was erased last time and the validity of the data cannot be judged. When the page is subjected to power failure during erasing and writing data or writing the mark 1, power failure recovery is carried out, and an unstable state of the page caused by power failure is eliminated.
S4006, through the process, if the two pages A and B are both valid pages and the mark 1 and the mark 2 in the two pages are both valid, the counters in the two mirror image pages are directly read, and the page with the largest counter is selected to be directly read.
S4007, ending data reading.
The erasing and writing process of the embodiment, as shown in fig. 5, includes the following steps:
s5001, starting data erasing.
S5002, reading the mark 1 and the mark 2 in the two mirror image pages corresponding to the NVM logical page, if the mark 1 and the mark 2 of the A page and the B page are both valid (0xA55A5AA5), the counters in the two pages are definitely stable and valid, and executing S5005; otherwise, S5003 is executed.
S5003, if a page of pages a and B is marked 1 valid (0xA55A5AA5) and marked 2 invalid (not 0xA55A5AA5), performing S5004; otherwise, flag 1 invalid appears for a page, S5006 is executed.
S5004, the page flag 1 is valid (0xA55A5AA5) and flag 2 is invalid (not 0xA55A5AA5), indicating that the page data has been correctly written and stable, the page data is valid. When the page is written with the mark 1 or the mark 2, power failure occurs, or reading instability occurs due to the power failure of the previous mark 2, power failure recovery is carried out, and the unstable state of the page caused by the power failure is eliminated.
S5005, through the foregoing process, it is ensured that both pages a and B are valid pages, and both the flag 1 and the flag 2 in both pages are valid (0xA55A5AA5), then the counters in the two mirror pages are directly read, and the page with the smallest counter is selected as the erase-write target page.
S5006, when the flag 1 of a certain page is invalid (not 0xA55A5AA5), it indicates that the page is powered down when the data is erased or written or the flag 1 is written previously, and the validity of the page data cannot be determined. (in addition, because of a power failure recovery mechanism in the method, only one page marked with 1 invalidation, namely a data invalidation page, appears at most in a plurality of mirror image pages corresponding to the same NVM logical page.)
S5007, performing erasing operation, which is described in detail in the single-page erasing process.
S5008, ending data erasing.
Sixthly, the power failure recovery flow of the embodiment is shown in the attached figures 6 and 7.
In this embodiment, when both the flag 1 and the flag 2 are valid, they are identified as valid pages and used directly; and when more than one of the mark 1 and the mark 2 is invalid, identifying the page as an invalid page, and performing power failure recovery.
As shown in FIG. 6, before erasing the NVM logical page, tag 1 and tag 2 are both read from page A and page B (0xA55A5AA5), and then the counters of the two pages are read, wherein the counter of page A is 0x02, the counter of page B is 0x01, and the counter of page B is small, so page B is the old page, and page B is selected to be erased. If the erasure is successful, as shown in FIG. 7, the B page counter becomes 0x03, and the B page becomes the new page; and if the power is lost during erasing, performing power loss recovery flow processing during the next reading and writing.
If the A page and the B page are both invalid (not 0xA55A5AA5) and the data of the A page and the B page are not credible during reading and writing, unexpected processing is ensured to occur, and abnormal reading and writing is thrown out. Since page a was not last erased, the page data and tag 1 must be valid stable (0xA55A5AA 5).
Power failure recovery during reading:
if both tag 1 and tag 2 in pages A and B are valid (0xA55A5AA5), both are valid pages, then the counter is read, page B is 0x03 greater than page A0 x02, and page B is identified as the new page.
If the flag 1 of the page B is valid (0xA55A5AA5) and the flag 2 is invalid (not 0xA55A5AA5), the page B is an invalid page, which indicates that the previous erasing flag 1 and the previous flag 2 are powered down or the flag 2 has read instability, but the data and the counter are stable and valid, and if the data of the multiple pages are valid and the flag 2 is invalid, the maximum counter is restored first. And performing power failure recovery on the page B: reading the effective data of the page B into a temporary buffer area, erasing the page A (old page) by using a word writing mode to reduce the risk of continuous outage, adding 1 (namely 0x04) to a counter in the data of the temporary buffer area before erasing, erasing the page A firstly, writing the data of the buffer area into the page A by using the word writing mode, and respectively writing a mark 1 and a mark 2 into the page A by using the word writing mode to be effective (0xA55A5AA 5); and (3) completely clearing 0 (including a counter) from the data in the temporary buffer area, erasing and writing the data in the page B by using a word writing mode, and respectively writing a mark 1 and a mark 2 into the effective (0xA55A5AA5) by using the word writing mode to eliminate the unstable state of the page B caused by power failure.
If the B page tag 1 is invalid (not 0xA55A5AA5), identifying as an invalid page, power loss recovery is performed: and (3) clearing 0 (including a counter) of all page data in the temporary buffer, reinforcing the invalidation of erasable B page data by using a word writing mode, and respectively writing a mark 1 and a mark 2 in a valid mode (0xA55A5AA5) by using the word writing mode to eliminate the unstable state of the B page caused by power failure.
And after power failure recovery, comparing the A page counter with the B page counter, and reading the page with the large counter.
Power failure recovery during erasing:
when erasing the A page or the B page next time, firstly reading the mark 1 and the mark 2 in the two pages, if the mark 1 and the mark 2 are both effective (0xA55A5AA5) and are effective pages, then reading the counter of the two pages, and if the counter of the A page is smaller than the old page, updating the target data to the A page (before erasing, writing the value of the counter in the buffer to A, B and adding 1 to the maximum counter value in the effective pages of the two pages, namely 0x 04).
If the flag 1 of the page B is valid (0xA55A5AA5) and the flag 2 is invalid (not 0xA55A5AA5), the page B is an invalid page, which indicates that the previous erasing flag 1 and the previous flag 2 are powered down or the flag 2 has read instability, but the data and the counter are stable and valid, and if the data of the multiple pages are valid and the flag 2 is invalid, the maximum counter is restored first. And performing power failure recovery on the page B: reading the effective data of the page B into a temporary buffer area, erasing the page A (old page) in order to reduce the risk of continuous outage, adding 1 to a counter in the data of the temporary buffer area (namely 0x04) before erasing, erasing the page A first, writing the data of the buffer area into the page A by using a word writing mode, and respectively writing a mark 1 and a mark 2 into the page A by using the word writing mode (0xA55A5AA 5); after the valid data of the B page is restored to the A page, because the B page is still unstable and the counter of the B page is small as an old page, the target data is updated to the B page, and the unstable state of the B page is eliminated (the value of the counter in the buffer area of the B page is written as A, B, the maximum value of the counter of the two pages is added by 1, namely 0x05 before erasing).
If page B flag 1 is invalid (not 0xA55A5AA5), then it is identified as invalid page and the data validity cannot be determined, the target data is updated to page B, eliminating the unstable state of page B (the value of the counter in the buffer of page B is written to A, B before erasing, the maximum counter value of the two valid pages is added by 1, i.e. 0x 03).
And after power failure recovery, executing target page erasing operation, and erasing the target page in a word writing mode in order to ensure the stability and atomicity of the target page.

Claims (3)

1. A storage device of a smart card power-down backup data structure based on word writing is characterized in that each page of NVM comprises three parts, namely page internal data, a mark 1 and a mark 2, wherein the page internal data comprises user data and a counter of 1 word, the mark 1 and the mark 2 are respectively 1 word, and each logical page of the NVM corresponds to two or more mirror image pages and is backed up with each other; after erasing and writing a single NVM page, when subsequently reading and writing the page, firstly reading the effective states of the mark 1 and the mark 2 of each page in a plurality of mirror image pages of the NVM logical page, and judging whether to carry out power failure recovery; when all the page marks 1 and 2 are valid, the pages are valid pages, and the pages are directly used without power failure recovery; when the mark 1 of a certain page is valid and the mark 2 is invalid, identifying the page as an invalid page, and performing power failure recovery; when a certain page mark 1 is invalid, the page is an invalid page, and power failure recovery is carried out; after power failure recovery, all mirror image pages become effective pages, and if the effective pages are read, the page with the largest counter is selected for reading; and if the operation is erasing operation, selecting the page with the minimum counter for erasing, and changing the target page counter into the maximum counter in all current pages and adding 1 before erasing.
2. A smart card power-down backup method based on word writing, based on the storage device of the smart card power-down backup data structure of claim 1, when NVM pages are erased and written, data, a mark 1 and a mark 2 are sequentially written in a hardware word writing mode after the pages are erased, and in the subsequent use, effective pages are judged according to the effective states of the mark 1 and the mark 2 of each mirror image page, which is characterized by comprising the following steps:
step one, starting single-page erasing;
step two, in a plurality of mirror image pages of the NVM logical page, finding a target page according to the effective states of the mark 1 and the mark 2, and erasing the whole page;
writing the organized data into a target page by using a hardware word writing mode, wherein a counter is placed in one word of the data, and the page counter written at last is ensured to be maximum in all mirror image pages;
writing a mark 1 in a hardware word writing mode to be effective, wherein the mark 1 is one word in the page;
fifthly, writing the mark 2 into the page effectively in a hardware word writing mode, wherein the mark 2 is one word in the page;
and step six, ending the single-page erasing.
3. The method of claim 2, after the single page erasing is finished, the effective data identification and power failure recovery are required to be performed during the subsequent data reading and writing, in a plurality of mirror image pages of the NVM logical page, the effective states of the mark 1 and the mark 2 of each page are read first, whether the power failure recovery is performed or not is judged, and then the reading and writing are performed, wherein:
1) when all the page flags 1 and 2 are valid, identifying as a valid page;
2) when a certain page is marked with a valid 1 and marked with an invalid 2, indicating that the page has power failure when the mark 1 or the mark 2 is written in, or the page has read instability after the mark 2 has power failure, identifying the page as an invalid page, and performing power failure recovery: because the mark 1 is valid, the valid data is restored to other mirror image pages in a hardware word writing mode if the data is valid, and the data invalidity of the page is reinforced and erased in the hardware word writing mode to eliminate the unstable state of the page;
3) when a certain page mark 1 is invalid, indicating that the page has power failure when erasing and writing data or writing the mark 1, identifying the page as an invalid page, and performing power failure recovery: if the data is invalid because the mark 1 is invalid, the invalid page data is reinforced and written in a hardware word writing mode or the invalid page is directly covered by the target data so as to eliminate the unstable state;
4) and after power failure recovery, all pages become effective pages, if the effective pages are read, the page with the largest counter is selected for reading, and if the effective pages are erasing operation, the page with the smallest counter is selected for erasing.
CN201811131296.5A 2018-09-27 2018-09-27 Smart card power-down backup method and data structure based on character writing Active CN109254878B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811131296.5A CN109254878B (en) 2018-09-27 2018-09-27 Smart card power-down backup method and data structure based on character writing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811131296.5A CN109254878B (en) 2018-09-27 2018-09-27 Smart card power-down backup method and data structure based on character writing

Publications (2)

Publication Number Publication Date
CN109254878A CN109254878A (en) 2019-01-22
CN109254878B true CN109254878B (en) 2021-09-17

Family

ID=65047842

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811131296.5A Active CN109254878B (en) 2018-09-27 2018-09-27 Smart card power-down backup method and data structure based on character writing

Country Status (1)

Country Link
CN (1) CN109254878B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110427285B (en) * 2019-08-06 2023-05-09 北京中电华大电子设计有限责任公司 High-performance smart card mirror image protection method
CN113094294B (en) * 2021-04-12 2024-02-13 深圳忆联信息系统有限公司 SSD abnormal power failure processing method, SSD abnormal power failure processing device, computer equipment and storage medium
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
CN114510198B (en) * 2022-02-16 2023-06-30 北京中电华大电子设计有限责任公司 Method for improving erasing and writing efficiency of NVM (non-volatile memory)
CN116501264B (en) * 2023-06-25 2023-09-15 苏州浪潮智能科技有限公司 Data storage method, device, system, equipment and readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002229744A (en) * 2001-01-31 2002-08-16 Mitsubishi Electric Corp Data writing device and data writing method
CN102541690A (en) * 2011-12-23 2012-07-04 北京握奇数据系统有限公司 Intelligent card and method for recovering data
CN102799931A (en) * 2011-11-29 2012-11-28 深圳中科讯联科技有限公司 Data protection method of radio frequency smart card
CN103744746A (en) * 2013-12-30 2014-04-23 北京工业大学 Index-based smart card record backup and recovery method
CN106227680A (en) * 2016-07-26 2016-12-14 成都三零嘉微电子有限公司 A kind of data process and power fail preventing data guard method
CN107957921A (en) * 2017-12-08 2018-04-24 武汉瑞纳捷电子技术有限公司 A kind of intelligent card power failure data guard method of balance abrasion

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002229744A (en) * 2001-01-31 2002-08-16 Mitsubishi Electric Corp Data writing device and data writing method
CN102799931A (en) * 2011-11-29 2012-11-28 深圳中科讯联科技有限公司 Data protection method of radio frequency smart card
CN102541690A (en) * 2011-12-23 2012-07-04 北京握奇数据系统有限公司 Intelligent card and method for recovering data
CN103744746A (en) * 2013-12-30 2014-04-23 北京工业大学 Index-based smart card record backup and recovery method
CN106227680A (en) * 2016-07-26 2016-12-14 成都三零嘉微电子有限公司 A kind of data process and power fail preventing data guard method
CN107957921A (en) * 2017-12-08 2018-04-24 武汉瑞纳捷电子技术有限公司 A kind of intelligent card power failure data guard method of balance abrasion

Also Published As

Publication number Publication date
CN109254878A (en) 2019-01-22

Similar Documents

Publication Publication Date Title
CN109254878B (en) Smart card power-down backup method and data structure based on character writing
US9612954B2 (en) Recovery for non-volatile memory after power loss
CN109343790B (en) Data storage method based on NAND FLASH, terminal equipment and storage medium
US7765426B2 (en) Emerging bad block detection
US7694094B2 (en) Transaction method for managing the storing of persistent data in a transaction stack
EP2294510B1 (en) Method and apparatus for error correction according to erase counts of a solid-state memory
US7639537B2 (en) Method for writing data in a non volatile memory unit
CN102609334B (en) Nonvolatile flash memory is wiped abnormal memory block restorative procedure and device
US7725646B2 (en) Method of using a flash memory for a circular buffer
US20060107130A1 (en) System and method of reading non-volatile computer memory
CN106227680B (en) A kind of data processing and power fail preventing data guard method
CN102063380B (en) Method and device for writing data in non-volatile memory
CN110427285B (en) High-performance smart card mirror image protection method
CN104156174A (en) Strip based solid-state drive RAID (redundant array of independent disks) realizing method and device
CN111045870B (en) Method, device and medium for saving and restoring metadata
CN109947594B (en) Data backup method and device and data recovery method and device
CN107918524A (en) Data storage device and data maintenance method
CN112100184A (en) Vehicle total mileage data storage method and computer storage medium
CN107992268B (en) Bad block marking method and related device
CN111737058B (en) IC card and anti-power-down data backup method or data recovery method thereof
CN111427726B (en) IC card and anti-power-down data backup method or data recovery method thereof
CN113190182A (en) Management method for data storage in Flash
CN100442317C (en) Tax controlled cash register
CN116185563B (en) Software simulation algorithm based on vehicle-gauge microcontroller data flash memory
US10528348B2 (en) Data management method for storage media

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