CN112965661A - Data storage method, device, equipment and storage medium - Google Patents

Data storage method, device, equipment and storage medium Download PDF

Info

Publication number
CN112965661A
CN112965661A CN202110228131.5A CN202110228131A CN112965661A CN 112965661 A CN112965661 A CN 112965661A CN 202110228131 A CN202110228131 A CN 202110228131A CN 112965661 A CN112965661 A CN 112965661A
Authority
CN
China
Prior art keywords
data
stored
page
data storage
storage area
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
CN202110228131.5A
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.)
Goertek Techology Co Ltd
Original Assignee
Goertek Techology 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 Goertek Techology Co Ltd filed Critical Goertek Techology Co Ltd
Priority to CN202110228131.5A priority Critical patent/CN112965661A/en
Publication of CN112965661A publication Critical patent/CN112965661A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • G06F16/148File search processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/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]

Abstract

The invention relates to the technical field of data processing, and discloses a data storage method, a device, equipment and a storage medium, wherein the method comprises the following steps: the method comprises the steps of obtaining the data size of a data block to be stored, distributing a data retrieval area and a data storage area in a NOR Flash memory according to the data size, loading a storage serial number of the data block to be stored, corresponding to the data retrieval area, when a data storage instruction is received, erasing the data storage area according to the storage serial number, and storing the data block to be stored in the data storage area. The data retrieval area and the data storage area are distributed in the NORFlash memory, each bit of each byte represents one data block in the data retrieval area, so that the loading of the storage sequence number of the data block to be stored is realized, and the data block to be stored is stored in the data storage area based on the storage sequence number so as to realize the quick access of data, improve the data access efficiency and avoid the unnecessary waste of storage resources.

Description

