CN117453124A - Data reading and writing method and device and embedded equipment - Google Patents

Data reading and writing method and device and embedded equipment Download PDF

Info

Publication number
CN117453124A
CN117453124A CN202311212817.0A CN202311212817A CN117453124A CN 117453124 A CN117453124 A CN 117453124A CN 202311212817 A CN202311212817 A CN 202311212817A CN 117453124 A CN117453124 A CN 117453124A
Authority
CN
China
Prior art keywords
data
target
sectors
writing
memory
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.)
Pending
Application number
CN202311212817.0A
Other languages
Chinese (zh)
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.)
Sungrow Power Supply Co Ltd
Original Assignee
Sungrow Power Supply 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 Sungrow Power Supply Co Ltd filed Critical Sungrow Power Supply Co Ltd
Priority to CN202311212817.0A priority Critical patent/CN117453124A/en
Publication of CN117453124A publication Critical patent/CN117453124A/en
Pending legal-status Critical Current

Links

Abstract

The application discloses a data reading and writing method, a data reading and writing device and embedded equipment, and belongs to the technical field of data processing. The data reading and writing method comprises the following steps: dividing at least one storage space from a target memory under the condition that the writing frequency of target data is larger than a target frequency threshold value, wherein the storage space comprises at least one sector; the target memory is NANDFLASH; writing the target data into a target sector of the plurality of sectors based on an arrangement order of the plurality of sectors; and reading the target data from the plurality of sectors based on the arrangement order. The data read-write method expands the available capacity of read-write data, realizes space exchange time, reduces memory loss caused by erasure, thereby prolonging the service life of a target memory, indirectly prolonging the service life of a product, avoiding after-sale reworking loss caused by the loss of the target memory, and reducing the resource loss and hardware cost of the singlechip.

Description

