CN111913890B - Random read-write method of nonvolatile memory based on security module - Google Patents
Random read-write method of nonvolatile memory based on security module Download PDFInfo
- Publication number
- CN111913890B CN111913890B CN202010812540.5A CN202010812540A CN111913890B CN 111913890 B CN111913890 B CN 111913890B CN 202010812540 A CN202010812540 A CN 202010812540A CN 111913890 B CN111913890 B CN 111913890B
- Authority
- CN
- China
- Prior art keywords
- mapping table
- data
- block
- address
- page
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 24
- 238000013507 mapping Methods 0.000 claims abstract description 60
- 238000006243 chemical reaction Methods 0.000 claims description 3
- 230000001960 triggered effect Effects 0.000 abstract 1
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 1
- 230000002411 adverse Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000013021 overheating Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0238—Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
- G06F12/0246—Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/10—Providing a specific technical effect
- G06F2212/1032—Reliability improvement, data loss prevention, degraded operation etc
- G06F2212/1036—Life time enhancement
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/10—Providing a specific technical effect
- G06F2212/1041—Resource optimization
- G06F2212/1044—Space efficiency improvement
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE 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/00—Energy 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)
- Techniques For Improving Reliability Of Storages (AREA)
Abstract
The invention discloses a random read-write method of a nonvolatile memory based on a security module, and relates to the technical field of data read-write; the method comprises the steps of firstly, automatically dividing Flash into N blocks by taking a page as a size, establishing a storage area mapping table, converting a target address to be written into a random actual address to be written, converting the target address into a corresponding block address through an incoming target address when Flash writing operation is triggered each time, randomly searching an idle block in the storage area mapping table, reading data written last time through a mapping table relation, judging whether updating is needed, if the data needs to be updated, randomly searching the idle data block, writing the data, and updating the mapping table. The method can lead certain high-frequency erasing areas to be used in a scattered way, improves the service life of Flash, does not need to open up an area for backing up remapped data, improves the service life of a memory and reduces the cost of storage space of Flash.
Description
Technical Field
The invention relates to the technical field of data reading and writing, in particular to a nonvolatile memory randomization reading and writing method based on a security module.
Background
The nonvolatile memory (hereinafter referred to as Flash) in the security module product is used for storing permanent data, such as files, keys, certificates, and the like. However, as the Flash frequently erases and writes more and more application scenes, the number of times of erasing and writing at the same position of the traditional Flash is about 10 ten thousand times, if the Flash reads and writes wrongly, the information such as file data, secret keys and the like can be damaged, and great adverse effects are caused to users.
In the prior art, the method for reading Flash mainly divides the storage space of Flash into a plurality of storage subspaces with the same size, and then divides each storage subspace into a plurality of storage blocks with the same size, wherein each storage block corresponds to one logical address and one physical address. Because the logic address and the physical address have a unique mapping relation, when reading and writing are carried out, the accumulated read-write operation times of each storage subspace are recorded; when the accumulated number of write operations of any one of the plurality of storage subspaces reaches a predetermined remapping rate, mapping the logical address of the storage subspace to a remapped physical address. This method can cause a specific memory module to read and write continuously in the process of reading the memory content, resulting in local overheating of data, and can reduce the life and reliability of the memory module.
The existing nonvolatile memory life-span enhancement scheme is to adopt a fixed mapping mode to carry out bad block data backup or map to a new memory block, and because data backup is needed, a part of area is needed to be occupied in advance for data backup, so that the use needs to increase the expenditure of a larger memory unit, and the actual Flash memory space size of a product is reduced.
Therefore, it is needed to find a method for improving the service life of Flash.
Disclosure of Invention
The invention aims to provide a random read-write method of a nonvolatile memory based on a security module, thereby solving the problems in the prior art.
In order to achieve the above purpose, the technical scheme adopted by the invention is as follows:
A random read-write method of a nonvolatile memory based on a security module comprises the following steps:
S1, automatically dividing a storage space of a nonvolatile memory into N data blocks with the same size, and simultaneously establishing a storage area mapping table;
s2, converting a target address of data to be written into a corresponding data block address when the nonvolatile memory is read and written;
S3, randomly searching idle data blocks through a storage area mapping table;
s4, judging whether the idle data block needs to update the actual mapping address of the last written data or not according to the corresponding relation on the mapping table of the storage area; if the update is determined to be needed, repeating the step S3 to search for the idle data block again; if the data is not needed to be updated, the data is directly written into the idle data block, the actual mapping address is stored into the target data block, and the mapping relation of the mapping table is updated.
Preferably, the size of the data block in step S1 is in page size, n=total space size/page size, and typically, each page size is 512 bytes.
Preferably, the memory area mapping table has N tables, which are sequentially 0 pages, 1 page, … pages, N-1 pages and N pages;
the address conversion process using the mapping table structure specifically includes:
first, the target mapping block number to be written is determined: mapping table block number Y = target address/page size; target block number = Y;
generating a random number X, namely converting the actual page address into an actual address to be written randomly, wherein the actual page address is X pages: the actual address is written into the target block number Y.
Preferably, the method for judging whether the data block is idle in step S3 is as follows:
The initial value in the mapping table block number corresponding to each data block is 0, whether the corresponding data block is idle or not is judged according to the highest byte identification of all bits in the mapping table block number, and when the highest byte identification is 1, the data block corresponding to the mapping table block number is indicated to have effective data; and if the highest byte mark is 0, indicating that the data block corresponding to the mapping table block number is idle.
The beneficial effects of the invention are as follows:
The invention provides a random read-write method of a nonvolatile memory based on a security module, which can be used for randomly mapping and writing the data written into the nonvolatile memory in a security module product.
Drawings
FIG. 1 is a flow chart of a random access method for nonvolatile memory based on a security module according to embodiment 1;
fig. 2 is a memory area map structure employed in embodiment 1.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the detailed description is presented by way of example only and is not intended to limit the invention.
Examples
In this embodiment, a random read-write method of a nonvolatile memory based on a security module is provided, as shown in fig. 1, including the following steps:
S1, automatically dividing a storage space of a nonvolatile memory into N data blocks with the same size, and simultaneously establishing a storage area mapping table;
s2, converting a target address of data to be written into a corresponding data block address when the nonvolatile memory is read and written;
S3, randomly searching idle data blocks through a storage area mapping table;
s4, judging whether the idle data block needs to update the actual mapping address of the last written data or not according to the corresponding relation on the mapping table of the storage area; if the update is determined to be needed, repeating the step S3 to search for the idle data block again; if the data is not needed to be updated, the data is directly written into the idle data block, the actual mapping address is stored into the target data block, and the mapping relation of the mapping table is updated.
The size of the data block in step S1 in this embodiment is a page size, n=total space size/page size, and typically, each page size is 512 bytes.
In this embodiment, the memory mapping table has N tables, which are sequentially 0 pages, 1 page, … pages, N-1 pages, and N pages, as shown in fig. 2, and each table is a data block. In fig. 2, the initial value of each data block is all 0, each square is 2 bytes and 16 bits, when judging whether the data block is idle, the highest byte identification of all bits in the data block number of the mapping table is used for judging whether the corresponding data block is idle, and when the highest byte identification is 1, the data block corresponding to the block number of the mapping table is indicated to have valid data; if the highest byte mark is 0, it indicates that the data block corresponding to the mapping table block number is idle, and the following bit mark data marks the actual mapping address.
It should be noted that, in this embodiment, the actual block address relationship for converting the target address into random to be written is: mapping table block number = target address/page size, the value in the mapping table block number is the block address actually to be written after conversion. For example page 3 data address 48640, indicating that destination address 2048 maps to real address 15872. The forming process is as follows: when the Flash total space is 512K and the page size is 512 bytes, then n=1024, 5 bytes are to be written to the target address 2048, and then the mapping table block number is 2048/512=4, i.e. page 3. According to the generated random number being 31, the actual data storage address is 31 th page, i.e., 31×512 (page size) = 15872 addresses, and the actual mapping address is stored in the 4 th data block lattice (page 3).
By adopting the technical scheme disclosed by the invention, the following beneficial effects are obtained:
The invention provides a random read-write method of a nonvolatile memory based on a security module, which can be used for randomly mapping and writing the data written into the nonvolatile memory in a security module product.
The foregoing is merely a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention, which is also intended to be covered by the present invention.
Claims (4)
1. A random read-write method of a nonvolatile memory based on a security module is characterized by comprising the following steps:
S1, automatically dividing a storage space of a nonvolatile memory into N data blocks with the same size, and simultaneously establishing a storage area mapping table;
s2, converting a target address of data to be written into a corresponding data block address when the nonvolatile memory is read and written;
S3, randomly searching idle data blocks through a storage area mapping table;
S4, judging whether the idle data block needs to update the actual mapping address of the last written data or not according to the corresponding relation on the mapping table of the storage area; if the update is determined to be needed, repeating the step S3 to search for the idle data block again; if the data is not needed to be updated, the data is directly written into the idle data block, the actual mapping address is stored into the target mapping table block, and the mapping relation of the mapping table is updated;
the storage area mapping table is provided with N tables, namely 0 page, 1 page, … page, N-1 page and N page in sequence; each table is a mapping table block.
2. The randomized read-write method according to claim 1, wherein the size of the data block in step S1 is a page size, N = space total size/page size.
3. The randomized read-write method according to claim 1, wherein,
The address conversion process using the memory area mapping table is specifically:
first, the block number of the target mapping table to be written is determined: mapping table block number Y = target address/page size; target mapping table block number = Y;
Generating a random number X, namely converting the actual page address into an actual address to be written randomly, wherein the actual page address is X pages: x is the page size.
4. The method of claim 1, wherein step S3 is specifically that the initial value of the mapping table block corresponding to each data block is all 0, the highest byte identifier of all bits in the mapping table block is used to determine whether the data block corresponding to the mapping table block is idle, and when the highest byte identifier is 1
When the mapping table block is used, the data block corresponding to the mapping table block is indicated to have effective data; if the highest byte identification is 0,
And indicating that the data block corresponding to the mapping table block is idle.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010812540.5A CN111913890B (en) | 2020-08-13 | 2020-08-13 | Random read-write method of nonvolatile memory based on security module |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010812540.5A CN111913890B (en) | 2020-08-13 | 2020-08-13 | Random read-write method of nonvolatile memory based on security module |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111913890A CN111913890A (en) | 2020-11-10 |
CN111913890B true CN111913890B (en) | 2024-06-11 |
Family
ID=73284500
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010812540.5A Active CN111913890B (en) | 2020-08-13 | 2020-08-13 | Random read-write method of nonvolatile memory based on security module |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111913890B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113127377B (en) * | 2021-04-08 | 2022-11-25 | 武汉导航与位置服务工业技术研究院有限责任公司 | Wear leveling method for writing and erasing of nonvolatile memory device |
CN113450863A (en) * | 2021-07-09 | 2021-09-28 | 上海交通大学 | Method for resisting hard failure error of resistive symmetric memory |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103456360A (en) * | 2013-09-13 | 2013-12-18 | 北京昆腾微电子有限公司 | Management method and device for nonvolatile memory (NVM) |
CN103729303A (en) * | 2014-01-20 | 2014-04-16 | 飞天诚信科技股份有限公司 | Data writing and data reading methods of Flash |
CN109040334A (en) * | 2018-07-12 | 2018-12-18 | 山东师范大学 | Static Intranet mapping method, external network server, Intranet communication equipment and system |
CN110515552A (en) * | 2019-08-22 | 2019-11-29 | 深圳市得一微电子有限责任公司 | A kind of method and system of storage device data no write de-lay |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10810137B2 (en) * | 2017-02-27 | 2020-10-20 | Red Hat, Inc. | Physical address randomization for secure encrypted memory |
-
2020
- 2020-08-13 CN CN202010812540.5A patent/CN111913890B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103456360A (en) * | 2013-09-13 | 2013-12-18 | 北京昆腾微电子有限公司 | Management method and device for nonvolatile memory (NVM) |
CN103729303A (en) * | 2014-01-20 | 2014-04-16 | 飞天诚信科技股份有限公司 | Data writing and data reading methods of Flash |
CN109040334A (en) * | 2018-07-12 | 2018-12-18 | 山东师范大学 | Static Intranet mapping method, external network server, Intranet communication equipment and system |
CN110515552A (en) * | 2019-08-22 | 2019-11-29 | 深圳市得一微电子有限责任公司 | A kind of method and system of storage device data no write de-lay |
Non-Patent Citations (2)
Title |
---|
Quail: Using NVM write monitor to enable transparent wear-leveling;Kaixin Huang 等;Journal of Systems Architecture;第102卷;全文 * |
一种基于代数映射的相变内存矩阵磨损均衡方法;杜雨阳 等;计算机研究与发展;第49卷(第12期);2713-2720 * |
Also Published As
Publication number | Publication date |
---|---|
CN111913890A (en) | 2020-11-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7702844B2 (en) | Address mapping method and mapping information managing method for flash memory, and flash memory using the same | |
US7711892B2 (en) | Flash memory allocation for improved performance and endurance | |
JP4832521B2 (en) | Data management method in flash memory media | |
US7526600B2 (en) | Data management device and method for flash memory | |
KR100608602B1 (en) | Flash memory, Mapping controlling apparatus and method for the same | |
JP2009525511A (en) | Multistage error correction method and apparatus | |
CN111913890B (en) | Random read-write method of nonvolatile memory based on security module | |
CN102890656A (en) | Method for improving service life of FLASH | |
US20120246394A1 (en) | Flash Memory Device and Data Writing Method for a Flash Memory | |
US7836242B2 (en) | Method for page random write and read in blocks of flash memory | |
US20090319721A1 (en) | Flash memory apparatus and method for operating the same | |
CN107045423B (en) | Memory device and data access method thereof | |
CN112596668A (en) | Bad block processing method and system for memory | |
US20070005929A1 (en) | Method, system, and article of manufacture for sector mapping in a flash device | |
WO2009045010A2 (en) | Flash memory mapping management method | |
KR100533683B1 (en) | Data managing device and method for flash memory | |
CN105653466A (en) | Data storage device and flash memory control method | |
KR100977709B1 (en) | A flash memory storage device and a manage method using the same | |
CN101183336A (en) | Method using nonvolatile semiconductor memory performance-test data and electronic device thereof | |
US7206893B2 (en) | Linking method under mother and child block architecture for building check area and logic page of the child block | |
US20090055574A1 (en) | NAND Flash Memory Device And Related Method Thereof | |
US20090034333A1 (en) | Method for Managing a Non-Volatile Memory In a Smart Card | |
CN106484630A (en) | The Memory Controller of the access method of flash memory and correlation and electronic installation | |
US6845061B2 (en) | Method for quickly detecting the state of a nonvolatile storage medium | |
JP2005092678A (en) | Semiconductor memory card and method for deleting data in nonvolatile memory |
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 |