Data storage method, device, equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a data storage method, apparatus, device, and storage medium.
Background
NOR Flash and NAND Flash are two major non-volatile Flash technologies on the market, wherein NOR Flash is characterized by being executable In Place (XIP) on chip, so that applications can run directly In NOR Flash without reading the code into system RAM. NOR Flash has high transmission efficiency and high cost efficiency at a small capacity of 1-4 MB, but its performance is greatly affected by very low writing speed and erasing speed, resulting in long time for writing data and reading data. Therefore, how to realize fast data access based on NOR Flash becomes a problem to be solved urgently.
The above is only for the purpose of assisting understanding of the technical aspects of the present invention, and does not represent an admission that the above is prior art.
Disclosure of Invention
The invention mainly aims to provide a data storage method, a data storage device, data storage equipment and a data storage medium, and aims to solve the technical problem of how to realize quick data access based on NOR Flash.
In order to achieve the above object, the present invention provides a data storage method, comprising the steps of:
acquiring the data size of a data block to be stored, and allocating a data retrieval area and a data storage area in a NOR Flash memory according to the data size;
when a data storage instruction is received, loading a storage sequence number of the data block to be stored, which corresponds to the data retrieval area;
and erasing the data storage area according to the storage sequence number, and storing the data block to be stored in the data storage area.
Preferably, the step of obtaining the data size of the data block to be stored and allocating the data retrieval area and the data storage area in the NOR Flash memory according to the data size specifically includes:
acquiring the number of bytes of a data block and the total number of the data block to be stored;
calculating a first page number of a data retrieval area according to the total number of the data blocks and the number of bytes per page, and distributing the data retrieval area in a NOR Flash memory according to the first page number;
and calculating a second page number of the data storage area according to the total number of the data blocks, the byte number of the data blocks and the byte number of each page, and allocating the data storage area in the NOR Flash memory according to the second page number.
Preferably, the step of calculating the first number of pages of the data retrieval area according to the total number of data chunks and the number of bytes per page specifically includes:
calculating the first page number of the data retrieval area according to the total number of the data blocks and the number of bytes per page,
A=J/(L*8)
in the formula, a is the first page number of the data retrieval area, J is the total number of data blocks of the data block to be stored, and L is the number of bytes per page.
Preferably, the step of calculating the second number of pages of the data storage area according to the total number of the data blocks, the number of bytes of the data blocks, and the number of bytes per page specifically includes:
calculating a second page number of the data storage area according to the total number of the data blocks, the byte number of the data blocks and the byte number of each page,
B=J/N
N=L/K
in the formula, B is the second page number of the data storage area, J is the total number of data blocks of the data block to be stored, N is the number of data blocks per page, K is the number of bytes of the data block to be stored, and L is the number of bytes per page.
Preferably, the step of erasing the data storage area according to the storage sequence number and storing the data block to be stored in the data storage area specifically includes:
obtaining a quotient of dividing the storage sequence number by the number of data blocks of each page, and judging whether the storage sequence number can be divided by the number of data blocks of each page;
when the storage sequence number can be divided by the number of the data blocks of each page, searching the number of pages to be stored corresponding to the data storage area according to the quotient;
and erasing the pages to be stored, and storing the data blocks to be stored until the pages to be stored correspond to the writing addresses of the data storage areas.
Preferably, the erasing the number of pages to be stored, and storing the data block to be stored until the number of pages to be stored corresponds to the write address of the data storage area specifically includes:
erasing the pages to be stored, and storing the data blocks to be stored until the pages to be stored correspond to the write-in addresses of the data storage areas;
wherein the write address of the page to be stored corresponding to the data storage area can be obtained by the following formula,
h=h1+h2
h1=h0+P*L
h2=(H%N)*J
wherein h is the write address of the page to be stored corresponding to the data storage area, h1Page address, h, of the number of pages to be stored2Page offset for the number of pages to be stored, h0The method comprises the steps of setting a starting address of a page number to be stored, setting P to be the page number to be stored, setting L to be the number of bytes of each page, setting H to be a storage serial number,% to be used for carrying out remainder processing, setting J to be the total number of data blocks of a data block to be stored, and setting N to be the number of the data blocks of each page.
Preferably, after the step of erasing the data storage area according to the storage sequence number and storing the data block to be stored in the data storage area, the method further includes:
loading a storage sequence number of a data block to be read when a data reading instruction is received;
and calculating a historical serial number according to the storage serial number, and searching the write-in address of the data block to be read in the data storage area according to the historical serial number so as to read the data block to be read stored in the write-in address.
Further, in order to achieve the above object, the present invention also proposes a data storage device characterized by comprising:
the data allocation module is used for acquiring the data size of a data block to be stored and allocating a data retrieval area and a data storage area in the NOR Flash memory according to the data size;
the sequence number loading module is used for loading the storage sequence number of the data block to be stored when a data storage instruction is received;
and the data access module is used for erasing the data storage area according to the storage sequence number and storing the data block to be stored into the data storage area.
In addition, to achieve the above object, the present invention further provides a data storage device, including: a NOR Flash memory, a processor and a data storage program stored on the NOR Flash memory and executable on the processor, the data storage program being configured to implement the steps of the data storage method as described above.
Furthermore, to achieve the above object, the present invention also proposes a storage medium having stored thereon a data storage program which, when executed by a processor, implements the steps of the data storage method as described above.
The method comprises the steps of obtaining the data size of a data block to be stored, distributing a data retrieval area and a data storage area in a NOR Flash memory according to the data size, loading a storage serial number of the data block to be stored corresponding to the data retrieval area when a data storage instruction is received, erasing the data storage area according to the storage serial number, and storing the data block to be stored in the data storage area. Compared with the prior art that when data storage is carried out, the position information of the current storage block needs to be frequently updated and a relatively large FLASH space needs to be allocated to record the position information of the current storage block, so that storage resource waste and data access speed lag are caused.
Drawings
FIG. 1 is a schematic diagram of a data storage device of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating a first embodiment of a data storage method according to the present invention;
FIG. 3 is a flow chart illustrating a data storage method according to a second embodiment of the present invention;
FIG. 4 is a flow chart illustrating a data storage method according to a third embodiment of the present invention;
FIG. 5 is a block diagram of a data storage device according to a first embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a data storage device in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the data storage device may include: a processor 1001 such as a Central Processing Unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a NOR Flash memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The NOR Flash memory 1005 may alternatively be a storage device separate from the processor 1001 described above.
Those skilled in the art will appreciate that the configuration shown in FIG. 1 does not constitute a limitation of data storage devices, and may include more or fewer components than those shown, or some components in combination, or a different arrangement of components.
As shown in fig. 1, a NOR Flash memory 1005, which is a storage medium, may include therein an operating system, a data storage module, a network communication module, a user interface module, and a data storage program.
In the data storage device shown in fig. 1, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the NOR Flash memory 1005 in the data storage device of the present invention may be provided in the data storage device, and the data storage device calls a data storage program stored in the NOR Flash memory 1005 through the processor 1001 and executes the data storage method provided by the embodiment of the present invention.
An embodiment of the present invention provides a data storage method, and referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of the data storage method of the present invention.
In this embodiment, the data storage method includes the following steps:
step S10: acquiring the data size of a data block to be stored, and allocating a data retrieval area and a data storage area in a NOR Flash memory according to the data size;
it is easy to understand that after obtaining the data size of the data block to be stored, a data retrieval area and a data storage area may be allocated in the NOR Flash memory according to the data size, where the data size includes, but is not limited to, the number of bytes of the data block and the total number of the data blocks, in the data retrieval area, each bit (bit) of each Byte (Byte) represents a data block (a Byte is a measurement unit used by computer information technology to measure storage capacity and transmission capacity, a bit is the minimum unit of data storage, 1 Byte is equal to 8 bits binary system, i.e. 1 Byte (Byte) is equal to 8 bits (bit), in binary system, each 0 or 1 is a bit (bit), where 8 bits are referred to as a Byte), for example, 8 bits from low to high of the first Byte can respectively represent the 1 st data block to the 8 th data block, 8 bits from low to high of the second Byte can respectively represent the 9 th data block to the 16 th data block, and so on.
In a specific implementation, in order to implement accurate allocation of the data retrieval area and the data storage area, a first page number of the data retrieval area may be calculated according to the total number of the data blocks and the number of bytes per page, for example, the number of data blocks per page of the data retrieval area may be obtained by multiplying the number of bytes per page by 8, and then the total number of the data blocks is divided by the number of data blocks per page of the data retrieval area to obtain the first page number of the data retrieval area, and the data retrieval area is allocated in the NOR Flash memory according to the first page number, that is, a space corresponding to the first page number is allocated in the NOR Flash memory as the data retrieval area; and calculating a second page number of the data storage area according to the total number of the data blocks, the byte number of the data blocks and the byte number of each page, and allocating the data storage area in the NOR Flash memory according to the second page number, namely allocating a space corresponding to the second page number in the NOR Flash memory as the data storage area.
Step S20: when a data storage instruction is received, loading a storage sequence number of the data block to be stored, which corresponds to the data retrieval area;
it should be noted that, when a data storage instruction is received (that is, when a data block to be stored needs to be written in), a storage sequence number of the data block to be stored may be obtained, and then it is determined whether the data block to be stored has been loaded in the NOR Flash memory according to the storage sequence number, if not, a first bit equal to 1 in the data retrieval area is read, and then a data block sequence number corresponding to the bit is used as a storage sequence number of the data block to be stored corresponding to the data retrieval area, and the storage sequence number is loaded into the NOR Flash memory; if the serial number is loaded, the serial number stored in the NOR Flash memory is directly used.
Step S30: and erasing the data storage area according to the storage sequence number, and storing the data block to be stored in the data storage area.
It is easy to understand that, in order to realize the fast storage of the data blocks to be stored, after obtaining the storage serial number, the data storage area can be erased according to the storage serial number, and the data blocks to be stored are stored in the data storage area, wherein, each time a data block is stored, the data block can be sequentially written into the corresponding write address of the data storage area from the first data block of the first page, after each data block is written into the data storage area, the bit position 0 corresponding to the data retrieval area can be obtained, and the storage serial number of the corresponding data block to be stored in the NOR Flash memory can be added by 1, then, when switching pages, the corresponding page data can be erased and then written into the corresponding write address of the data storage area, after the last data block is written, all the data blocks of the first page can be erased, and writing can be started from the first page again, when the data storage area is subjected to loop-back writing to the first data block of the first page, all data in the data retrieval area can be erased.
In a specific implementation, in order to avoid the occurrence of a data omission phenomenon, it may be further detected whether a storage sequence number of a data block to be stored is consistent with the total number of data blocks of the data block to be stored, and the data retrieval area is formatted only when the storage sequence number is consistent with the total number of data blocks.
In specific implementation, in order to realize rapid reading of the data block to be stored, after the data storage area is erased according to the storage sequence number and the data block to be stored is stored in the data storage area, whether a data reading instruction is received or not can be detected in real time, when the data reading instruction is received, the storage sequence number of the data block to be read is loaded, a historical sequence number is calculated according to the storage sequence number, the historical sequence number can be obtained by subtracting 1 from the storage sequence number, and then, a writing address of the data block to be read in the data storage area is searched according to the historical sequence number so as to read the data block to be read, which is stored in the writing address.
In this embodiment, the data size of the data block to be stored is obtained, a data retrieval area and a data storage area are allocated in the NOR Flash memory according to the data size, when a data storage instruction is received, a storage serial number corresponding to the data retrieval area of the data block to be stored is loaded, the data storage area is erased according to the storage serial number, and the data block to be stored is stored in the data storage area. Compared with the prior art that when data storage is performed, a relatively large FLASH space needs to be allocated to record the position information of the current storage block due to the fact that the position information of the current storage block needs to be frequently updated, and storage resource waste and data access speed lag are caused by the fact that the position information of the current storage block needs to be recorded, in the embodiment, a data retrieval area and a data storage area are allocated in a NOR FLASH memory, each bit of each byte represents one data block in the data retrieval area, so that loading of a storage serial number, corresponding to the data retrieval area, of the data block to be stored is achieved, the data storage area is subjected to erasing processing based on the loaded storage serial number, and the data block to be stored is stored in the data storage area, so that data can be rapidly accessed, data access efficiency is improved, and unnecessary storage resource waste is avoided.
Referring to fig. 3, fig. 3 is a flowchart illustrating a data storage method according to a second embodiment of the present invention.
Based on the first embodiment described above, in the present embodiment, the step S10 includes:
step S101: acquiring the number of bytes of a data block and the total number of the data block to be stored;
step S102: calculating a first page number of a data retrieval area according to the total number of the data blocks and the number of bytes per page, and distributing the data retrieval area in a NOR Flash memory according to the first page number;
step S103: and calculating a second page number of the data storage area according to the total number of the data blocks, the byte number of the data blocks and the byte number of each page, and allocating the data storage area in the NOR Flash memory according to the second page number.
It is easy to understand that after the number of bytes of the data block to be stored and the total number of the data block are obtained, in order to realize accurate allocation of the data retrieval area, a first page number of the data retrieval area can be calculated according to the total number of the data block and the number of bytes of each page, and the data retrieval area is allocated in the NOR Flash memory according to the first page number; in order to realize accurate allocation of the data storage area, a second page number of the data storage area can be calculated according to the total number of the data blocks, the number of bytes of the data blocks and the number of bytes per page, and the data storage area can be allocated in the NOR Flash memory according to the second page number.
In a specific implementation, in order to implement accurate allocation of the data retrieval area, the number of data blocks per page of the data retrieval area is obtained by multiplying the number of bytes per page by 8 (in the data retrieval area, each bit of each byte represents one data block), the total number of the data blocks is divided by the number of data blocks per page of the data retrieval area to obtain a first number of pages of the data retrieval area, the data retrieval area is allocated in the NOR Flash memory according to the first number of pages, that is, a space corresponding to the first number of pages is allocated in the NOR Flash memory as the data retrieval area, that is, the first number of pages of the data retrieval area can be calculated according to the total number of data blocks and the number of bytes per page by the following formula,
A=J/(L*8)
in the formula, a is the first page number of the data retrieval area, J is the total number of data blocks of the data block to be stored, and L is the number of bytes per page.
In a specific implementation, in order to implement accurate allocation of the data storage area, a second page number of the data storage area may be calculated according to the total number of data blocks, the number of bytes of the data blocks, and the number of bytes per page, and a data storage area may be allocated in the NOR Flash memory according to the second page number, that is, a space corresponding to the second page number is allocated in the NOR Flash memory as the data storage area, for example, the number of data blocks per page of the data storage area may be obtained by dividing the number of bytes per page by the number of bytes of the data blocks, and then the total number of data blocks is divided by the number of data blocks per page of the data storage area to obtain the second page number of the data storage area, and the data storage area may be allocated in the NOR Flash memory according to the second page number, that the second page number of the data storage area may be calculated according to the total number of data blocks,
B=J/N
N=L/K
in the formula, B is the second page number of the data storage area, J is the total number of data blocks of the data block to be stored, N is the number of data blocks per page, K is the number of bytes of the data block to be stored, and L is the number of bytes per page.
In the implementation, the number of data blocks and the total number of data blocks of a data block to be stored are acquired, a first page number of a data retrieval area is calculated according to the total number of the data blocks and the number of bytes per page, the data retrieval area is allocated in a NOR Flash memory according to the first page number so as to realize accurate allocation of the data retrieval area, the loading speed of the subsequent storage sequence number loading based on the data retrieval area is improved, a second page number of a data storage area is calculated according to the total number of the data blocks, the number of bytes of the data blocks and the number of bytes per page, the data storage area is allocated in the NOR Flash memory according to the second page number so as to realize accurate allocation of the data storage area, and the subsequent reading efficiency of the data storage area for reading the data stored in the NOR Flash memory is improved.
Referring to fig. 4, fig. 4 is a flowchart illustrating a data storage method according to a third embodiment of the present invention.
Based on the second embodiment described above, in the present embodiment, the step S30 includes:
step S301: obtaining a quotient of dividing the storage sequence number by the number of data blocks of each page, and judging whether the storage sequence number can be divided by the number of data blocks of each page;
step S302: when the storage sequence number can be divided by the number of the data blocks of each page, searching the number of pages to be stored corresponding to the data storage area according to the quotient;
step S303: and erasing the pages to be stored, and storing the data blocks to be stored until the pages to be stored correspond to the writing addresses of the data storage areas.
It should be noted that, in order to implement fast storage of the data block to be stored, before performing data erasure processing on the number of pages to be stored in the data storage area, a quotient obtained by dividing the storage sequence number by the number of data blocks in each page may be obtained, and it is determined whether the storage sequence number is divisible by the number of data blocks in each page, when the storage sequence number is divisible by the number of data blocks in each page (that is, a remainder of the storage sequence number divided by the number of data blocks in each page is 0), the number of pages to be stored corresponding to the data storage area is searched according to the quotient, and then, erasure processing may be performed on the number of pages to be stored, and the data block to be stored is stored until the write address where the number of pages to be stored corresponds to the data storage area.
In a specific implementation, in order to quickly locate the number of pages to be stored, a page address and a page offset of the number of pages to be stored may be obtained first, and then the page address and the page offset are added to obtain a write address of the number of pages to be stored corresponding to the data storage area, where the page address may be obtained by adding a start address of the number of pages to be stored (i.e., an address of a first page of the number of pages to be stored) and a product of the number of pages to be stored and a number of bytes per page, and the page offset may be obtained by first obtaining a remainder of a storage sequence number divided by the number of data blocks per page (which may be obtained by dividing the number of bytes per page by the number of bytes of data blocks), and then multiplying the obtained remainder by a total number of data blocks of the data blocks to be stored, that is the write address of the number of,
h=h1+h2
h1=h0+P*L
h2=(H%N)*J
wherein h is the write address of the page to be stored corresponding to the data storage area, h1Page address, h, of the number of pages to be stored2Page offset for the number of pages to be stored, h0The method comprises the steps of setting a starting address of a page number to be stored, setting P to be the page number to be stored, setting L to be the number of bytes of each page, setting H to be a storage serial number,% to be used for carrying out remainder processing, setting J to be the total number of data blocks of a data block to be stored, and setting N to be the number of the data blocks of each page.
In this embodiment, a quotient of the storage sequence number divided by the number of data blocks per page is obtained, whether the storage sequence number is divisible by the number of data blocks per page is determined, when the storage sequence number is divisible by the number of data blocks per page, the number of pages to be stored corresponding to the data storage area is searched according to the quotient, the number of pages to be stored is erased, and the data blocks to be stored are stored until the number of pages to be stored corresponds to the write-in address of the data storage area. The write-in address of the page number to be stored corresponding to the data storage area is obtained through the page address and the page offset based on the page number to be stored, so that the page number to be stored is quickly positioned, then the page number to be stored is erased, and the data block to be stored is stored until the page number to be stored corresponds to the write-in address of the data storage area, so that the data block to be stored is quickly stored, and the storage efficiency of the data block to be stored is further improved.
Furthermore, an embodiment of the present invention further provides a storage medium, such as a NOR Flash memory, where the storage medium stores a data storage program, and the data storage program, when executed by a processor, implements the steps of the data storage method described above.
Referring to fig. 5, fig. 5 is a block diagram of a data storage device according to a first embodiment of the present invention.
As shown in fig. 5, the data storage device according to the embodiment of the present invention includes:
the data allocation module 10 is configured to obtain a data size of a data block to be stored, and allocate a data retrieval area and a data storage area in the NOR Flash memory according to the data size;
a sequence number loading module 20, configured to load a storage sequence number of the data block to be stored when a data storage instruction is received;
and the data access module 30 is configured to erase the data storage area according to the storage sequence number, and store the data block to be stored in the data storage area.
In this embodiment, the data size of the data block to be stored is obtained, a data retrieval area and a data storage area are allocated in the NOR Flash memory according to the data size, when a data storage instruction is received, a storage serial number corresponding to the data retrieval area of the data block to be stored is loaded, the data storage area is erased according to the storage serial number, and the data block to be stored is stored in the data storage area. Compared with the prior art that when data storage is performed, a relatively large FLASH space needs to be allocated to record the position information of the current storage block due to the fact that the position information of the current storage block needs to be frequently updated, and storage resource waste and data access speed lag are caused by the fact that the position information of the current storage block needs to be recorded, in the embodiment, a data retrieval area and a data storage area are allocated in a NOR FLASH memory, each bit of each byte represents one data block in the data retrieval area, so that loading of a storage serial number, corresponding to the data retrieval area, of the data block to be stored is achieved, the data storage area is subjected to erasing processing based on the loaded storage serial number, and the data block to be stored is stored in the data storage area, so that data can be rapidly accessed, data access efficiency is improved, and unnecessary storage resource waste is avoided.
A second embodiment of the data storage device of the present invention is proposed based on the first embodiment of the data storage device of the present invention described above.
In this embodiment, the data allocation module 10 is further configured to obtain the number of bytes of a data block to be stored and the total number of the data block;
the data allocation module 10 is further configured to calculate a first number of pages of the data retrieval area according to the total number of the data blocks and the number of bytes per page, and allocate the data retrieval area in the NOR Flash memory according to the first number of pages;
the data allocation module 10 is further configured to calculate a second number of pages of the data storage area according to the total number of the data blocks, the number of bytes of the data blocks, and the number of bytes per page, and allocate the data storage area in the NOR Flash memory according to the second number of pages.
The data allocating module 10 is further configured to calculate a first page number of the data retrieving area according to the total number of the data chunks and the number of bytes per page,
A=J/(L*8)
in the formula, a is the first page number of the data retrieval area, J is the total number of data blocks of the data block to be stored, and L is the number of bytes per page.
The data allocating module 10 is further configured to calculate a second number of pages of the data storage area according to the total number of the data chunks, the number of bytes of the data chunks, and the number of bytes per page,
B=J/N
N=L/K
in the formula, B is the second page number of the data storage area, J is the total number of data blocks of the data block to be stored, N is the number of data blocks per page, K is the number of bytes of the data block to be stored, and L is the number of bytes per page.
The data access module 30 is further configured to obtain a quotient obtained by dividing the storage sequence number by the number of data blocks in each page, and determine whether the storage sequence number is divisible by the number of data blocks in each page;
the data access module 30 is further configured to search, according to the quotient, a number of pages to be stored corresponding to the data storage area when the storage sequence number is divisible by the number of data blocks of each page;
the data access module 30 is further configured to erase the number of pages to be stored, and store the data block to be stored to the write address where the number of pages to be stored corresponds to the data storage area.
The data access module 30 is further configured to erase the number of pages to be stored, and store the data block to be stored to a write address where the number of pages to be stored corresponds to the data storage area;
wherein the write address of the page to be stored corresponding to the data storage area can be obtained by the following formula,
h=h1+h2
h1=h0+P*L
h2=(H%N)*J
wherein h is the write address of the page to be stored corresponding to the data storage area, h1Page address, h, of the number of pages to be stored2Page offset for the number of pages to be stored, h0Is the initial address of the page number to be stored, P is the page number to be stored, L is the byte number per pageH is a storage sequence number,% represents the complementation processing, J is the total number of the data blocks to be stored, and N is the number of the data blocks in each page.
The data access module 30 is further configured to load a storage sequence number of a data block to be read when receiving a data reading instruction;
the data access module 30 is further configured to calculate a historical serial number according to the storage serial number, and search a write address of the data block to be read in the data storage area according to the historical serial number, so as to read the data block to be read stored in the write address.
Other embodiments or specific implementations of the data storage device of the present invention may refer to the above method embodiments, and are not described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., a rom/ram, a magnetic disk, an optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A method of storing data, the method comprising the steps of:
acquiring the data size of a data block to be stored, and allocating a data retrieval area and a data storage area in a NOR Flash memory according to the data size;
when a data storage instruction is received, loading a storage sequence number of the data block to be stored, which corresponds to the data retrieval area;
and erasing the data storage area according to the storage sequence number, and storing the data block to be stored in the data storage area.
2. The method of claim 1, wherein the step of obtaining the data size of the data block to be stored and allocating the data retrieval area and the data storage area in the NOR Flash memory according to the data size specifically comprises:
acquiring the number of bytes of a data block and the total number of the data block to be stored;
calculating a first page number of a data retrieval area according to the total number of the data blocks and the number of bytes per page, and distributing the data retrieval area in a NOR Flash memory according to the first page number;
and calculating a second page number of the data storage area according to the total number of the data blocks, the byte number of the data blocks and the byte number of each page, and allocating the data storage area in the NOR Flash memory according to the second page number.
3. The method of claim 2, wherein the step of calculating the first number of pages of the data retrieval area based on the total number of data chunks and the number of bytes per page comprises:
calculating the first page number of the data retrieval area according to the total number of the data blocks and the number of bytes per page,
A=J/(L*8)
in the formula, a is the first page number of the data retrieval area, J is the total number of data blocks of the data block to be stored, and L is the number of bytes per page.
4. The method of claim 2, wherein said step of calculating a second number of pages of the data storage area based on the total number of data blocks, the number of bytes of the data blocks, and the number of bytes per page comprises:
calculating a second page number of the data storage area according to the total number of the data blocks, the byte number of the data blocks and the byte number of each page,
B=J/N
N=L/K
in the formula, B is the second page number of the data storage area, J is the total number of data blocks of the data block to be stored, N is the number of data blocks per page, K is the number of bytes of the data block to be stored, and L is the number of bytes per page.
5. The method according to claim 1, wherein the step of erasing the data storage area according to the storage sequence number and storing the data block to be stored in the data storage area specifically includes:
obtaining a quotient of dividing the storage sequence number by the number of data blocks of each page, and judging whether the storage sequence number can be divided by the number of data blocks of each page;
when the storage sequence number can be divided by the number of the data blocks of each page, searching the number of pages to be stored corresponding to the data storage area according to the quotient;
and erasing the pages to be stored, and storing the data blocks to be stored until the pages to be stored correspond to the writing addresses of the data storage areas.
6. The method according to claim 5, wherein the step of erasing the number of pages to be stored and storing the data block to be stored until the number of pages to be stored corresponds to the write address of the data storage area specifically comprises:
erasing the pages to be stored, and storing the data blocks to be stored until the pages to be stored correspond to the write-in addresses of the data storage areas;
wherein the write address of the page to be stored corresponding to the data storage area can be obtained by the following formula,
h=h1+h2
h1=h0+P*L
h2=(H%N)*J
wherein h is the write address of the page to be stored corresponding to the data storage area, h1Page address, h, of the number of pages to be stored2Page offset for the number of pages to be stored, h0The method comprises the steps of setting a starting address of a page number to be stored, setting P to be the page number to be stored, setting L to be the number of bytes of each page, setting H to be a storage serial number,% to be used for carrying out remainder processing, setting J to be the total number of data blocks of a data block to be stored, and setting N to be the number of the data blocks of each page.
7. The method according to any one of claims 1 to 6, wherein after the step of erasing the data storage area according to the storage sequence number and storing the data block to be stored in the data storage area, the method further comprises:
loading a storage sequence number of a data block to be read when a data reading instruction is received;
and calculating a historical serial number according to the storage serial number, and searching the write-in address of the data block to be read in the data storage area according to the historical serial number so as to read the data block to be read stored in the write-in address.
8. A data storage device, characterized in that the device comprises:
the data allocation module is used for acquiring the data size of a data block to be stored and allocating a data retrieval area and a data storage area in the NOR Flash memory according to the data size;
the sequence number loading module is used for loading the storage sequence number of the data block to be stored when a data storage instruction is received;
and the data access module is used for erasing the data storage area according to the storage sequence number and storing the data block to be stored into the data storage area.
9. A data storage device, the device comprising: NOR Flash memory, a processor and a data storage program stored on the NOR Flash memory and executable on the processor, the data storage program being configured to implement the steps of the data storage method of any one of claims 1 to 7.
10. A storage medium, characterized in that the storage medium has stored thereon a data storage program which, when executed by a processor, implements the steps of the data storage method according to any one of claims 1 to 7.
CN202110228131.5A 2021-03-01 2021-03-01 Data storage method, device, equipment and storage medium Pending CN112965661A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110228131.5A CN112965661A (en) 2021-03-01 2021-03-01 Data storage method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110228131.5A CN112965661A (en) 2021-03-01 2021-03-01 Data storage method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112965661A true CN112965661A (en) 2021-06-15