Data reading and writing method and device and embedded equipment
Technical Field
The application belongs to the technical field of data processing, and particularly relates to a data reading and writing method, a data reading and writing device and embedded equipment.
Background
When processing data with a high write frequency, a large memory is required to perform processing such as reading and writing on the data. In the related art, a method for jointly reading and writing data based on an electrified erasable programmable read-only memory (Electrically Erasable Programmable read only memory, EEPROM) and NANDFLASH exists, the service life of the NANDFLASH is prolonged by using the EEPROM, but the cost of the EEPROM is higher, the capacity is smaller, the hardware cost in application is higher, and the resource loss is caused to a singlechip by using the EEPROM; and for data with higher writing frequency, the data in NANDFLASH needs to be erased for many times in the writing process, and the resource loss of the singlechip is larger.
Disclosure of Invention
The present application aims to solve at least one of the technical problems existing in the prior art. Therefore, the data read-write method, the device and the embedded equipment provided by the application expand the available capacity of read-write data, realize space exchange time, reduce memory loss caused by erasure, thereby prolonging the service life of a target memory, indirectly prolonging the service life of a product, and avoiding after-sale reworking loss caused by the loss of the target memory, so that the resource loss and hardware cost of a singlechip are reduced.
In a first aspect, the present application provides a data reading and writing method, including:
dividing at least one storage space from a target memory under the condition that the writing frequency of target data is larger than a target frequency threshold value, wherein the storage space comprises at least one sector;
writing the target data into a target sector of the plurality of sectors based on an arrangement order of the plurality of sectors;
and reading the target data from the plurality of sectors based on the arrangement order.
According to the data read-write method provided by the embodiment of the application, the data with higher write-in frequency is divided into at least one storage area from the target memory to perform read-write operation, so that the available capacity of the read-write data is enlarged, the plurality of storage areas can be uniformly erased after the data is written into the plurality of storage areas, the target data is written in continuously, the erasing frequency of the memory is reduced, the space-time conversion is realized, the memory loss caused by erasing is reduced, the service life of the target memory is prolonged, the service life of a product is prolonged indirectly, the after-sale reworking loss caused by the loss of the target memory is avoided, and the resource loss and the hardware cost of the singlechip are reduced.
The data read-write method of an embodiment of the present application, where the dividing the target memory into at least one storage space includes:
the at least one storage space is divided based on at least one of a service life of an embedded device, a specification life of the target memory, the writing frequency of the target data, and a data capacity, and the embedded device is provided with the target memory.
According to an embodiment of the present application, the method for data reading and writing is based on at least one of a service life of an embedded device, a specification life of the target memory, the writing frequency of the target data, and a data capacity, and the dividing to obtain the at least one storage space includes:
determining a target number based on a lifetime of the embedded device, a specification lifetime of the target memory, and the write frequency of the target data;
and dividing the target memory to obtain the storage space with the target quantity.
The method for writing and reading data according to one embodiment of the present application, wherein determining the target number based on the service life of the embedded device, the specification life of the target memory, and the writing frequency of the target data includes:
based on the writing frequency and the service life, acquiring the total writing frequency of the embedded equipment in the service life;
the target number is determined based on a ratio of the total write frequency and the specification lifetime.
According to an embodiment of the present application, the data reading and writing method is based on at least one of a service life of an embedded device, a specification life of the target memory, the writing frequency of the target data, and a data capacity, and the at least one storage space is obtained by dividing the data, and the method further includes:
determining a target number based on a ratio of the required capacity to the data capacity;
and dividing the target memory to obtain the storage space with the target quantity.
According to the data reading and writing method of the embodiment of the application, the target frequency threshold value is that the target data is written into the target memory 10 times per minute.
The data reading and writing method according to one embodiment of the present application, based on an arrangement sequence of a plurality of sectors, writes the target data into a target sector of the plurality of sectors, includes:
based on the arrangement sequence, sequentially carrying out data verification on the plurality of sectors from front to back;
and writing the target data in the target sector in the case that the target sector in the plurality of sectors fails the data verification.
The data reading and writing method according to one embodiment of the present application, based on the arrangement order, reads the target data from the plurality of sectors, includes:
based on the arrangement sequence, sequentially carrying out data verification on the plurality of sectors from back to front;
and in the case that a target sector in the plurality of sectors passes the data verification, reading the target data from the target sector.
The data reading and writing method of an embodiment of the present application sequentially performs data verification on the plurality of sectors, including:
the plurality of sectors are data checked based on at least one of a data content length, a data area written state, and a CRC16 check.
The data read-write method according to one embodiment of the present application, before the writing of the target data to the target sector of the plurality of sectors, further includes:
and performing an erasing operation on the plurality of sectors.
In a second aspect, the present application provides a data read-write apparatus, including:
the first processing module is used for dividing at least one storage space from the target memory under the condition that the writing frequency of the target data is larger than the target frequency threshold value, wherein the storage space comprises at least one sector; the target memory is NANDFLASH;
a second processing module for writing the target data into a target sector among the plurality of sectors based on an arrangement order of the plurality of sectors;
and the third processing module is used for reading the target data from the plurality of sectors based on the arrangement sequence.
According to the data read-write device provided by the embodiment of the application, through dividing at least one storage area from the target memory for read-write operation on data with higher write frequency, the available capacity of read-write data is enlarged, and the plurality of storage areas can be uniformly erased after the data are written into the plurality of storage areas, so that the target data are written in continuously, the erasing frequency of the memory is reduced, the space exchange time is shortened, the memory loss caused by erasing is reduced, the service life of the target memory is prolonged, the service life of a product is prolonged indirectly, the after-sale reworking loss caused by the loss of the target memory is avoided, and the resource loss and the hardware cost of the singlechip are reduced.
In a third aspect, the present application provides an embedded device, comprising:
a target memory;
the data read-write device of the second aspect, wherein the data read-write device is electrically connected to the target memory.
According to the embedded equipment provided by the embodiment of the application, the data read-write device is arranged in the embedded equipment and is electrically connected with the target memory, so that a plurality of storage spaces can be divided for data with higher write-in frequency, and the data can be alternately read-written based on the plurality of storage spaces, so that the service life of the target memory is prolonged, the service life of the embedded equipment is prolonged indirectly, and the hardware cost is reduced.
In a fourth aspect, the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the data read-write method according to the first aspect when executing the computer program.
In a fifth aspect, the present application provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a data read-write method as described in the first aspect above.
In a sixth aspect, the present application provides a computer program product comprising a computer program which, when executed by a processor, implements a data read-write method as described in the first aspect above.
The above technical solutions in the embodiments of the present application have at least one of the following technical effects:
by dividing at least one storage area from a target memory for reading and writing data with higher writing frequency, the available capacity of the read-write data is enlarged, the plurality of storage areas can be uniformly erased after the data are written into the plurality of storage areas, the target data are written in continuously, the erasing frequency of the memory is reduced, the space exchange time is realized, the memory loss caused by erasing is reduced, the service life of the target memory is prolonged, the service life of a product is prolonged indirectly, the after-sale reworking loss caused by the loss of the target memory is avoided, and the resource loss and the hardware cost of the singlechip are reduced.
Further, at least one storage space is obtained through at least one of service life of the embedded device, specification service life of the target memory, writing frequency of target data and data capacity, a division mode can be preferentially selected based on actual conditions such as actual service life of the device, so that the storage space is divided for data with higher writing frequency, service life of the target memory is prolonged, service life of the embedded device is prolonged indirectly, and hardware cost is reduced.
Furthermore, before the read-write operation is performed on the target data, data verification is performed on a plurality of sectors, the validity of the area data can be determined through a verification algorithm, the reliability of the sector for storing the data is improved, and errors possibly occurring after data transmission or storage are avoided.
Additional aspects and advantages of the application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application.
Drawings
The foregoing and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, wherein:
fig. 1 is a schematic flow chart of a data read-write method provided in an embodiment of the present application;
fig. 2 is a schematic diagram of a data read-write method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a data read-write device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Technical solutions in the embodiments of the present application will be clearly described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application are within the scope of the protection of the present application.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, as appropriate, such that embodiments of the present application may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of a type and not limited to the number of objects, e.g., the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
The following describes a data reading and writing method according to an embodiment of the present application with reference to fig. 1 to 2.
It should be noted that, the execution body of the data read-write method may be an embedded device, or may be a server electrically connected to the embedded device, or may be a data read-write device disposed in the embedded device, or may also be a user terminal communicatively connected to the embedded device, including, but not limited to, a mobile terminal and a non-mobile terminal.
For example, mobile terminals include, but are not limited to, cell phones, PDA smart terminals, tablet computers, vehicle-mounted smart terminals, and the like; non-mobile terminals include, but are not limited to, PC-side and the like.
As shown in fig. 1, the data read-write method includes: step 110, step 120 and step 130.
The data read-write method can perform read-write operation on data with larger write frequency, can perform read-write operation on data with conventional write frequency, and the like, can select based on user requirements, and is not limited in the application.
Step 110, dividing at least one storage space from a target memory when the writing frequency of the target data is greater than the target frequency threshold, wherein the storage space comprises at least one sector; the target memory is NANDFLASH.
In this step, the target memory may be NAND flash memory (NANDFLASH).
The NANDFLASH has larger capacity and higher rewriting speed, and is suitable for storing a large amount of data.
The target memory can be arranged in the embedded device, wherein the embedded device can be a digital camera, an MP3 walkman, a USB flash disk and the like, the embedded device can also be an embedded single chip microcomputer, and the target memory can be a memory card in the digital camera or a memory card in the MP3 walkman and the like.
The target data is the data that needs to be written into the target memory.
The write frequency of the target data is higher, and the write frequency of the target frequency is greater than the target frequency threshold.
For example, the target data may be a power value.
The target data may be data that needs to be refreshed and written to the target memory in real time per unit time during operation of the embedded device.
The write frequency of the target data may be a frequency at which the target data needs to be written to the target memory per unit time.
For example, the write frequency may be a frequency at which target data needs to be written to the target memory every day, or may be a frequency at which target data needs to be written to the target memory every minute.
In some embodiments, the target frequency threshold may be 10 writes of target data to the target memory per minute.
In this embodiment, in the case where the target data needs to be written to the target memory more frequently than 10 times per minute, the writing frequency of the target data can be regarded as high.
In some embodiments, the target frequency threshold may also be 1000 writes of target data to the target memory per day.
Of course, in other embodiments, the target frequency threshold may be set to other values, which may be set based on actual requirements, and the application is not limited herein.
In the actual execution process, the target data can be an electric quantity value, the electric energy needs to be refreshed in real time, power failure is saved, and the electric energy needs to be refreshed in real time according to the last electric quantity value after power is on.
In the case of circularly storing 1000 pieces of recordable data, in order to record the position of the written data, 1 piece of data needs to be stored, and then the position of the written data is updated;
in the case of 1000 pieces of data being stored, the write variable is written 1000 times, and it is understood that the number of times of writing is increased by 1000 per cycle, and in the case of 10 ten thousand times of life of the target memory, the target memory can be cycled 100 times.
For data with higher writing frequency, at least one storage space can be divided from the target memory.
Each memory space includes at least one sector.
The sector is a read-write unit of the hard disk or the magnetic disk, the sector is a minimum storage unit of the hard disk or the magnetic disk, the size of the sector can be 512Bytes or can be 4KB, and the size of the sector can be set based on the hard disk or the magnetic disk, which is not limited in the application.
For example, in the case where the data size is 8KB and the sector size is 4KB, two sectors may be provided in the storage space for storing data.
And the at least one storage space obtained by dividing the target memory is used for performing read-write operation on the target data.
The at least one storage space can perform read-write operation on the target data so as to prolong the service life of the embedded device.
In some embodiments, step 110 may include:
the embedded device is provided with a target memory based on at least one of a service life of the embedded device, a specification life of the target memory, a writing frequency of target data, and a data capacity.
In this embodiment, the lifetime of the embedded device is the period of time from when the embedded device is new until it is completely unusable.
The specification lifetime of the target memory may be the read-write lifetime of the target memory, for example, the specification lifetime of the target memory may be 10 tens of thousands times, i.e., the target memory will be scrapped after 10 tens of thousands of times of read-write of the target memory.
The data capacity may be used to characterize the data size, for example, the data capacity may be 128Bytes.
The at least one storage space may be divided based on at least one of a lifetime of the embedded device, a specification lifetime of the target memory, a writing frequency of the target data, and a data capacity.
The manner of determining the at least one memory space is described in detail below based on two ways, respectively.
Firstly, obtaining at least one storage space based on the service life of the embedded equipment, the specification life of the target memory and the writing frequency division of the target data
In some embodiments, the partitioning into at least one storage space based on at least one of a lifetime of the embedded device, a specification lifetime of the target memory, a write frequency of the target data, and a data capacity may include:
determining a target number based on a service life of the embedded device, a specification life of the target memory, and a write frequency of the target data;
and dividing the target memory into a target amount of memory space.
In this embodiment, the target number may be used to characterize the number of at least one storage space.
Based on the lifetime, the specification lifetime and the writing frequency, the number of at least one storage space, i.e. the target number, may be determined.
The target amount of memory space may be partitioned from the target memory.
In some embodiments, determining the target number based on the lifetime of the embedded device, the specification lifetime of the target memory, and the write frequency of the target data may include:
based on the writing frequency and the service life, acquiring the total writing frequency of the embedded equipment in the service life;
the target number is determined based on the ratio of the total write frequency to the specification lifetime.
In this embodiment, the total write frequency is all write frequencies of the embedded device over the lifetime.
For example, the write frequency may be 128 times per day, the lifetime may be 15 years, and based on the write frequency and lifetime, the write frequency within one year for the embedded device may be obtained as: 128 x 365 = 46720 (times);
the total write frequency for the embedded device over 15 years is: 15 x 46720= 700800 (times).
Based on the ratio of the total write frequency to the specification lifetime, the target number may be determined.
For example, the target memory may have a specification lifetime of 10 tens of thousands, and the target number may be: n=700000/100000=7.008, N may be 8, i.e. 8 storage spaces may be divided from the target memory.
Secondly, obtaining at least one storage space based on data capacity division
In some implementations, the partitioning into at least one storage space based on at least one of a lifetime of the embedded device, a specification lifetime of the target memory, a write frequency of the target data, and a data capacity may further include:
determining a target number based on a ratio of the required capacity to the data capacity;
and dividing the target memory into a target amount of memory space.
In this embodiment, the required capacity is the capacity that the at least one storage space is required to have.
The target number may be based on a ratio of the required capacity to the data capacity.
For example, where the required capacity is 4096Bytes and the data capacity is 128Bytes, the target number may be: n=4096/128=32.
In an application, 32 storage spaces may be partitioned from the target memory.
According to the data read-write method provided by the embodiment of the application, the at least one storage space is obtained through dividing at least one of the service life of the embedded device, the specification service life of the target memory, the writing frequency of the target data and the data capacity, and the dividing mode can be preferentially selected based on actual conditions such as the service life of the actual device, so that the storage space is divided for the data with higher writing frequency, the service life of the target memory is prolonged, the service life of the embedded device is prolonged indirectly, and the hardware cost is reduced.
Step 120, writing the target data into the target sector of the plurality of sectors based on the arrangement order of the plurality of sectors.
In this step, the plurality of sectors may be at least one sector in one storage space, and the plurality of sectors may also be all sectors in the at least one storage space.
The arrangement sequence of the plurality of sectors may be customized based on a user, and as shown in fig. 2, the arrangement sequence of the plurality of sectors may be 1# sector to n # sector.
The arrangement order of the plurality of sectors may be determined based on the arrangement order of the at least one memory space.
In the case of writing data, the data needs to be written in a plurality of sectors in sequence.
The target sector may include one sector, and the target sector may further include a plurality of sectors, and may be customized based on the size of the target data, which is not limited in this application.
For example, in the case where data is larger than a single sector capacity, data needs to be written to a plurality of sectors, and the target sector may be a plurality of sectors.
The target sector may be a sector to which data is not written.
Step 130, reading target data from the plurality of sectors based on the arrangement order.
In this step, after the target data is written into the target memory, the target data may be sequentially read from the plurality of sectors based on the arrangement order of the plurality of sectors.
In the actual execution process, for the target data with higher writing frequency, at least one storage space can be obtained from the target memory, and the at least one storage space is used for performing read-write operation on the target data.
Then writing target data into target sectors in the plurality of sectors based on the arrangement sequence of the plurality of sectors;
after writing the target data into the target memory, the target data may be sequentially read from the plurality of sectors based on the arrangement order of the plurality of sectors.
The inventor finds that in the research and development process, a method for jointly reading and writing data based on a charged erasable programmable read-only memory (Electrically Erasable Programmable read only memory, EEPROM) and a memory exists in the related technology, the service life of the memory is prolonged by using the EEPROM, but the cost of the EEPROM is higher, the capacity is smaller, the hardware cost in application is higher, and the resource loss is caused to a singlechip by using the EEPROM;
and the NANDFLASH needs to be erased before the data is written into the NANDFLASH, and the data in the NANDFLASH needs to be erased for many times in the writing process for the data with higher writing frequency, so that the resource loss of the singlechip is larger.
In the application, the data with higher writing frequency is divided into at least one storage area from the NANDFLASH for reading and writing operation, the available capacity of the read-write data is enlarged, the storage areas can be uniformly erased after the data are written into the storage areas, the target data are written in continuously, the erasing frequency of the NANDFLASH is reduced, the space exchange time is shortened, the memory loss caused by erasing is shortened, the service life of the target memory is prolonged, the service life of a product is prolonged indirectly, the after-sale reworking loss caused by the NANDFLASH is avoided, and the resource loss and the hardware cost of the singlechip are reduced.
According to the data read-write method provided by the embodiment of the application, the data with higher write-in frequency is divided into at least one storage area from the target memory to perform read-write operation, so that the available capacity of the read-write data is enlarged, the plurality of storage areas can be uniformly erased after the data is written into the plurality of storage areas, the target data is written in continuously, the erasing frequency of the memory is reduced, the space-time conversion is realized, the memory loss caused by erasing is reduced, the service life of the target memory is prolonged, the service life of a product is prolonged indirectly, the after-sale reworking loss caused by the loss of the target memory is avoided, and the resource loss and the hardware cost of the singlechip are reduced.
In some embodiments, prior to step 120, the data read-write method may include:
an erase operation is performed on a plurality of sectors.
In this embodiment, the plurality of sectors may be erased before writing the target data to the plurality of sectors.
In the case of first operating the target memory, a plurality of sectors may be erased, for example, the data contents in the plurality of sectors may be emptied to write target data to the plurality of sectors.
In the application, the data can be uniformly erased in the storage areas after being written into the storage areas, so that target data can be written in continuously, the erasing frequency of the memory is reduced, the space-based time is shortened, the memory loss caused by erasing is reduced, and the service life of the memory is prolonged.
In some embodiments, step 120 may include:
sequentially checking data of a plurality of sectors from front to back based on the arrangement sequence;
in the case that the target sector among the plurality of sectors fails the data verification, the target data is written in the target sector.
In this embodiment, data verification is used to determine whether a plurality of sectors meet the conditions for writing data.
In the case where the target sector fails the data verification, the target sector can be considered to meet the conditions for writing data.
As shown in fig. 2, when the arrangement order of the plurality of sectors is 1# to n # sectors, the data verification of the plurality of sectors from front to back may be performed sequentially from 1# to n # sectors.
In the case where the target sector among the plurality of sectors fails the data verification, the target data may be written in the target sector.
As shown in fig. 2, in some embodiments, a sector may include at least 4 monomers.
In this embodiment, each monomer may be 1000Bytes in length.
In some embodiments, the monomer may include a data verification module and a data content module.
In this embodiment, the data content module may be used to store data entities.
The data verification module may be configured to perform data verification on the data entity to determine whether the data content of the share area is valid.
In some embodiments, sequentially performing data verification on the plurality of sectors may include:
the data is verified for the plurality of sectors based on at least one of the data content length, the written state of the data area, and the CRC16 verification.
In this embodiment, the data content length may be a single length.
The written state of the data area may include written and unwritten.
CRC (Cyclic redundancy check) is a cyclic redundancy check, which is a hash function that generates a short fixed bit check code based on data such as network packets or computer files.
The CRC check may be used to detect or check errors that may occur after the data transmission or storage.
The CRC16 check is a check using 16 as the CRC code.
The CRC16 check may include a calculation method, a table lookup method, etc., and may be selected based on user requirements, which is not limited in this application.
For example, when the data area is written with 8bytes of a single length and the read value is the same as the last written value, the data content of the area can be considered valid.
For example, the sector may be considered to pass the data check if the data content length, the written state of the data area, and the CRC16 check all meet the requirements.
If any one of the data content length, the written state of the data area, and the CRC16 check is not satisfied, the sector may be considered to fail the data check.
In the actual execution process, under the condition of operating NANDFLASH for the first time, firstly, erasing operation is carried out on the 1# sector to the n # sector, and data verification of a plurality of sectors is not passed;
when target data is written into NANDFLASH, sequentially reading the 1# sector to the n # sector according to parts, performing data verification on a plurality of sectors, and finding a position which does not pass the first verification as a position for writing the data;
when target data is read from NANDFLASH, the target data is sequentially read from n # sector to 1# sector in parts, data verification is carried out on a plurality of sectors, and the position passing the first verification is found to be used as the position of the read data.
According to the data read-write method provided by the embodiment of the application, before the read-write operation is performed on the target data, the data of the plurality of sectors are verified, the validity of the regional data can be determined through the verification algorithm, the reliability of the sector for storing the data is improved, and the possible errors after the data transmission or storage are avoided.
The data read-write device provided by the application is described below, and the data read-write device described below and the data read-write method described above can be referred to correspondingly.
According to the data reading and writing method provided by the embodiment of the application, the execution main body can be a data reading and writing device. In the embodiment of the present application, a method for executing data reading and writing by using a data reading and writing device is taken as an example, and the data reading and writing device provided in the embodiment of the present application is described.
The embodiment of the application also provides a data read-write device.
As shown in fig. 3, the data read/write apparatus includes: a first processing module 310, a second processing module 320, and a third processing module 330.
A first processing module 310, configured to divide at least one storage space from the target memory, where the storage space includes at least one sector, when the write frequency of the target data is greater than the target frequency threshold; the target memory is NANDFLASH;
a second processing module 320, configured to write target data into a target sector of the plurality of sectors based on an arrangement order of the plurality of sectors;
the third processing module 330 is configured to read target data from the plurality of sectors based on the arrangement order.
According to the data read-write device provided by the embodiment of the application, through dividing at least one storage area from the target memory for read-write operation on data with higher write frequency, the available capacity of read-write data is enlarged, and the plurality of storage areas can be uniformly erased after the data are written into the plurality of storage areas, so that the target data are written in continuously, the erasing frequency of the memory is reduced, the space exchange time is shortened, the memory loss caused by erasing is reduced, the service life of the target memory is prolonged, the service life of a product is prolonged indirectly, the after-sale reworking loss caused by the loss of the target memory is avoided, and the resource loss and the hardware cost of the singlechip are reduced.
In some embodiments, the first processing module 310 may also be configured to:
the embedded device is provided with a target memory based on at least one of a service life of the embedded device, a specification life of the target memory, a writing frequency of target data, and a data capacity.
In some embodiments, the first processing module 310 may also be configured to:
determining a target number based on a service life of the embedded device, a specification life of the target memory, and a write frequency of the target data;
and dividing the target memory into a target amount of memory space.
In some embodiments, the first processing module 310 may also be configured to:
based on the writing frequency and the service life, acquiring the total writing frequency of the embedded equipment in the service life;
the target number is determined based on the ratio of the total write frequency to the specification lifetime.
In some embodiments, the first processing module 310 may also be configured to:
determining a target number based on a ratio of the required capacity to the data capacity;
and dividing the target memory into a target amount of memory space.
In some embodiments, the second processing module 320 may also be configured to:
sequentially checking data of a plurality of sectors from front to back based on the arrangement sequence;
in the case that the target sector among the plurality of sectors fails the data verification, the target data is written in the target sector.
In some embodiments, the third processing module 330 may also be configured to:
sequentially checking the data of the plurality of sectors from back to front based on the arrangement sequence;
in the case where the target sector passes the data verification among the plurality of sectors, the target data is read from the target sector.
In some embodiments, the third processing module 330 may also be configured to:
the data is verified for the plurality of sectors based on at least one of the data content length, the written state of the data area, and the CRC16 verification.
In some embodiments, the data read-write module may further include a fourth processing module for:
an erase operation is performed on a plurality of sectors before writing target data to a target sector of the plurality of sectors.
The data read-write device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an IOS operating system, or other possible operating systems, which is not specifically limited in the embodiments of the present application.
The data read-write device provided in this embodiment of the present application can implement each process implemented by the embodiments of the methods of fig. 1 to fig. 2, and in order to avoid repetition, a detailed description is omitted here.
The embodiment of the application also provides embedded equipment.
The embedded device includes: target memory and data read-write equipment.
In this embodiment, the target memory is used for performing operations such as reading, writing, storing, and the like on the data.
The data read-write device is the data read-write device described in any of the above embodiments.
The data read-write device is electrically connected with the target memory.
The data read-write device is used for dividing a plurality of storage spaces for data with higher writing frequency so as to perform alternating read-write operation on the data based on the plurality of storage spaces, and further the service life of the target memory is prolonged.
According to the embedded equipment provided by the embodiment of the application, the data read-write device is arranged in the embedded equipment and is electrically connected with the target memory, so that a plurality of storage spaces can be divided for data with higher write-in frequency, and the data can be alternately read-written based on the plurality of storage spaces, so that the service life of the target memory is prolonged, the service life of the embedded equipment is prolonged indirectly, and the hardware cost is reduced.
In some embodiments, as shown in fig. 4, the embodiment of the present application further provides an electronic device 400, including a processor 401, a memory 402, and a computer program stored in the memory 402 and capable of running on the processor 401, where the program when executed by the processor 401 implements the respective processes of the foregoing embodiments of the data read/write method, and the same technical effects can be achieved, so that repetition is avoided, and no further description is given here.
The electronic device in the embodiment of the application includes the mobile electronic device and the non-mobile electronic device described above.
In another aspect, the present application further provides a computer program product, where the computer program product includes a computer program stored on a non-transitory computer readable storage medium, where the computer program includes program instructions, when the program instructions are executed by a computer, can execute each process of the foregoing data read-write method embodiment, and achieve the same technical effect, and for avoiding repetition, a description is omitted herein.
In yet another aspect, the present application further provides a non-transitory computer readable storage medium, on which a computer program is stored, where the computer program is implemented when executed by a processor to perform each process of the foregoing data read-write method embodiment, and the same technical effects can be achieved, and for avoiding repetition, a description is omitted herein.
In still another aspect, an embodiment of the present application further provides a chip, where the chip includes a processor and a communication interface, where the communication interface is coupled to the processor, and the processor is configured to run a program or an instruction, implement each process of the foregoing data read-write method embodiment, and achieve the same technical effect, so that repetition is avoided, and no further description is given here.
It should be understood that the chips referred to in the embodiments of the present application may also be referred to as system-on-chip chips, chip systems, or system-on-chip chips, etc.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the corresponding technical solutions.

