Method, device and storage medium for random writing of embedded multimedia card
By introducing a second buffer area in the embedded multimedia card and determining the write operation request interval, the problem of low writing efficiency in eMMC when there is a large amount of random writing of user data is solved, and a more efficient data writing and solidification process is realized .
Patent Information
- Application Number
- CN202411559839.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-11-04
AI Technical Summary
In the scenario where a large number of randomly written user data exist, the writing efficiency of embedded multimedia cards (eMMCs) is low, mainly due to the duration of the NAND flash solidification process, the host device needs to wait.
By introducing a second buffer area in the embedded multimedia card, and determining the write operation request interval based on the available capacity of the buffer area and the length of data to be written. This interval ensures that while the first target user data is solidified to NAND, the second target user data may be cached into the second cache area, thereby performing data writing and solidification asynchronously.
The writing efficiency of the host device writing randomly to the eMMC is improved, and the waiting time of the host device when sending the next original user data is reduced, especially in the scenario where there are a large number of random writes.
Smart Images

Figure CN119065614B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of memory technology, and in particular to a random writing method, device and storage medium of an embedded multimedia card. Background Art
[0002] Embedded Multi Media Card (eMMC) is a storage device based on NAND flash packaging; it encapsulates the underlying NAND operations into different protocols for use by different host devices. However, in actual applications, when the host device randomly writes user data into the eMMC, since the address of the user data is random, the host device will divide the user data into multiple pieces of user data, each of which corresponds to a storage address in the eMMC, and then write each piece of user data into the eMMC in sequence. For the eMMC, after receiving each piece of user data, it will enter the idle state and start the NAND flash curing process. When the eMMC curing is completed, it will automatically switch from the idle state to the busy state, and then it can continue to receive user data sent by the host device. However, since NAND flash solidification takes a certain amount of time, the host device needs to wait for a period of time after sending each user data, resulting in low eMMC write efficiency. When there is a large amount of randomly written user data, the eMMC write efficiency is even lower. Therefore, how to improve the eMMC write efficiency in scenarios with a large amount of randomly written user data is a technical problem that needs to be solved urgently. Summary of the invention
[0003] The main purpose of the embodiments of the present application is to provide a method, device and storage medium for random writing of an embedded multimedia card, which can improve the writing efficiency of the eMMC in a scenario where there is a large amount of randomly written user data.
[0004] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application provides a random writing method of an embedded multimedia card, which is applied to a host device, and the method includes:
[0005] Determining a first data length of original user data to be written at a current moment in a preset first buffer area;
[0006] Determine a write operation request interval, first target user data, and second target user data according to the available buffer area capacity of the second buffer area of the embedded multimedia card and the first data length; wherein the write operation request interval is used to make the time interval of the second target user data waiting to be sent less than or equal to a preset waiting time threshold after the first target user data is sent; the first target user data and the second target user data are both at least part of the original user data in the first buffer area;
[0007] Sending a first write operation request to the embedded multimedia card;
[0008] In a case where the embedded multimedia card enters a busy state in response to the first write operation request, sending the first target user data to the embedded multimedia card so that the embedded multimedia card caches the received first target user data in a second buffer area; wherein the embedded multimedia card enters an idle state after receiving all the first target user data corresponding to the first write operation request;
[0009] sending a second write operation request to the embedded multimedia card after the write operation request interval;
[0010] In a case where the embedded multimedia card enters a busy state after responding to the second write operation request, second target user data is sent to the embedded multimedia card.
[0011] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a method for random writing of an embedded multimedia card, which is applied to the embedded multimedia card. The method includes:
[0012] receiving a first write operation request sent by a host device and switching a working mode to a busy state;
[0013] In the busy state, receiving first target user data sent by the host device and buffering the first target user data in a preset second buffer area;
[0014] When it is detected that the first target user data corresponding to the first write operation request has been completely received, switching the working mode to an idle state;
[0015] receiving a second write operation request sent by the host device after a write operation request interval, and switching the working mode to a busy state; the write operation request interval is used to make the time interval of the second target user data waiting to be sent less than or equal to a preset waiting time threshold after the first target user data is sent;
[0016] In the busy state, receiving second target user data sent by the host device and buffering the second target user data in the second buffer area;
[0017] When it is determined that the working mode has switched to an idle state, each target user data in the second buffer area is sequentially solidified to the NAND.
[0018] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, it implements the method of random writing of the embedded multimedia card described in any one of the first aspect and / or the second aspect.
[0019] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the method of random writing of an embedded multimedia card as described in any one of the first aspect and / or the second aspect.
[0020] The random writing method, device and storage medium of the embedded multimedia card proposed in the present application determine the write operation request interval according to the available capacity of the cache area of the second cache area based on the embedded multimedia card and the first data length of the original user data to be written currently. So that each time the eMMC is written, real-time calculation can be performed based on the original user data to be written currently, and because the NAND solidification process of the eMMC can be asynchronously performed with the operation of the host device writing the user data into the second cache area, the write operation request interval can ensure that the eMMC can solidify the first target user data written by the first write operation request into the NAND and cache the second target user data into the second cache under the premise that the second cache area is sufficient to cache the second target user data. At this time, for the host device, when sending the next original user data, it is not necessary to wait for the eMMC to complete writing the target data that has been sent last into the NAND before sending it. Therefore, the total time for the host device to send each original user data can be shortened, thereby improving the writing efficiency of the host device to randomly write user data to the eMMC. In the scenario where there is a large amount of user data that needs to be written randomly, the writing efficiency of the embodiment of the present application is higher than that of the random writing method of the eMMC in the related art. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a schematic diagram of interaction between an embedded multimedia card and a host device during random writing of an embedded multimedia card in the prior art;
[0022] Figure 2This is a schematic diagram of a process of applying a random writing method of an embedded multimedia card provided by an embodiment of the present application to a host device;
[0023] Figure 3 This is a schematic diagram of interaction between an embedded multimedia card and a host device in an embodiment of the random writing method of an embedded multimedia card provided by an embodiment of the present application applied to a host device;
[0024] Figure 4 is a schematic diagram of interaction between an embedded multimedia card and a host device in another embodiment in which the random writing method of an embedded multimedia card provided by an embodiment of the present application is applied to a host device;
[0025] Figure 5 is a flow chart of the random writing method of the embedded multimedia card provided by the embodiment of the present application applied to the embedded multimedia card;
[0026] Figure 6 is a schematic diagram of interaction between an embedded multimedia card and a host device in an embodiment of the present application in which the random writing method of the embedded multimedia card provided in the embodiment is applied to the embedded multimedia card;
[0027] Figure 7 It is a structural diagram of the hardware structure corresponding to the random writing method of the embedded multimedia card provided in the embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0029] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0030] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0031] First, some nouns involved in this application are analyzed:
[0032] Idle state, the idle state of eMMC refers to a working state of the device in different operating modes. In the idle state, the eMMC device will not respond to any command from the host unless a specific startup command is received.
[0033] Busy state, the busy state of eMMC refers to a working state of the device in different operating modes. Busy state means that the eMMC device is processing commands issued by the host or performing data transmission. After the device assigns the relative RCA, it will enter the data transmission mode. In the busy state, the device can respond to the host's read and write requests and other commands and perform normal operations.
[0034] Embedded Multi Media Card (eMMC) is a storage device based on NAND flash packaging; it encapsulates the underlying NAND operations into different protocols for use by different host devices. However, in actual applications, when the host device randomly writes user data into the eMMC, since the address of the user data is random, the host device will divide the user data into multiple pieces of user data, each of which corresponds to a storage address in the eMMC, and then write each piece of user data into the eMMC in sequence. Figure 1 As shown, for eMMC, after receiving each user data, it will enter the idle state and start the NAND flash curing process to write the user data into NAND. After the eMMC curing is completed, it will automatically switch from the idle state to the busy state, and then it can continue to receive user data sent by the host device. However, since NAND flash curing takes a certain amount of time, the host device needs to wait for a period of time after sending each user data, resulting in a low write efficiency of the eMMC. For example, Figure 1 As shown in the figure, taking user data N as an example, after user data N is sent to eMMC, eMMC writes user data N to NAND after receiving it. During the writing process of user data N, eMMC is in an idle state, and the host device needs to wait for eMMC to become busy before continuing to send user data N+1. When there is a large amount of randomly written user data, the eMMC write efficiency is lower. Figure 1As shown, in the prior art, the bus frequency inside the eMMC device can be increased to improve the curing efficiency of NAND flash, thereby reducing the waiting time of the host device, but this will increase the power consumption of the eMMC. When the eMMC is applied to an embedded storage device, it will have a great impact on the performance of the embedded storage device. Therefore, how to improve the writing efficiency of the eMMC in the scenario where there is a large amount of randomly written user data is a technical problem that needs to be solved urgently. Based on this, the embodiment of the present application provides a method, device and storage medium for random writing of an embedded multimedia card, which can improve the writing efficiency of the eMMC in the scenario where there is a large amount of randomly written user data.
[0035] The random writing method, device and storage medium of the embedded multimedia card provided in the embodiments of the present application are specifically described through the following embodiments. First, the random writing method of the embedded multimedia card in the embodiments of the present application is described.
[0036] The random write method of the embedded multimedia card of the present application is a management method for the host device to write to the embedded multimedia card, wherein the host device and the embedded multimedia card can be integrated in an integrated device, or the host device and the embedded multimedia card can be two independent devices. The integrated device can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0037] Refer to the following Figure 2 As shown, the random writing method of the embedded multimedia card provided in the embodiment of the present application is applied to a host device; the random writing method of the embedded multimedia card includes:
[0038] Step S110, determining a first data length of original user data to be written at a current moment in a preset first buffer area;
[0039] Step S120: determining a write operation request interval, first target user data, and second target user data according to the available capacity of the second buffer area of the embedded multimedia card and the first data length; wherein the write operation request interval is used to make the time interval of the second target user data waiting to be sent less than or equal to a preset waiting time threshold after the first target user data is sent; and the first target user data and the second target user data are both at least part of the original user data in the first buffer area;
[0040] Step S130: sending a first write operation request to the embedded multimedia card;
[0041] Step S140: when the embedded multimedia card enters a busy state in response to the first write operation request, sending the first target user data to the embedded multimedia card so that the embedded multimedia card caches the received first target user data in the second cache area; wherein the embedded multimedia card enters an idle state after receiving all the first target user data corresponding to the first write operation request;
[0042] Step S150, sending a second write operation request to the embedded multimedia card after an interval of write operation requests;
[0043] Step S160: When the embedded multimedia card enters a busy state after responding to the second write operation request, send the second target user data to the embedded multimedia card.
[0044] Therefore, by determining the write operation request interval according to the available capacity of the cache area of the second cache area based on the embedded multimedia card and the first data length of the original user data to be written, each time the eMMC is written, real-time calculation can be performed based on the original user data to be written, and because the NAND solidification process of the eMMC can be asynchronous with the operation of the host device writing the user data to the second cache area, the write operation request interval can ensure that the eMMC can solidify the first target user data written by the first write operation request to NAND and cache the second target user data to the second cache under the premise that the second cache area is sufficient to cache the second target user data. At this time, for the host device, when sending the next original user data, it is not necessary to wait for the eMMC to complete writing the target data that was previously sent to NAND before sending it. Therefore, the total time for the host device to send each original user data can be shortened, thereby improving the write efficiency of the host device to randomly write user data to the eMMC. In the scenario where there is a large amount of user data that needs to be randomly written, the write efficiency of the embodiment of the present application is higher than that of the random writing method of the eMMC in the related art.
[0045] In step S100, the original user data is the original data written by the host device to the host device for the user. Since the user writes data continuously, the original user data may correspond to the user's operation or data within a period of time. In this regard, the embodiment of the present application does not limit the original user data. The first target user data and the second target user data may be data obtained after splitting an original user data, or may both correspond to a complete original user data, or the first target user data may correspond to an original user data, and the second target user data may correspond to part of the data of another original user data. The division method of the original user data (that is, the method of determining the first target user data and the second target user data) may be based on the length of each data block in the eMMC, the buffer area capacity of the second buffer area of the eMMC, or a preset second length threshold, wherein the second length threshold may be determined in real time according to the simulation experiment or the transmission efficiency of the current host device, the curing efficiency of the eMMC, and the available capacity of the buffer area. In this regard, the embodiment of the present application does not limit how the original user data is divided. In a scenario where a large amount of user data is written randomly, since the user writes the user data continuously, at least one original user data can be cached in the first cache area at the same time. When there are multiple original user data, the data length of each original user data can be the same or different, and the embodiments of the present application do not impose any restrictions on this.
[0046] The second cache area is the internal cache area of the eMMC, which is used to cache user data sent from the host device, so that the NAND solidification operation (that is, writing the data in the second cache area to the NAND flash) can be performed only after receiving enough user data, thereby improving the convenience of eMMC operation and the utilization rate of eMMC resources.
[0047] The available capacity of the cache area indicates the amount of user data that can be stored in the second cache area of the eMMC at the current moment. Based on the available capacity of the cache area and the first data length of the original user data to be written at the current moment, it can be determined in real time whether there is enough remaining cache space in the second cache area to enable the host to send data and NAND solidification operations to be performed as synchronously as possible. The available capacity of the cache area can be obtained by theoretical calculation of the host device or can be queried and determined from the eMMC.
[0048] The waiting time threshold can be selectively set according to actual needs. It represents the expected waiting time for starting to send the second target user data after the first target user data is sent. In some embodiments, the waiting time threshold can be set to 0.
[0049] Exemplarily, it is assumed that M original user data are determined based on step S110, which are user data 1 to user data M. When writing to the eMMC starting from user data 1, refer to step S120 to determine the write operation request interval, the first target user data, and the second target user data corresponding to the first write request, wherein, when the first target user data is solidified in the eMMC under the write operation request interval, the second cache area can support the synchronous caching of the second target user data. Taking the first target data as user data 1 and the second target data as user data 2 as an example, refer to steps S130 to 140 to write data to user data 1. Referring to step S150, when user data 1 has been sent and the information of entering the idle state sent by the eMMC is received, that is, after the write operation request interval, a second write operation request is sent to the eMMC, and data is written to user data 2. At this time, user data 2 is the user data to be written at the current moment, and can be written to the eMMC with reference to step S150. After user data 2 is sent, user data 3 is the original user data to be written at the current moment and is re-judged with reference to step S120, and so on, thereby realizing the transmission of each original user data. Figure 3 As shown, when the length of each original user data can support the asynchronous operation of receiving and solidifying in the second buffer area, the write operation request interval of user data 2 is the write duration of user data 1, and the write operation request interval of user data 3 is the write duration of user data 2, such as Figure 3 As shown, for the host device, it can theoretically achieve uninterrupted transmission of user original data, thereby improving the efficiency of random writing.
[0050] It is understandable that when entering the random write scenario, in the initial state, the available capacity of the cache area is greater than the first length threshold.
[0051] It is understandable that, when the first data length is less than the preset first length threshold, step S120, determining the write operation request interval, the first target user data, and the second target user data according to the available buffer area capacity of the second buffer area of the embedded multimedia card and the first data length, includes:
[0052] Calculating the remaining buffer area capacity according to the available buffer area capacity and the first data length;
[0053] When the remaining cache capacity is greater than or equal to the preset multiple of the cache single write data amount, the original user data to be written currently is used as the first target user data, and the next original user data to be written is used as the second target user data;
[0054] Using the writing duration of the first target user data as the write operation request interval;
[0055] The preset multiple is a positive integer greater than 1; the cache single write data volume represents the maximum amount of user data that can be sent by the host device within the preset cache solidification time.
[0056] The preset multiple can be dynamically configured, such as based on the host sending rate and the eMMC curing rate. The preset multiple can be different for different host device and eMMC combinations. In this case, the time the host device needs to wait when user data needs to be randomly written can be further reduced.
[0057] The amount of data written to the cache at a time can be determined by the product of the host sending rate and the cache solidification time. The cache solidification time is the time corresponding to the minimum amount of data when the eMMC solidifies the NAND flash. The cache solidification time can be determined based on the average value of the historical time, or it can be determined based on the minimum historical time. In this regard, the embodiments of the present application do not limit how to determine the cache solidification time.
[0058] When the remaining cache area capacity is greater than or equal to a preset multiple of the cache single write data amount, it can ensure that there is still sufficient cache space in the second cache area of the eMMC within the cache solidification time to ensure that the host data can continue to write data for the cache solidification time until the second target user data transmission is completed.
[0059] It is understandable that the first length threshold can be determined in real time based on the total cache size of the second cache area, the amount of data written to the cache at a time, and the amount of data solidified at a time. For example, assuming that the first length threshold is L; then the ratio of L to the amount of data written to the cache at a time* (the amount of data written to the cache at a time - the amount of data solidified at a time) can determine the reserved space that must be reserved when the user data of the first length threshold is sent and solidified simultaneously. Under the premise that the capacity of the reserved space based on the preset ratio multiple is less than the total cache size, the eMMC is simulated and debugged to determine the ratio range of the preset ratio multiple when the eMMC performance is optimal, and the first length threshold is determined in reverse based on the ratio range. The first length threshold can also be determined by simulation testing. In this regard, the embodiment of the present application does not limit the first length threshold.
[0060] It is understandable that, when the first data length is less than a preset first length threshold, determining the write operation request interval, the first target user data, and the second target user data according to the available capacity of the cache area of the second cache area of the embedded multimedia card and the first data length, further includes:
[0061] When the remaining cache capacity is less than the preset multiple of the cache single write data volume, the next division step is performed on the original user data to be written:
[0062] The division steps include:
[0063] Determine the next partition length step of the original user data to be written according to the remaining buffer area capacity and the preset buffer redundancy value;
[0064] Divide the next user data to be written according to the division length step to obtain the first sub-random write data of at least one different storage address;
[0065] Using the original user data to be written currently as the first target user data;
[0066] The first sub-random write data to be written in the first buffer area is used as the second target user data.
[0067] By splitting the next original user data to be written, the next original data to be written can be written into the second cache in batches, and the next original data to be written can be solidified in batches in the eMMC, thereby further reducing the impact of the next original user data to be written on the solidification of user data that has been received by the eMMC while being written.
[0068] In some embodiments, when the next original data to be written is split, the write operation request interval between multiple first sub-random write data can be based on the write duration of the split first sub-random write data. When the last first sub-random write data is completed, it can jump to step S110 to re-determine the original user data to be written at the current moment and repeat steps S120 to S160.
[0069] In some embodiments, before initiating the first first write operation request to the eMMC to randomly write user data, wait for the target user data in the second buffer area in the eMMC to be solidified, thereby further ensuring that when randomly writing batch user data based on the above steps, the total writing time of the host device is shorter.
[0070] The cache redundancy value is determined by the following steps:
[0071] Calculate the difference between the cache single write data volume and the single solidification data volume to obtain the cache difference, wherein the single solidification data volume is the minimum user data volume supported by the embedded multimedia card within the cache solidification time;
[0072] Subtract the single solidified data volume from the cache difference to obtain the cache redundancy value.
[0073] The division step is used to ensure that the writing of the next original user data to be written is accelerated after the first target data is solidified.
[0074] The partition length step is less than or equal to the remaining cache capacity, and can be determined based on the first data length, the second data length of the next original user data to be written, and the remaining cache capacity. The embodiment of the present application does not limit how to determine, and those skilled in the art can selectively set it according to actual needs. If the remaining cache capacity is greater than the second data length of the next original user data to be written, there is no need to split it, that is, the partition step is 0. When the remaining cache capacity is less than the second data length, the size of the first data length and the second data length can be determined. When the first data length is greater than (the second data length - the remaining cache capacity), the partition step is set to the remaining cache capacity. Otherwise, the available cache space after each solidification is completed can be determined based on the cache redundancy value to further split the next original user data to be written.
[0075] It can be understood that, when the first data length is greater than or equal to a preset first length threshold, determining the write operation request interval, the first target user data, and the second target user data according to the available buffer area capacity of the second buffer area of the embedded multimedia card and the first data length, further includes:
[0076] Taking a preset second length threshold as a splitting step, splitting the original user data to be written to obtain a plurality of second sub-user data at different storage addresses;
[0077] Updating the plurality of second sub-user data into the first buffer area;
[0078] Updating first second sub-user data among the plurality of second sub-user data as first target user data to be allocated;
[0079] Updating second second sub-user data among the plurality of second sub-user data to second target user data;
[0080] The updated writing duration of the first target user data is used as the writing operation request interval.
[0081] It is understandable that for the original user data to be written, after the execution of the second target user data is completed, it is possible to jump to step S110 to re-determine the first data length of the original data to be written, and repeat the subsequent steps to write the eMMC data, thereby improving the overall writing speed of the host device to the eMMC.
[0082] For example, refer to Figure 4As shown, assuming that the original user data to be written is user data N, and user data N is split into two parts, the second part of user data N is triggered to be sent after the first part of user data N is sent (that is, the first target data is sent), and at the same time, in the eMMC, the eMMC solidifies the first part of user data N. After the second part of user data N is sent, user data N+1 is used as the original user data to be written at the current moment. When the user data N+1 is also greater than the first length threshold, user data N+1 is split and sent. At this time, the second part of user data N is written to NAND while part of user data N+1 is sent. At this time, the total waiting time of the host device is shorter when randomly writing to eMMC.
[0083] It can be understood that the second length threshold is determined by the following steps:
[0084] Determining a reserved space in the second buffer area according to the available capacity of the buffer area and the second data length of the next original user data to be allocated;
[0085] Determine the number of splits based on the reserved space, the amount of data written to the cache at a time, and the cache redundancy value;
[0086] A second length threshold is determined according to the minimum number of write times.
[0087] When the second data length is less than the first length threshold, it can be determined that the reserved space in the second cache area that can be used for the original user data to be written at the current moment is (cache area available capacity - second data length). At this time, the reserved space and the amount of data written to the cache at a single time can determine the minimum number of writes (that is, the minimum number of writes), and then the second length threshold can be determined based on the minimum number of writes.
[0088] In summary, in the above embodiment of the present application, when the first target user data and the second target user data are the same original user data at the current moment, after the writing of each original user data at the current moment is completed, the process will be adjusted to step S110 to re-determine the original user data at the current moment to start the fast writing process. When the first target user data and the second target user data are different original user data, after the two adjacent original user data are sent, the process will jump to step S110 to re-determine the original user data at the current moment to start the fast writing process.
[0089] Understandably, referring to Figure 5 As shown, according to the random writing method of the embedded multimedia card applied to the eMMC provided in the embodiment of the present application, the method includes:
[0090] Step S210, receiving a first write operation request sent by the host device and switching the working mode to a busy state;
[0091] Step S220: In a busy state, receiving first target user data sent by the host device and buffering the first target user data in a preset second buffer area;
[0092] Step S230: When it is detected that the first target user data corresponding to the first write operation request has been completely received, the working mode is switched to an idle state;
[0093] Step S240, receiving a second write operation request sent by the host device after the write operation request interval, and switching the working mode to a busy state; the write operation request interval is used to make the time interval of the second target user data waiting to be sent less than or equal to a preset waiting time threshold after the first target user data is sent;
[0094] Step S250: In a busy state, receiving second target user data sent by the host device and buffering the second target user data in a second buffer area;
[0095] Step S260: When it is determined that the working mode has switched to an idle state, the target user data in the second cache area are sequentially solidified to the NAND.
[0096] The solidification of target user data to NAND can be triggered every time the device switches to an idle state, or the triggering timing can be determined based on the size of the NAND idle area in the eMMC.
[0097] It is understandable that the target user data in the second cache area is sequentially solidified to the NAND, including:
[0098] Extracting third target user data from the second cache area according to the data length of the target user data corresponding to each write operation request in the second cache area and the preset single-time solidified data volume;
[0099] The third target user data is solidified to the free area of the NAND.
[0100] Each data stored in the second cache area that is expected to be continuously stored in the NAND is the target data. The single solidification data volume is the minimum data volume allowed to be solidified when there is a free area in the eMMC. When the eMMC has a larger free area, multiple target data can be solidified together in the same continuous interval.
[0101] The first write operation request and the second write operation request are both write operation requests, and the first target user data and the second target user data are both target user data.
[0102] It is understandable that, according to the data length of the target user data corresponding to each write operation request in the second cache area and the preset single solidification data volume, the third target user data is extracted from the second cache area, including:
[0103] Extracting target user data of different write operation requests from the second buffer area in sequence;
[0104] After each extraction of target user data of a write operation request, determining whether the sum of the data volume of the next target user data to be extracted for another write operation request and the extracted user data is greater than the free area;
[0105] When the total amount of data is greater than the capacity of the free area, stop extracting the target user data from the second cache;
[0106] The extracted target user data is sorted according to the preset memory writing format and solidified into the free area of the NAND.
[0107] The capacity of the free area is a multiple of the amount of data that is solidified at one time. By writing each target user data as a whole block, the writing efficiency of NAND can be improved.
[0108] For example, refer to Figure 6 As shown, user data N is greater than the first length threshold and is split into two parts. After the first part of user data N is received by the second buffer area, the host device sends the second part of user data N to the second buffer area. In the process of eMMC writing the second part of user data N into NAND, user data N+2, user data N+3, and the first part of user data N+4 are received by the second buffer. In the eMMC, since the first part of user data N+2, user data N+3, and user data N+4 are relatively short, they are spliced and written into NAND as a whole. At this time, in the process of eMMC writing the spliced data, the second part of user data N+4 and the first part of user data N+5 are being sent. Since there is a large free area in the eMMC that is sufficient for storing the second part of user data N+4 and the first part of user data N+5, the second part of user data N+4 and the first part of user data N+5 are spliced and written into NAND.
[0109] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the random writing method of the embedded multimedia card when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0110] See also Figure 7 , Figure 7 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0111] The processor 701 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0112] The memory 702 may be a NAND flash, and the relevant program code is stored in the memory 702, and the processor 701 calls and executes the random writing method of the embedded multimedia card of the embodiment of the present application;
[0113] Input / output interface 703, used to implement information input and output;
[0114] Communication interface 704, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0115] A bus 705 that transmits information between various components of the device (e.g., the processor 701, the memory 702, the input / output interface 703, and the communication interface 704);
[0116] The processor 701 , the memory 702 , the input / output interface 703 and the communication interface 704 are connected to each other in communication within the device via a bus 705 .
[0117] The embodiment of the present application also provides a computer-readable storage medium, which is a computer-readable storage medium that stores a computer program. When the computer program is executed by a processor, the random writing method of the embedded multimedia card is implemented.
[0118] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0119] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0120] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0121] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0122] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0123] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0124] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0125] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0126] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0127] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0128] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0129] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for random writing of an embedded multimedia card, characterized in that: Applied to a host device, the method comprises: Determining a first data length of original user data to be written at a current moment in a preset first buffer area; Determine a write operation request interval, first target user data, and second target user data according to the available buffer area capacity of the second buffer area of the embedded multimedia card and the first data length; wherein the write operation request interval is used to make the time interval of the second target user data waiting to be sent less than or equal to a preset waiting time threshold after the first target user data is sent; the first target user data and the second target user data are both at least part of the original user data in the first buffer area; Sending a first write operation request to the embedded multimedia card; In a case where the embedded multimedia card enters a busy state in response to the first write operation request, sending the first target user data to the embedded multimedia card so that the embedded multimedia card caches the received first target user data in a second buffer area; wherein the embedded multimedia card enters an idle state after receiving all the first target user data corresponding to the first write operation request; sending a second write operation request to the embedded multimedia card after the write operation request interval; In a case where the embedded multimedia card enters a busy state after responding to the second write operation request, sending second target user data to the embedded multimedia card; Wherein, the embedded multimedia card is used for: extracting target user data of different write operation requests from the second buffer area in sequence; the first write operation request and the second write operation request are both write operation requests, the first target user data and the second target user data are both target user data, and the target user data is data stored in the second buffer area and expected to be continuously stored in the NAND; After each target user data of a write operation request is extracted, it is determined whether the sum of the data amount of the next target user data to be extracted for another write operation request and the extracted target user data is greater than the free area, so as to solidify the multiple target user data together in the same continuous interval of the NAND; the free area is a multiple of the single solidification data amount; the single solidification data amount is the minimum data amount allowed to be solidified when there is a free area in the embedded multimedia card; When the total amount of data is greater than the capacity of the free area, stopping extracting target user data from the second cache; The extracted target user data is sorted according to a preset memory writing format and solidified into the free area of the NAND.
2. The random writing method of embedded multimedia card according to claim 1, characterized in that: In a case where the first data length is less than a preset first length threshold, determining the write operation request interval, the first target user data, and the second target user data according to the available capacity of the cache area of the second cache area of the embedded multimedia card and the first data length, comprises: Calculating the remaining buffer area capacity according to the available capacity of the buffer area and the first data length; When the remaining cache area capacity is greater than or equal to a preset multiple of the cache single write data amount, the original user data to be written currently is used as the first target user data, and the next original user data to be written is used as the second target user data; Using the writing duration of the first target user data as a write operation request interval; The preset multiple is a positive integer greater than 1; the cache single write data volume represents the maximum user data volume that can be sent by the host device within the preset cache solidification time.
3. The random writing method of embedded multimedia card according to claim 2, characterized in that: In a case where the first data length is less than a preset first length threshold, determining the write operation request interval, the first target user data, and the second target user data according to the available capacity of the cache area of the second cache area of the embedded multimedia card and the first data length, further comprising: When the remaining buffer area capacity is less than the preset multiple of the single-time write data amount of the buffer, a division step is performed on the next original user data to be written; Wherein, the dividing step comprises: Determining the partition length step of the next original user data to be written according to the remaining buffer area capacity and a preset buffer redundancy value; Dividing the next user data to be written stepwise according to the division length to obtain at least one first sub-random write data with a different storage address; Using the original user data to be written currently as the first target user data; Using the first sub-random write data to be written in the first buffer area as the second target user data; The cache redundancy value is determined by the following steps: Calculating the difference between the cache single write data amount and the single solidification data amount to obtain a cache difference, wherein the single solidification data amount is the minimum user data amount supported by the embedded multimedia card for solidification within the cache solidification time; The cache redundancy value is obtained by subtracting the single solidified data amount from the cache difference.
4. The random writing method of embedded multimedia card according to claim 2, characterized in that: In a case where the first data length is greater than or equal to a preset first length threshold, determining the write operation request interval, the first target user data, and the second target user data according to the available capacity of the cache area of the second cache area of the embedded multimedia card and the first data length, further comprising: Taking a preset second length threshold as a splitting step, splitting the original user data to be written to obtain a plurality of second sub-user data at different storage addresses; Updating a plurality of second sub-user data into the first buffer area; Updating the first second sub-user data among the plurality of second sub-user data as the first target user data to be allocated; Updating second second sub-user data among the plurality of second sub-user data into second target user data; The updated writing duration of the first target user data is used as a write operation request interval.
5. The random writing method of embedded multimedia card according to claim 4, characterized in that: The second length threshold is determined by the following steps: Determining a reserved space in the second buffer area according to the available capacity of the buffer area and the second data length of the next original user data to be allocated; Determining a minimum number of write times according to the reserved space, the amount of data written to the cache at a single time, and a cache redundancy value; The second length threshold is determined according to the minimum number of write times.
6. A method for random writing of an embedded multimedia card, characterized in that: Applied to an embedded multimedia card, the method comprises: receiving a first write operation request sent by a host device and switching a working mode to a busy state; In the busy state, receiving first target user data sent by the host device and buffering the first target user data in a preset second buffer area; When it is detected that the first target user data corresponding to the first write operation request has been completely received, switching the working mode to an idle state; receiving a second write operation request sent by the host device after a write operation request interval, and switching the working mode to a busy state; the write operation request interval is used to make the time interval of the second target user data waiting to be sent less than or equal to a preset waiting time threshold after the first target user data is sent; In the busy state, receiving the second target user data sent by the host device and buffering the second target user data in the second buffer area; When it is determined that the working mode has switched to an idle state, sequentially solidifying each target user data in the second buffer area to NAND; The sequentially solidifying the target user data in the second cache area to the NAND includes: extracting target user data of different write operation requests from the second buffer area in sequence; the first write operation request and the second write operation request are both write operation requests, the first target user data and the second target user data are both target user data, and the target user data is data stored in the second buffer area and expected to be continuously stored in the NAND; After each target user data of a write operation request is extracted, it is determined whether the sum of the data amount of the next target user data to be extracted for another write operation request and the extracted target user data is greater than the free area, so as to solidify the multiple target user data together in the same continuous interval of the NAND; the free area is a multiple of the single solidification data amount; the single solidification data amount is the minimum data amount allowed to be solidified when there is a free area in the embedded multimedia card; When the total amount of data is greater than the capacity of the free area, stopping extracting target user data from the second cache; The extracted target user data is sorted according to a preset memory writing format and solidified into the free area of the NAND.
7. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the random writing method of the embedded multimedia card according to any one of claims 1 to 6 when executing the computer program.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for random writing of an embedded multimedia card according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Data processing method and device
CN112748869A
Mapping table management method of storage chip, electronic equipment and storage medium
CN118689786A