Family

ID=76276230

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110228131.5A Pending CN112965661A (en) 2021-03-01 2021-03-01 Data storage method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112965661A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113434084A (en) * 2021-06-20 2021-09-24 苏州浪潮智能科技有限公司 Data erasing method, system, device and medium
CN116501654A (en) * 2022-01-18 2023-07-28 北京科益虹源光电技术有限公司 Data storage method and laser

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1963814A (en) * 2006-11-29 2007-05-16 珠海市泰德企业有限公司 Managing method of data of memorizer
CN101184155A (en) * 2007-12-18 2008-05-21 中国电子科技集团公司第五十四研究所 Method for storing station name of security receiving chip
CN106293532A (en) * 2016-08-10 2017-01-04 广东佳禾声学科技有限公司 A kind of Flash data storage method
CN111208950A (en) * 2020-01-15 2020-05-29 山西银河电子设备厂 Method for improving NORFLASH service cycle based on single chip microcomputer

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1963814A (en) * 2006-11-29 2007-05-16 珠海市泰德企业有限公司 Managing method of data of memorizer
CN101184155A (en) * 2007-12-18 2008-05-21 中国电子科技集团公司第五十四研究所 Method for storing station name of security receiving chip
CN106293532A (en) * 2016-08-10 2017-01-04 广东佳禾声学科技有限公司 A kind of Flash data storage method
CN111208950A (en) * 2020-01-15 2020-05-29 山西银河电子设备厂 Method for improving NORFLASH service cycle based on single chip microcomputer

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
姚燕南,薛钧义: "微型计算机原理与接口技术", 《高等教育出版社》, pages: 298 - 299 *
赵伟华: "《计算机操作系统》", 30 September 2018, pages: 0164 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113434084A (en) * 2021-06-20 2021-09-24 苏州浪潮智能科技有限公司 Data erasing method, system, device and medium
CN113434084B (en) * 2021-06-20 2023-01-06 苏州浪潮智能科技有限公司 Data erasing method, system, device and medium
CN116501654A (en) * 2022-01-18 2023-07-28 北京科益虹源光电技术有限公司 Data storage method and laser