Claims (14)

1. The data read-write method is characterized by being applied to NANDFLASH, and comprises the following steps:
dividing at least one storage space from a target memory under the condition that the writing frequency of target data is larger than a target frequency threshold value, wherein the storage space comprises at least one sector; the target memory is NANDFLASH;
writing the target data into a target sector of the plurality of sectors based on an arrangement order of the plurality of sectors;
and reading the target data from the plurality of sectors based on the arrangement order.
2. The method for reading and writing data according to claim 1, wherein said dividing at least one storage space from the target memory comprises:
the at least one storage space is divided based on at least one of a service life of an embedded device, a specification life of the target memory, the writing frequency of the target data, and a data capacity, and the embedded device is provided with the target memory.
3. The method according to claim 2, wherein the dividing the at least one storage space based on at least one of a lifetime of the embedded device, a specification lifetime of the target memory, the writing frequency of the target data, and a data capacity includes:
determining a target number based on a lifetime of the embedded device, a specification lifetime of the target memory, and the write frequency of the target data;
and dividing the target memory to obtain the storage space with the target quantity.
4. The data read-write method according to claim 3, wherein said determining a target number based on a lifetime of the embedded device, a specification lifetime of the target memory, and the write frequency of the target data includes:
based on the writing frequency and the service life, acquiring the total writing frequency of the embedded equipment in the service life;
the target number is determined based on a ratio of the total write frequency and the specification lifetime.
5. The method according to claim 2, wherein the dividing into the at least one storage space is based on at least one of a lifetime of the embedded device, a specification lifetime of the target memory, the writing frequency of the target data, and a data capacity, further comprising:
determining a target number based on a ratio of the required capacity to the data capacity;
and dividing the target memory to obtain the storage space with the target quantity.
6. The method of any one of claims 1-5, wherein the target frequency threshold is 10 writes of the target data per minute to the target memory.
7. The data reading and writing method according to any one of claims 1 to 5, wherein the writing of the target data to a target sector among the plurality of sectors based on the arrangement order of the plurality of sectors includes:
based on the arrangement sequence, sequentially carrying out data verification on the plurality of sectors from front to back;
and writing the target data in the target sector in the case that the target sector in the plurality of sectors fails the data verification.
8. The data reading and writing method according to any one of claims 1 to 5, wherein the reading the target data from the plurality of sectors based on the arrangement order includes:
based on the arrangement sequence, sequentially carrying out data verification on the plurality of sectors from back to front;
and in the case that a target sector in the plurality of sectors passes the data verification, reading the target data from the target sector.
9. The method for reading and writing data according to claim 8, wherein sequentially performing data verification on the plurality of sectors comprises:
the plurality of sectors are data checked based on at least one of a data content length, a data area written state, and a CRC16 check.
10. The data read-write method according to any one of claims 1 to 5, characterized in that before said writing said target data to a target sector of said plurality of sectors, the method further comprises:
and performing an erasing operation on the plurality of sectors.
11. A data reading and writing apparatus, comprising:
the first processing module is used for dividing at least one storage space from the target memory under the condition that the writing frequency of the target data is larger than the target frequency threshold value, wherein the storage space comprises at least one sector; the target memory is NANDFLASH;
a second processing module for writing the target data into a target sector among the plurality of sectors based on an arrangement order of the plurality of sectors;
and the third processing module is used for reading the target data from the plurality of sectors based on the arrangement sequence.
12. An embedded device, comprising:
a target memory;
the data read-write device of claim 11, wherein the data read-write device is electrically connected to the target memory.
13. A non-transitory computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when executed by a processor, implements the data read-write method according to any one of claims 1-10.
14. A computer program product comprising a computer program which, when executed by a processor, implements a data read-write method according to any one of claims 1-10.
CN202311212817.0A 2023-09-19 2023-09-19 Data reading and writing method and device and embedded equipment Pending CN117453124A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311212817.0A CN117453124A (en) 2023-09-19 2023-09-19 Data reading and writing method and device and embedded equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311212817.0A CN117453124A (en) 2023-09-19 2023-09-19 Data reading and writing method and device and embedded equipment

Publications (1)

Publication Number Publication Date
CN117453124A true CN117453124A (en) 2024-01-26

Family

ID=89586319

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311212817.0A Pending CN117453124A (en) 2023-09-19 2023-09-19 Data reading and writing method and device and embedded equipment

Country Status (1)

Country Link
CN (1) CN117453124A (en)

Similar Documents

Publication Publication Date Title
US10713178B2 (en) Mapping table updating method, memory controlling circuit unit and memory storage device
EP2294510B1 (en) Method and apparatus for error correction according to erase counts of a solid-state memory
US10102146B2 (en) Memory system and operating method for improving rebuild efficiency
US20200065187A1 (en) Data access method, memory control circuit unit and memory storage device
CN106708416B (en) Data reconstruction method and system and memory control circuit unit thereof
CN104765569A (en) Data write-in method, memory control circuit unit and memory storing device
US9304907B2 (en) Data management method, memory control circuit unit and memory storage apparatus
US10613932B2 (en) Method for controlling operations of memory device, associated memory device and controller thereof, and associated electronic device
CN102981969A (en) Method for deleting repeated data and solid hard disc thereof
CN111813591B (en) Data error correction method and device of Nand Flash, electronic equipment and storage medium
CN103136111A (en) Data writing method, memorizer controller and memorizer storage device
CN113360336A (en) Memory system for predicting power of sequential command operation and method of operating the same
CN110377538B (en) Memory management method and memory controller
CN117453124A (en) Data reading and writing method and device and embedded equipment
CN108108118B (en) Data writing method and storage controller
US11947819B2 (en) Method and system for testing conversion relationship between block reading and page reading in flash memory chip
US20220413737A1 (en) Secure-Erase Prediction for Data Storage Devices
CN114822664A (en) Risk assessment method based on data priority, storage device and control circuit
CN114300026A (en) Monotonic counter, counting method, electronic device and storage medium
CN111258498B (en) FLASH memory management method
CN109960611B (en) Data recovery method and device, electronic equipment and machine-readable storage medium
CN114005476A (en) Flash memory, flash memory erasing and writing counting method, electronic equipment and computer storage medium
CN109558265B (en) Memory system with feature enhancement and method of operating the same
CN109308930B (en) Data writing method, memory control circuit unit and memory storage device
CN114047880B (en) NAND write power consumption optimization method and device for multi-Pass programming and computer 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