A kind of date storage method and device based on EMMC
Technical field
The present invention relates to chip technology field more particularly to a kind of date storage methods and device based on EMMC.
Background technology
EMMC (Embedded Multi Media Card) is ordered by MMC associations, primarily directed to mobile phone or tablet
The embedded memory standard specification of the products such as computer is made of an embedded storage solution, carries MMC (multimedias
Card) interface, flash memory (nand-flash) and EMMC controllers.More and more mobile devices are using EMMC as storage
Unit.
However, the amount of capacity that the size of EMMC i.e. user can actually store, and the amount of capacity stored is weighing apparatus
A major parameter of EMMC performances is measured, the size of actual EMMC is also the major technique ginseng of consumer electronics product
Number.And at present EMMC memories can the size of maximum storage data i.e. the size of EMMC memories, data storage capacity
It cannot extend, more data cannot be stored in EMMC memories.
Invention content
In view of the above problems, it is proposed that the embodiment of the present invention is based on EMMC in order to provide a kind of one kind overcoming the above problem
Date storage method and a kind of corresponding data storage device based on EMMC.
To solve the above-mentioned problems, the embodiment of the invention discloses a kind of date storage methods based on EMMC, including:
The data write request of EMMC front end layer receiving hosts;
The EMMC front end layers ask corresponding initial data to said write, are compressed, and the pressure that compression is obtained
Contracting data flow is sent to EMMC middle layers;
The EMMC middle layers as data to be stored stream and record the compressed data stream, and are the number to be stored
Storage location is distributed according to stream;
The data to be stored stream and storage location are sent to EMMC back end layers by the EMMC middle layers;
The data to be stored stream is encrypted in the EMMC back end layers;
Encrypted data to be stored stream is stored in the storage location of NAND by the EMMC back end layers.
Optionally, the EMMC middle layers as data to be stored stream and record the compressed data stream, and are described
Data to be stored stream distributes storage location, including:
EMMC middle layers shield the data identity information before the compressed data stream compression, and the compressed data stream is made
For data to be stored stream;
Record the data identity information of the data to be stored stream;
According to the data identity information, storage position of the data to be stored stream in NAND is determined using mapping ruler
It sets.
Optionally, the step of EMMC back end layers encrypt the data to be stored stream, including:
SEED seeds are generated according to the parameter of NAND;
The SEED seeds based on generation are encrypted the data to be stored stream using out of order algorithm.
Optionally, described that SEED seeds are generated according to the parameter of memory, including:
The unique mark and the first two byte of the block number as SEED seeds of the NAND are extracted, page number is as SEED kinds
Latter two byte of son generates SEED seeds.
Optionally, further include:
The data removal request of EMMC front end layer receiving hosts, and the deletion object in the data removal request is sent
To the EMMC middle layers;
The EMMC middle layers search the corresponding record of the deletion object;
The EMMC middle layers delete in the NAND and record corresponding data with described;
The EMMC middle layers delete the record that object is deleted described in middle layer after data deletion finishes.
The embodiment of the invention also discloses a kind of method for reading data based on EMMC, including:
The data read request of EMMC front end layer receiving hosts, and it is sent to EMMC middle layers;
The EMMC middle layers search the storage location for the corresponding data flow of the read requests according to record;
The storage location is sent to EMMC back end layers by the EMMC middle layers;
The EMMC back end layers read the ciphertext data that data are decrypted, and will be obtained after decryption from the storage location
It is sent to the EMMC middle layers;
The ciphertext data is sent to the EMMC front end layers by the EMMC middle layers;
The EMMC front end layers decompress the ciphertext data, and will the obtained decompression data of decompression return to it is described
Host.
Optionally, the EMMC middle layers search the storage for the corresponding data flow of the read requests according to record
The step of position, including:
The EMMC middle layers search according to record and are directed to the corresponding data identity information of the read requests;
According to the data identity information, determine that the corresponding data flow of the data read request exists using mapping ruler
Storage location in NAND.
Optionally, the EMMC back end layers read data from the storage location and are decrypted, including:
Obtain SEED seeds;
The SEED seeds based on acquisition, using out of order algorithm to the data stream.
Correspondingly, the embodiment of the invention also discloses a kind of data storage devices based on EMMC, including:
Write request receiving module is used for the data write request of receiving host;
Compression module, for asking corresponding initial data to said write, the compression compressed, and compression is obtained
Data flow is sent to storage location distribution module;
Storage location distribution module for as data to be stored stream and recording the compressed data stream, and is described
Data to be stored stream distributes storage location, and the data to be stored stream and storage location are sent to encrypting module;
Encrypting module is stored in for the data to be stored stream to be encrypted, and by encrypted data to be stored stream
The storage location of NAND.
Correspondingly, the embodiment of the invention also discloses a kind of digital independent device based on EMMC, including:
Read requests receiving module is used for the data read request of receiving host;
Storage location searching module, for searching the storage location for the corresponding data flow of the read requests, and will
The storage location is sent to deciphering module;
Deciphering module, for reading the ciphertext data that data are decrypted, and will be obtained after decryption from the storage location
It is sent to decompression module;
Decompression module, for being decompressed to the ciphertext data, and will the obtained decompression data of decompression return to it is described
Host.
The embodiment of the present invention includes following advantages:
The embodiment of the present invention is when carrying out data storage, the data write request of EMMC front end layer receiving hosts, to described
The corresponding initial data of write request, is compressed, and the compressed data stream that compression obtains is sent to EMMC middle layers;It is described
EMMC middle layers as data to be stored stream and record the compressed data stream, and are data to be stored stream distribution storage
Position, and the data to be stored stream and storage location are sent to EMMC back end layers;The EMMC back end layers wait depositing to described
Storage data flow is encrypted, and encrypted data to be stored stream is stored in the storage location of NAND.Similarly can also it realize
Reading to data.The application will be restored again into after the data compression of user in EMMC memories by inside EMMC, Ke Yishi
Increase the data volume that can actually store in the case of existing EMMC physical capacities are limited, it might even be possible to realize the double effect of capacity
Fruit, while the effect for also ensuring storage Information Security is encrypted to it.
Description of the drawings
Fig. 1 shows a kind of flow chart of date storage method based on EMMC in the embodiment of the present invention one;
Fig. 2 shows a kind of EMMC structure charts of the embodiment of the present invention;
Fig. 3 shows a kind of flow chart of method for reading data based on EMMC in the embodiment of the present invention two;
Fig. 4 shows a kind of structure diagram of data storage device based on EMMC in the embodiment of the present invention three;
Fig. 5 shows a kind of structure diagram of digital independent device based on EMMC in the embodiment of the present invention four.
Specific implementation mode
In order to make the foregoing objectives, features and advantages of the present invention clearer and more comprehensible, below in conjunction with the accompanying drawings and specific real
Applying mode, the present invention is described in further detail.
Embodiment one
Referring to Fig.1, the flow chart for showing a kind of date storage method based on EMMC of the present invention, can specifically include
Following steps:
Step 101, the data write request of EMMC front end layers receiving host.
It is formed as shown in Fig. 2, EMMC forms (raw-nand) by EMMC controllers and memory, the band on EMMC controllers
There is MMC (multimedia card) interface, the connection with external host may be implemented by MMC interfaces.
In the embodiment of the present application, the compression to data and encryption may be implemented in EMMC controllers.Front end layer refers in EMMC
It is responsible for the part that agreement is docked with host hosts in portion.EMMC is powered on, i.e., starts EMMC first, is at working condition.With
Family can obtain the number corresponding to user's write request by leading portion layer by host transmission data write request, EMMC from host
According to stream.For example, it is assumed that user thinks that the data flow of storage is A data flows (size 800MB), at this time user by host to EMMC
Transmission data write request.Herein it should be noted that host can be computer in the embodiment of the present invention, tablet, mobile phone etc. is respectively
Terminal Type, it is without limitation.
Step 102, the EMMC front end layers ask corresponding initial data to said write, are compressed, and will compression
Obtained compressed data stream is sent to EMMC middle layers.
In the embodiment of the present application, data stream compression function is increased in EMMC controllers.It is obtained in EMMC front end layers
After needing the data flow being written to user, the data flow that the front end layer in EMMC controllers can upload user is compressed, raw
At compressed data stream.The size of EMMC memory capacity shared by compressed data stream is far smaller than EMMC shared by uncompressed data flow and stores
The double of EMMC memory capacity may be implemented under square one in the size of capacity.It should be noted that right in the embodiment of the present invention
The use of compression algorithm is not limited.For example, after EMMC front end layers receive data write request, data flow is obtained by host
A (size 800MB).EMMC front end layers compress data flow A, generate data stream B (size 400MB), the number through overcompression
The spaces NAND are occupied according to the relatively unpressed data flow A of stream B to substantially reduce.Data stream B is sent in EMMC by EMMC front end layers
Interbed.
Step 103, the EMMC middle layers as data to be stored stream and record the compressed data stream, and are described
Data to be stored stream distributes storage location.
EMMC middle layers are some control logics inside EMMC.After generating compressed data stream, EMMC middle layers are to pressure
The compression information of contracting data flow is shielded, i.e., the compression of data flow only EMMC front end layers complete, and EMMC middle layers no matter
The compression process of data flow, EMMC middle layers are only according to compressed actual amount of data using compressed data stream as data to be stored
Flow and record, for later realize read data when, can be according to the storage location of record search respective stream of data.
The EMMC middle layers as data to be stored stream and record the compressed data stream, and are the number to be stored
Storage location is distributed according to stream, including:
S1031, EMMC middle layer shield the data identity information before the compressed data stream compression, by the compression number
It is used as data to be stored stream according to stream.
For example, EMMC middle layers data stream B is compressed before data flow A data identity information shielding, data stream B is made
To need to be stored in the data flow of NAND.
S1032 records the data identity information of the data to be stored stream;
In the embodiment of the present application, data flow has the data identity information of oneself, such as head and the tail byte-identifier, size of data
Deng.Before and after data stream compression, since its size of data changes, then its data identity information also changes, and EMMC middle layers are only
The data identity information of data flow after recording compressed.For example, EMMC middle layers are by the data identity information of data stream B, such as word
Joint number is 1256byte, size of data 400MB, and head and the tail byte-identifier etc. is recorded.
S1033 determines the data to be stored stream in NAND according to the data identity information using mapping ruler
Storage location.
EMMC middle layers can be mapped to logical address on physical address different in NAND according to mapping ruler, management
The physical address of the newest data storage of each logical address, mapping affects the storage of data.EMMC middle layers, which utilize, reflects
It is that data to be stored stream distributes storage location to penetrate rule so that the data in data to be stored stream are neatly deposited in storage by rule
It puts.For example, byte number 1256byte of the EMMC middle layers according to data stream B, data greatly 400MB, the number such as head and the tail byte-identifier
According to identity information, it is mapped to physical address by logical address, be storage location of the data stream B distribution in NAND is m.
Step 104, the data to be stored stream and storage location are sent to EMMC back end layers by the EMMC middle layers.
EMMC back end layers are to control the part of NAND, realize the storage for treating storage data flow, therefore EMMC middle layers will
Data to be stored stream and the storage location distributed for data to be stored stream are sent to EMMC back end layers, are waited for for EMMC back end layers storages
It stores data flow and storage foundation is provided.For example, EMMC middle layers by abovementioned steps data stream B and storage location m be sent to
EMMC back end layers.
Step 105, the data to be stored stream is encrypted in the EMMC back end layers.
EMMC back end layers also realize the encryption function to data flow to be stored simultaneously.It is encrypted to data flow to be stored
When, first generate SEED seeds.SEED seeds are out of order algorithm seed.In the generation of traditional SEED seeds, SEED seeds are
Manufacturer provides when EMMC dispatches from the factory, and the only unique fixed SEED seeds of each media type are very easy to be cracked.And
In the embodiment of the present application, SEED seeds are generated according to the parameter of memory, the memory parameter of each EMMC is all different, and is generated
SEED seeds it is also different, if can not know SEED seeds, can not just obtain the initial data of data flow, to realize pair
The protection of data.
The generation method of the SEED seeds is:The unique mark of the NAND is extracted with block number as SEED seeds
The first two byte, latter two byte of page number as SEED seeds generate SEED seeds.
Memory NAND in EMMC is made of many pieces (block), and each block (block) is by many pages (page) group
At each page (page) is made of numerous bytes (byte).Each block (block) and each page (page) have its respective number
Code.Memory NAND in EMMC has oneself unique ID.By choosing the ID of above-mentioned NAND, the number and page of block
Number can generate SEED seeds.Out of order algorithm uses randomizer algorithms in the application, that is, uses randomizer
Algorithm upsets the byte of data to be stored stream, that is, realizes the light-type encryption to data flow to be stored, ensure that the peace of data
Quan Xing.
For example, EMMC back end layers encrypt data stream B.If the unique mark of NAND be P1127, select block number for
Block 5, page number are page 6, are P1127 by unique mark, select block number for block 5, page number generates for page 6
SEED seeds are upset the byte in data stream B using randomizer algorithms are generated, to realize that encryption generates data flow C
(size 400MB, encryption).
Step 106, encrypted data to be stored stream is stored in the storage location of NAND by the EMMC back end layers
Such as EMMC back end layers complete the storage of data by corresponding storage location m in data flow C deposits NAND
Process.
In above-described embodiment, can also include:
Step 107, the data removal request of EMMC front end layers receiving host, and by the deletion in the data removal request
Object is sent to the EMMC middle layers;
In certain data during user thinks deletion NAND, by host transmission data removal request, the data are deleted
The object information for wanting to delete is contained in request, EMMC middle layers obtain this data removal request.
Step 108, the EMMC middle layers search the corresponding record of the deletion object;
Step 109, the EMMC middle layers delete in the NAND and record corresponding data with described;
When data flow is written and stores, EMMC middle layers have done record to data flow to be stored and have been assigned with storage for it
Position, at this time EMMC middle layers according to the deletion object in data removal request searched in record needed for delete data flow,
Data corresponding with recording in NAND, the deletion of complete paired data are deleted after finding the data flow of the deletion.
Step 110, the EMMC middle layers delete after data deletion finishes and delete object described in middle layer
Record.
After completing to the deletion of data in NAND, EMMC middle layers also by the record deletion of this deletion data, are deleted
The relative recording of data is no longer present in EMMC.
The embodiment of the present invention is when carrying out data storage, the data write request of EMMC front end layer receiving hosts, to described
The corresponding initial data of write request, is compressed, and the compressed data stream that compression obtains is sent to EMMC middle layers;It is described
EMMC middle layers as data to be stored stream and record the compressed data stream, and are data to be stored stream distribution storage
Position, and the data to be stored stream and storage location are sent to EMMC back end layers;The EMMC back end layers wait depositing to described
Storage data flow is encrypted, and encrypted data to be stored stream is stored in the storage location of NAND.Similarly can also it realize
Reading to data.The application will be restored again into after the data compression of user in EMMC memories by inside EMMC, Ke Yishi
Increase the data volume that can actually store in the case of existing EMMC physical capacities are limited, it might even be possible to realize the double effect of capacity
Fruit, while the effect for also ensuring storage Information Security is encrypted to it.
Embodiment two
With reference to Fig. 3, shows a kind of flow chart of method for reading data based on EMMC of the present invention, can specifically include
Following steps:
Step 301, the data read request of EMMC front end layers receiving host, and it is sent to EMMC middle layers.
If for wanting to read certain data, by host to EMMC front end layer transmission data read requests, among EMMC
Layer obtains data read request, carries out the processing of digital independent.For example, it is assumed that user wants that the data flow read is that (size is C
400MB, encryption) data flow, then user by host to EMMC transmission data read requests.Host will be counted by EMMC front end layers
It is sent to EMMC middle layers according to read requests.
Step 302, the EMMC middle layers search the storage for the corresponding data flow of the read requests according to record
Position.
When reading stores the data in NAND, it is still necessary to the deposit position that data are read needed for knowing, it could be by number
It is read according to correct.And the information of data, EMMC are read needed for equally being contained in the data read request that EMMC middle layers obtain
Middle layer can correctly find the corresponding data identity information of phase read requests according to this information, be believed according to this data identity
Breath, by the way that logical address is mapped to according to mapping ruler on physical address different in NAND, you can number is read needed for knowing
According to deposit position.
Above-mentioned steps, including:
S3021, the EMMC middle layers search according to record and are directed to the corresponding data identity information of the read requests;
S3022 determines the corresponding data of the data read request according to the data identity information using mapping ruler
Stream storage location in NAND.
For example, EMMC middle layers obtain the relevant data identity letter of required reading data flow C from data read request
Breath finds the data identity information to data flow C records in record, to know that data flow C exists according to mapping ruler
Specific storage location in NAND is m.
It is because mapping ruler is just when data store herein it should be noted that according to mapping ruler reading data flow
The storage of data is affected, such as needs differentiation alphabetic data and random data, random data that may be divided into dsc data, cold number
According to.If dsc data and cold data are placed in the block in the same NAND, since dsc data update is frequent, physical block is caused to have
It is not high to imitate page utilization rate, when this block is carried out garbage reclamation, wherein cold data active page is copied to other places, causes to write
Amplification.It, can be to avoid being recovered to cold data in garbage reclamation if cold and hot data separate.So being utilized when storing data
Mapping ruler stores, then still needs to read according to mapping ruler when reading data, and the feelings for reading failure or error otherwise may occur
Shape.
Step 303, the storage location is sent to EMMC back end layers by the EMMC middle layers.
It illustrates in conjunction with above-mentioned steps, the specific storage location m of data flow C is sent to EMMC back end layers by EMMC middle layers.
Step 304, the EMMC back end layers read data from the storage location and are decrypted, and will be obtained after decryption
Ciphertext data is sent to the EMMC middle layers.
EMMC back end layers can still realize the decryption to data, above-mentioned steps, including:
S3041 obtains SEED seeds.
When data are decrypted, still need to acquisition SEED seeds just can not successfully solve if can not know SEED seeds
It is close.The acquisition methods of SEED seeds are consistent with generation method, would know that according to the unique mark of NAND and block number and page number
Former and later two bytes of SEED seeds, you can learn SEED seeds.
S3042, the SEED seeds based on acquisition, using out of order algorithm to the data stream.
Out of order algorithm still uses randomizer algorithms herein, and randomizer algorithms can be by the data flow upset again
It is arranged as original data stream, to realize the decryption to data flow.
For example, after EMMC back end layers find the data flow C of storage according to the storage location m of data flow C, reading data flow C,
Data flow C is decrypted, unique mark P1127 is obtained, block block 5, page number page 6 obtain SEED seeds, recycle
Randomizer algorithms restore the byte upset in data flow C, generate ciphertext data stream B (size 400MB).
Step 305, the ciphertext data is sent to the EMMC front end layers by the EMMC middle layers.
In conjunction with the example above, data stream B is sent to EMMC front end layers by EMMC middle layers.
Step 306, the EMMC front end layers decompress the ciphertext data, and the decompression data that decompression obtains are returned
Back to the host.
EMMC front end layers can also realize that the decompression to ciphertext data, decompression algorithm will can decompress determines according to actual conditions
Data afterwards are returned to host, that is, complete the reading process of data.For example, EMMC front end layers decompress data stream B, number is generated
According to stream A (size 800MB).Data flow A is sent to host by EMMC front end layers, that is, completes the reading process of data.
The embodiment of the present invention is when carrying out data storage, the data write request of EMMC front end layer receiving hosts, to described
The corresponding initial data of write request, is compressed, and the compressed data stream that compression obtains is sent to EMMC middle layers;It is described
EMMC middle layers as data to be stored stream and record the compressed data stream, and are data to be stored stream distribution storage
Position, and the data to be stored stream and storage location are sent to EMMC back end layers;The EMMC back end layers wait depositing to described
Storage data flow is encrypted, and encrypted data to be stored stream is stored in the storage location of NAND.Similarly can also it realize
Reading to data.The application will be restored again into after the data compression of user in EMMC memories by inside EMMC, Ke Yishi
Increase the data volume that can actually store in the case of existing EMMC physical capacities are limited, it might even be possible to realize the double effect of capacity
Fruit, while the effect for also ensuring storage Information Security is encrypted to it.
Embodiment three
With reference to Fig. 4, shows a kind of structure diagram of the data storage device based on EMMC of the present invention, can specifically wrap
It includes:
Write request receiving module 401 is used for the data write request of receiving host;
Compression module 402, for the corresponding initial data of said write request, being compressed, and compression is obtained
Compressed data stream is sent to storage location distribution module;
Storage location distribution module 403 for as data to be stored stream and recording the compressed data stream, and is institute
Data to be stored stream distribution storage location is stated, and the data to be stored stream and storage location are sent to encrypting module;
Encrypting module 404 for the data to be stored stream to be encrypted, and encrypted data to be stored stream is deposited
Enter the storage location of NAND.
Example IV
With reference to Fig. 5, shows a kind of structure diagram of the digital independent device based on EMMC of the present invention, can specifically wrap
It includes:
Read requests receiving module 501 is used for the data read request of receiving host;
Storage location searching module 502, for searching the storage location for the corresponding data flow of the read requests, and
The storage location is sent to deciphering module;
Deciphering module 503, for reading the decryption number that data are decrypted, and will be obtained after decryption from the storage location
According to being sent to decompression module;
Decompression module 504 returns to institute for being decompressed to the ciphertext data, and by the decompression data that decompression obtains
State host.
For device embodiments, since it is basically similar to the method embodiment, so fairly simple, the correlation of description
Place illustrates referring to the part of embodiment of the method.
Each embodiment in this specification is described in a progressive manner, the highlights of each of the examples are with
The difference of other embodiment, the same or similar parts between the embodiments can be referred to each other.
It should be understood by those skilled in the art that, the embodiment of the embodiment of the present invention can be provided as method, apparatus or calculate
Machine program product.Therefore, the embodiment of the present invention can be used complete hardware embodiment, complete software embodiment or combine software and
The form of the embodiment of hardware aspect.Moreover, the embodiment of the present invention can be used one or more wherein include computer can
With in the computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) of program code
The form of the computer program product of implementation.
The embodiment of the present invention be with reference to according to the method for the embodiment of the present invention, terminal device (system) and computer program
The flowchart and/or the block diagram of product describes.It should be understood that flowchart and/or the block diagram can be realized by computer program instructions
In each flow and/or block and flowchart and/or the block diagram in flow and/or box combination.These can be provided
Computer program instructions are set to all-purpose computer, special purpose computer, Embedded Processor or other programmable data processing terminals
Standby processor is to generate a machine so that is held by the processor of computer or other programmable data processing terminal equipments
Capable instruction generates for realizing in one flow of flow chart or multiple flows and/or one box of block diagram or multiple boxes
The device of specified function.
These computer program instructions, which may also be stored in, can guide computer or other programmable data processing terminal equipments
In computer-readable memory operate in a specific manner so that instruction stored in the computer readable memory generates packet
The manufacture of command device is included, which realizes in one flow of flow chart or multiple flows and/or one side of block diagram
The function of being specified in frame or multiple boxes.
These computer program instructions can be also loaded into computer or other programmable data processing terminal equipments so that
Series of operation steps are executed on computer or other programmable terminal equipments to generate computer implemented processing, thus
The instruction executed on computer or other programmable terminal equipments is provided for realizing in one flow of flow chart or multiple flows
And/or in one box of block diagram or multiple boxes specify function the step of.
Although the preferred embodiment of the embodiment of the present invention has been described, once a person skilled in the art knows bases
This creative concept, then additional changes and modifications can be made to these embodiments.So the following claims are intended to be interpreted as
Including preferred embodiment and fall into all change and modification of range of embodiment of the invention.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by
One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation
Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning
Covering non-exclusive inclusion, so that process, method, article or terminal device including a series of elements not only wrap
Those elements are included, but also include other elements that are not explicitly listed, or further include for this process, method, article
Or the element that terminal device is intrinsic.In the absence of more restrictions, limited by sentence " including one ... "
Element, it is not excluded that identical wanted there is also other in process, method, article or the terminal device including the element
Element.
A kind of date storage method based on EMMC provided by the present invention and a kind of data based on EMMC are deposited above
Storage device is described in detail, and principle and implementation of the present invention are described for specific case used herein,
The explanation of above example is only intended to facilitate the understanding of the method and its core concept of the invention;Meanwhile for the one of this field
As technical staff, according to the thought of the present invention, there will be changes in the specific implementation manner and application range, to sum up institute
It states, the content of the present specification should not be construed as limiting the invention.