Similar Documents

Publication Publication Date Title
US8112682B2 (en) Method and device for bad-block testing
CN107391038B (en) Data writing method of data storage type flash memory, flash memory and storage medium
CN112965661A (en) Data storage method, device, equipment and storage medium
EP3364303A1 (en) Data arrangement method, storage apparatus, storage controller and storage array
CN106598504B (en) data storage method and device
CN112596668A (en) Bad block processing method and system for memory
US8161228B2 (en) Apparatus and method for optimized NAND flash memory management for devices with limited resources
CN108829342B (en) Log storage method, system and storage device
CN116700629B (en) Data processing method and device
CN116340198B (en) Data writing method and device of solid state disk and solid state disk
US7681009B2 (en) Dynamically updateable and moveable memory zones
CN112181275A (en) Data processor and data processing method
CN112269665B (en) Memory processing method and device, electronic equipment and storage medium
CN114138176A (en) Nor Flash erasing and upgrading method and device, computer equipment and storage medium
KR101376268B1 (en) Device and method of memory allocation with 2 stage for mobile phone
CN110286995B (en) Data reading and writing method and device
CN113051105A (en) Data processing method, device, equipment and storage medium
EP3819771B1 (en) Data processing method and device, apparatus, and system
CN111708715A (en) Memory allocation method, memory allocation device and terminal equipment
CN109144399B (en) Data storage method and device and electronic equipment
CN112988037A (en) Static wear leveling method, terminal and computer-readable storage medium
KR100688463B1 (en) Method for writing and erasing data of physical memory
CN108959517B (en) File management method and device and electronic equipment
CN108073362B (en) Method and device for prolonging service life of PairBlock
WO2018094937A1 (en) Quick upgrade method for embedded software and embedded device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination