Data writing method, data writing device, electronic equipment and readable storage medium

By dividing multiple data storage sub-regions and compensation space areas in NAND FLASH memory, fine writing of small data is realized, the problem of low storage space utilization is solved, and the efficiency of storage space usage is improved.

CN118885115APending Publication Date: 2024-11-01VIVO MOBILE COMM CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410933165.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

The existing NAND FLASH memory has low utilization when writing small data, resulting in wasted storage space, especially in SLC space. How to improve the efficiency of storage space is an important issue.

Method used

By dividing the target write location into multiple data storage sub-regions and corresponding compensation space areas, each page contains multiple data storage sub-regions and compensation space areas, and writing is refined according to the length of the data to be written to avoid the whole Waste of pages and dynamically adjust how storage space is used.

Benefits of technology

It realizes more efficient storage space utilization, avoids the wasted storage space due to scattered small data, and improves the efficiency of NAND SLC area usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118885115A_ABST
    Figure CN118885115A_ABST
Patent Text Reader

Abstract

The invention discloses a data writing method, a data writing device, electronic equipment and a readable storage medium. The data writing method comprises the following steps: receiving to-be-written data, and determining the data length of the to-be-written data; under the condition that the data length is smaller than a first length, the to-be-written data are sequentially written into a first address range space from a target writing position, and the first address range space is composed of N pages with first capacity, each page comprises M data storage sub-regions with second capacity and a first compensation space region corresponding to each data storage sub-region, and the first compensation space region is used for storing a first ECC check code corresponding to first data; the first data is the data stored in the data storage sub-region corresponding to the first compensation space region, the first length is the sum of M second capacities, N is an integer greater than or equal to 1, and M is an integer greater than 1.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and specifically relates to a data writing method, a data writing device, an electronic device and a readable storage medium. Background Art

[0002] With the development of storage technology, NAND FLASH memory has entered the era of 3D TLC (Trinary-Level Cell, i.e. 3bit / cell) and even QLC (Quad-Level Cell, i.e. 4bit / cell) from 2D SLC (Single-Level Cell, i.e. 1bit / cell) and MLC (Multi-Level Cell, i.e. 2bit / cell). The number of bits that can be stored in a single Cell is increasing, and there are also problems such as decreased read and write speed and poor data storage stability. In the use of existing memory, the SLC (Single-Level Cell, i.e. 1bit / cell) area is often used to improve the speed and data storage stability. However, setting the SLC space will reduce the use space of the entire memory. In the limited SLC space, it is very important to improve the space utilization efficiency. At present, the storage method of NAND includes storage in pages. However, when the length of the written data is less than the page capacity, the utilization rate of NAND is low, resulting in a waste of storage space. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a data writing method, a data writing device, an electronic device and a readable storage medium, which can solve the problem of low storage space utilization.

[0004] In a first aspect, an embodiment of the present application provides a data writing method, the method comprising: receiving data to be written, and determining a data length of the data to be written; when the data length is less than a first length, starting from a target write position, writing the data to be written in sequence into a first address range space, wherein the first address range space is composed of N pages of a first capacity, each page comprising M data storage sub-areas of a second capacity and a first compensation space area corresponding to each of the data storage sub-areas, the first compensation space area being used to store a first ECC check code corresponding to the first data, the first data being data stored in the data storage sub-area corresponding to the first compensation space area, the first length being the sum of the M second capacities, N being an integer greater than or equal to 1, and M being an integer greater than 1.

[0005] In a second aspect, an embodiment of the present application provides a data writing device, which includes: a receiving module, used to receive data to be written and determine the data length of the data to be written; a writing module, used to write the data to be written in sequence into a first address range space starting from a target write position when the data length is less than a first length, wherein the first address range space is composed of N pages of a first capacity, each page includes M data storage sub-areas of a second capacity and a first compensation space area corresponding to each of the data storage sub-areas, the first compensation space area is used to store a first ECC check code corresponding to the first data, the first data is the data stored in the data storage sub-area corresponding to the first compensation space area, the first length is the sum of the M second capacities, N is an integer greater than or equal to 1, and M is an integer greater than 1.

[0006] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0007] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0008] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.

[0009] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.

[0010] In an embodiment of the present application, when the data length of the received data to be written is less than the first length, starting from the target write position, the data to be written is written sequentially into the data storage sub-area in the first address range space, thereby realizing refined writing, making fuller use of the storage space, and avoiding wasting a whole page of storage space due to scattered small data. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 A schematic diagram showing a flow chart of a data writing method provided by an embodiment of the present application;

[0012] Figure 2 A schematic diagram showing a flow chart of a data writing method provided by an embodiment of the present application;

[0013] Figure 3 A schematic diagram showing an SLC space division provided by an embodiment of the present application is shown;

[0014] Figure 4 A schematic diagram showing an SLC space division provided by an embodiment of the present application is shown;

[0015] Figure 5 A schematic diagram of SLC space division provided by an embodiment of the present application is shown;

[0016] Figure 6a A schematic diagram showing data writing provided by an embodiment of the present application is shown;

[0017] Figure 6b Another schematic diagram showing a data writing method provided by an embodiment of the present application;

[0018] Figure 7 Another schematic diagram of data writing provided by an embodiment of the present application is shown;

[0019] Figure 8a Another schematic diagram of data writing provided by an embodiment of the present application is shown;

[0020] Figure 8b Another schematic diagram showing a data writing method provided by an embodiment of the present application;

[0021] Fig. 9 A schematic diagram of calculating an ECC check code provided by an embodiment of the present application is shown;

[0022] Fig.10 A schematic diagram showing an address update provided by an embodiment of the present application is shown;

[0023] Fig.11 Another schematic diagram showing a flow chart of a data writing method provided by an embodiment of the present application;

[0024] Fig.12 A schematic diagram showing the structure of a data writing device provided by an embodiment of the present application is shown;

[0025] Fig.13 A schematic diagram showing the structure of an electronic device provided by an embodiment of the present application is shown;

[0026] Fig.14 Another structural schematic diagram of an electronic device provided by an embodiment of the present application is shown. DETAILED DESCRIPTION

[0027] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0028] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0029] The data writing method, data writing device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.

[0030] Figure 1 A data writing method provided by an embodiment of the present application is shown, and the method can be executed by an electronic device, and the electronic device may include: a terminal device. In other words, the method can be executed by software or hardware installed in the electronic device, and the method includes the following steps:

[0031] S110: receiving data to be written, and determining the data length of the data to be written.

[0032] The data length refers to the size of the storage space that the data needs to occupy, and its units may include but are not limited to:

[0033] (1) Bit: The smallest unit of data in a computer, representing a binary bit, which can take the value 0 or 1.

[0034] (2) Byte (B): The basic storage unit, equal to 8 bits.

[0035] (3) Kilobyte (KB): equal to 1024 bytes (2^10B).

[0036] (4) Megabyte (MB): equal to 1024 kilobytes (2^20B).

[0037] (5) Gigabyte (GB): equal to 1024 megabytes (2^30B).

[0038] S120: When the data length is less than the first length, starting from the target writing position, the data to be written is sequentially written into the first address range space.

[0039] Among them, the first address range space is composed of N pages of first capacity, each page includes M data storage sub-areas of second capacity and a first compensation space area corresponding to each of the data storage sub-areas, the first compensation space area is used to store a first ECC check code corresponding to the first data, the first data is the data stored in the data storage sub-area corresponding to the first compensation space area, the first length is the sum of M second capacities, N is an integer greater than or equal to 1, and M is an integer greater than 1.

[0040] Optionally, before S120, the following steps may also be included:

[0041] Divide the target storage space into a first address range space and a second address range space, wherein the first address range space includes N pages of a first capacity, the second address range space includes X pages of a first capacity, each page includes a data storage area of ​​a first length and a second compensation space area of ​​a second length, wherein the sum of the first length and the second length is the first capacity;

[0042] The data storage area corresponding to each page in the first address range space is divided into M data storage sub-areas of second capacity, and the compensation space area corresponding to each page in the first address range space is divided into M first compensation space areas, wherein the M data storage sub-areas of second capacity and the M first compensation space areas correspond one to one.

[0043] It is understandable that the target storage space can be set for the SCL space in the NAND storage medium, and the traditional SCL space includes multiple pages. When scattered data is stored, the storage effect is as follows: Figure 2 As shown, if the minimum capacity of a page in an SLC NAND is 16KB, the minimum write data each time is 16KB. If less than 16KB of data is written, there will be a large amount of invalid data space, and the storage space will not be fully utilized. Figure 3 As shown, the SLC space is divided into two parts: a first address range space and a second address range space. Figure 4 and Figure 5As shown, in the first address range space, a page is divided into multiple data storage sub-areas, and the data in each data storage sub-area is individually ECC-checked, while in the second address range space, the page is still the basic unit. In this way, when the data length of the data to be written is less than the first length, the data to be written can be stored in the first address range space. Exemplarily, assuming that the total capacity (first length) of the data storage area is 16KB, it can be divided into 4 data storage sub-areas, and the capacity of each data storage sub-area is 4KB. When the data to be written is 4KB, one data storage sub-area can be occupied, and the remaining three data storage sub-areas are still available; when the data to be written is 2KB, one data storage sub-area can be occupied, and the remaining three data storage sub-areas are still available; when the data to be written is 6KB, two data storage sub-areas can be occupied, and the remaining two data storage sub-areas are still available.

[0044] Wherein, in another implementation, before the data to be written is sequentially written into the first address range space in units of data storage sub-areas starting from the target write position, the method further includes: determining the target write position as the starting position of the next data storage sub-area adjacent to the target data storage sub-area, wherein the target data storage sub-area is the end data storage sub-area corresponding to the last write operation. In other words, the target write position is the next data storage sub-area of ​​the end data storage sub-area corresponding to the last write operation. For example, if the address of the end data storage sub-area is Sector 0, then the target write address will be Sector 1. In this implementation, since each write operation does not need to re-search the next available address, but directly starts writing from the position where the last operation ends, the addressing time can be reduced, thereby improving the efficiency of the write operation. At the same time, data fragmentation caused by storage can be avoided, and the storage space can be better managed.

[0045] In an embodiment of the present application, when the data length of the received data to be written is less than the first length, starting from the target write position, the data to be written is written sequentially into the data storage sub-area in the first address range space, thereby realizing refined writing, making fuller use of the storage space, and avoiding wasting a whole page of storage space due to scattered small data.

[0046] In one implementation, the method further includes: in the case where a target page exists in the first address range space, migrating the data stored in the target page to the second address range space in units of pages; wherein the second address range space is composed of X pages of the first capacity, each page includes a data storage area and a second compensation space area corresponding to the data storage area, the capacity of the data storage area is the first length, the target page is a page in which M of the data storage sub-areas are fully written, X is an integer greater than or equal to 1, and the second compensation space area is used to store a second ECC check code corresponding to second data, and the second data is the data stored in the data storage area.

[0047] It can be understood that the first address range space stores scattered data by dividing the data storage area into multiple data storage sub-areas, and the second address range space stores in units of pages for storing integrated data. Then, after storing the data to be written into the first address range space, it is necessary to determine whether there is a target page whose corresponding M second-capacity data storage sub-areas are full of data. If so, the data in the target page is migrated and stored in the second address range space, so that the storage space of each page in the second address range space is fully utilized.

[0048] In one implementation, the method further includes: when the data length is equal to the first length, writing the data to be written into the second address range space in sequence; when the data length is greater than the first length, writing the third data into the second address range space in sequence, and writing the fourth data into the first address range space in sequence, wherein the length of the third data is an integer multiple of the first length, and the length of the fourth data is the difference between the length of the data and the length of the third data.

[0049] It can be understood that if the data length is equal to the first length, the data to be written can be stored as a page, and there is no remaining space, so it can be written into the second address range space in units of pages; if the data length is greater than the first length, the third data is written into the second address range space in units of pages, and the fourth data is not enough to fill a whole page, so the second data is written into the first address range space as scattered data. In this way, dynamic storage of data is achieved, which can effectively improve the utilization rate of storage space, thereby avoiding waste of storage resources.

[0050] In one implementation, writing the data to be written into the first address range space in sequence includes: for any data storage sub-area corresponding to the current write operation, when valid data has been written into the data storage sub-area, generating the first ECC check code based on the valid data, and writing the first ECC check code into the first compensation space area corresponding to the data storage sub-area.

[0051] It is understandable that since NAND is written in pages, and data needs to be ECC (Error correction code) checked in units of Pages when writing, the ECC check code is stored in the compensation space at the end of the page. For example, assuming that the data storage area is 16KB, when writing data for the first time, Figure 6a As shown, write 4KB, fill in 12KB of invalid data, and fill in the ECC check code corresponding to the 4KB data in the compensation space; if the data is written twice, such as Figure 6b As shown, if 12KB of data is written for the second time, the newly generated ECC check code cannot be written directly to the compensation space, because NAND needs to be erased before writing, and erasing is performed on the entire block, so the 4KB of valid data written for the first time is erased, resulting in a write data conflict. Therefore, in this implementation, the above-mentioned write conflict is solved on the basis that data can be stored multiple times for each page. Exemplarily, assuming that the total capacity (first length) of the data storage area is 16KB, it can be divided into 4 data storage sub-areas: Sector 0, Sector 1, Sector 2, Sector 3, the capacity of each data storage sub-area is 4KB, the data length of the data to be written is 7KB, and the target write address is Sector 0 of the blank page, then the data storage sub-areas corresponding to the current write operation include Sector 0 and Sector 1, wherein the valid data stored in Sector 0 is 4KB, and the valid data stored in Sector 1 is 3KB, then, if Figure 7 As shown, a first ECC check code ECC 0 is generated based on the valid data stored in Sector 0, and a first ECC check code ECC1 is generated based on the data stored in Sector 1, and ECC 0 and ECC 1 are respectively stored in the first compensation space area corresponding to the corresponding data storage sub-area.

[0052] Furthermore, in another implementation, the method further includes: when the data storage sub-area has been written with the valid data and is not full, writing invalid data into the remaining storage space of the data storage sub-area except the valid data. That is, valid data is stored in the data storage sub-area, but there is still some space left in the data storage sub-area, so invalid data can be written into the remaining space based on the NAND characteristics. Figure 7 In the corresponding example, the valid data stored in Sector 1 is 3KB, and the remaining space is still 1KB, so the 1KB of invalid data is filled into the remaining space. Then, for each page of the first address range space, the smaller the capacity of each data storage sub-area is divided, that is, the more sub-areas are divided, the more refined writing can be achieved, and the storage space can be fully utilized. Therefore, the divided sub-areas can be dynamically adjusted according to actual needs, and the embodiment of the present application does not specifically limit the number of sub-areas divided.

[0053] In one implementation, the data stored in the target page is migrated to the second address range space in units of pages, including: when the length of the data stored in the target page reaches the first length, merging the data in the M data storage sub-areas in the target page to obtain the migration data of the first length; generating the second ECC check code based on the migration data of the first length; writing the migration data of the first length into the target data storage area, and writing the second ECC check code into the target compensation space area, wherein the target data storage area and the target compensation space area are the data storage area and the second compensation space area corresponding to the blank page in the second address range space, respectively; and erasing the target page.

[0054] It is understandable that when a page is full, that is, the M data storage sub-areas are full, the page data can be integrated and written into the second address range space in units of pages, while erasing the resources stored in the target page, thereby realizing dynamic migration of data.

[0055] For example, Figure 8a As shown in the figure, assuming that 4 write operations are performed, each of which writes 1KB of data, then the valid data in Sector 0, Sector 1, Sector 2, and Sector 3 are all 1KB, and the remaining 3KB are all invalid data. Therefore, if the page data is migrated to the second address range space, the space utilization rate corresponding to the page can be 1 / 4, and the resource waste rate is 3 / 4. If the traditional storage method is used, such as Figure 8bAs shown, if the input is in pages, each page only stores 1KB of valid data, and the remaining 15KB are invalid data. The space utilization rate of a page can be 1 / 16, and the resource waste rate is 15 / 16. It can be seen that this implementation method can effectively improve resource utilization compared to traditional storage methods and avoid wasting storage space due to scattered small data.

[0056] In addition, when data is merged, the first ECC check code corresponding to the data in each data storage sub-area will be discarded, such as Fig. 9 As shown, a third ECC check code is regenerated based on the merged data, ie, the migration data, thereby avoiding the writing conflict of the ECC check code.

[0057] Furthermore, in one implementation, the method further includes: updating an address mapping table corresponding to the migration data.

[0058] The address mapping table is used to store the mapping relationship between logical addresses and physical addresses. In memory management, the operating system converts logical addresses into physical addresses according to its own algorithm, so that the application can read and write data in the memory normally. Therefore, in this implementation, since the data migration process will cause changes in the physical address, it is necessary to update the address mapping table in a timely manner to facilitate the accurate reading of subsequent data. Fig.10 The figure shows an example of address update.

[0059] Based on the above implementations, as shown in Figure 11, the present application provides a specific embodiment of a data writing method, which may include the following steps:

[0060] S1110: Data writing.

[0061] The memory receives externally written data normally.

[0062] S1120: Is the data larger than the capacity of 1 Page?

[0063] Determine whether the amount of data written is greater than a single NAND page. If a single SLC NAND page is 16KB, determine whether the amount of data written is greater than 16KB.

[0064] If it is less than that, it is regarded as scattered data, and the data is written into the first address range space and transposed S1130;

[0065] If it is greater, it is regarded as normal writing, and the data is written into the second address range space and transposed S1150.

[0066] S1130: Writing into the first address range space sequentially according to the data storage sub-areas within the page.

[0067] In the first address range, the Page is divided into several data storage sub-areas and a corresponding number of compensation spaces. Data is written in blocks as the smallest unit and stored in sequence until it is full. The written data is ECCed with the data in a single data storage sub-area, and the ECC check code is placed in the corresponding compensation space area.

[0068] S1140: Read the full single page of data in the first address range space.

[0069] When a page is filled up in blocks, the data of the entire page is read out together.

[0070] S1150: Write into the second address range space.

[0071] The full page of data written above is written into the normal address space in units of pages. At this time, the entire page of data is processed with ECC to generate an overall ECC check code.

[0072] S1160: Update the logical address table.

[0073] The address changes caused by the above data movement process are updated in the logical address mapping table in a timely manner so that subsequent data can be read accurately.

[0074] In this embodiment, by dividing the special address space, the original process of only being able to write the entire page is split into a process of writing by block. At the same time, the ECC algorithm is changed, and the data in each block is individually ECC checked, so that each page can be written with data multiple times, making full use of the storage space wasted by writing scattered small data in units of pages, thereby improving the utilization efficiency of the NAND SLC area.

[0075] Fig.12 A schematic diagram showing the structure of a data writing device provided by an embodiment of the present application is shown as follows: Fig.12 As shown,

[0076] The data writing device 1200 may include: a receiving module 1201 and a writing module 1202 .

[0077] In this embodiment, the receiving module 1201 is used to receive the data to be written and determine the data length of the data to be written; the writing module 1202 is used to write the data to be written in sequence into the first address range space starting from the target write position when the data length is less than the first length, wherein the first address range space is composed of N pages of the first capacity, each page includes M data storage sub-areas of the second capacity and a first compensation space area corresponding to each of the data storage sub-areas, the first compensation space area is used to store a first ECC check code corresponding to the first data, the first data is the data stored in the data storage sub-area corresponding to the first compensation space area, the first length is the sum of M second capacities, N is an integer greater than or equal to 1, and M is an integer greater than 1.

[0078] In one implementation, the data writing device 1200 may also include a migration module 1203, which is used to migrate the data stored in the target page to the second address range space in units of pages when there is a target page in the first address range space; wherein the second address range space is composed of X pages of the first capacity, each page includes a data storage area and a second compensation space area corresponding to the data storage area, the second compensation space area is used to store a second ECC check code corresponding to the second data, the second data is the data stored in the data storage area, the capacity of the data storage area is the first length, the target page is a page in which M of the data storage sub-areas are fully written, and X is an integer greater than or equal to 1.

[0079] In one implementation, the write module 1202 is also used to: when the data length is equal to the first length, write the data to be written into the second address range space in sequence; when the data length is greater than the first length, write the third data into the second address range space in sequence, and write the fourth data into the first address range space in sequence, wherein the length of the third data is an integer multiple of the first length, and the length of the fourth data is the difference between the length of the data and the length of the third data.

[0080] In one implementation, writing the data to be written into the first address range space in sequence includes: for any data storage sub-area corresponding to the current write operation, when valid data has been written into the data storage sub-area, generating the first ECC check code based on the valid data, and writing the first ECC check code into the first compensation space area corresponding to the data storage sub-area.

[0081] In one implementation, the writing module 1202 is further configured to: when the data storage sub-area has been written with the valid data but is not full, write invalid data into the remaining storage space of the data storage sub-area except the valid data.

[0082] In one implementation, the data stored in the target page is migrated to the second address range space in units of pages, including: when the length of the data stored in the target page reaches the first length, merging the data in the M data storage sub-areas in the target page to obtain the migration data of the first length; generating the second ECC check code based on the migration data of the first length; writing the migration data of the first length into the target data storage area, and writing the second ECC check code into the target compensation space area, wherein the target data storage area and the target compensation space area are the data storage area and the second compensation space area corresponding to the blank page in the second address range space, respectively; and erasing the target page.

[0083] In one implementation, the data writing device 1200 may further include an updating module, and the updating module is used to update the address mapping table corresponding to the migration data.

[0084] In one implementation, the data writing device 1200 may also include a determination module, which is used to determine that the target write position is the starting position of the next data storage sub-area adjacent to the target data storage sub-area, wherein the target data storage sub-area is the end data storage sub-area corresponding to the previous write operation.

[0085] The data writing device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.

[0086] The data writing device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0087] The data writing device provided in the embodiment of the present application can achieve Figures 1 to 11 To avoid repetition, the various processes implemented in the illustrated method embodiment will not be described again here.

[0088] Alternatively, if Fig.13 As shown, an embodiment of the present application also provides an electronic device 1300, including a processor 1301 and a memory 1302, wherein the memory 1302 stores programs or instructions that can be executed on the processor 1301, and when the program or instructions are executed by the processor 1301, the various steps of the above-mentioned data writing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not repeated here.

[0089] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0090] Fig.14 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0091] The electronic device 1400 includes but is not limited to: a radio frequency unit 1401, a network module 1402, an audio output unit 1403, an input unit 1404, a sensor 1405, a display unit 1406, a user input unit 1407, an interface unit 1408, a memory 1409, and a processor 1410 and other components.

[0092] Those skilled in the art will appreciate that the electronic device 1400 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1410 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.14 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0093] The radio frequency unit 1401 is used to receive the data to be written and determine the data length of the data to be written.

[0094] Processor 1410 is used to write the data to be written into the first address range space in sequence starting from the target write position when the data length is less than the first length, wherein the first address range space is composed of N pages of the first capacity, each page includes M data storage sub-areas of the second capacity and a first compensation space area corresponding to each of the data storage sub-areas, the first compensation space area is used to store a first ECC check code corresponding to the first data, the first data is the data stored in the data storage sub-area corresponding to the first compensation space area, the first length is the sum of M second capacities, N is an integer greater than or equal to 1, and M is an integer greater than 1.

[0095] Optionally, the processor 1410 is further used to: when a target page exists in the first address range space, migrate the data stored in the target page to the second address range space in units of pages; wherein the second address range space is composed of X pages of the first capacity, each page includes a data storage area and a second compensation space area corresponding to the data storage area, the second compensation space area is used to store a second ECC check code corresponding to second data, the second data is the data stored in the data storage area, the capacity of the data storage area is the first length, the target page is a page in which M of the data storage sub-areas are fully written, and X is an integer greater than or equal to 1.

[0096] Optionally, processor 1410 is also used to: when the data length is equal to the first length, write the data to be written into the second address range space in sequence; when the data length is greater than the first length, write the third data into the second address range space in sequence, and write the fourth data into the first address range space in sequence, wherein the length of the third data is an integer multiple of the first length, and the length of the fourth data is the difference between the length of the data and the length of the third data.

[0097] Optionally, the processor 1410 is further used to: for any data storage sub-area corresponding to a current write operation, when valid data has been written into the data storage sub-area, generate the first ECC check code based on the valid data, and write the first ECC check code into the first compensation space area corresponding to the data storage sub-area.

[0098] Optionally, the processor 1410 is further configured to: when the data storage sub-area has been written with the valid data but is not full, write invalid data into the remaining storage space of the data storage sub-area except the valid data.

[0099] Optionally, the processor 1410 is also used to: when the length of the data stored in the target page reaches the first length, merge the data in the M data storage sub-areas in the target page to obtain migration data of the first length; generate the second ECC check code based on the migration data of the first length; write the migration data of the first length into the target data storage area, and write the second ECC check code into the target compensation space area, wherein the target data storage area and the target compensation space area are the data storage area and the second compensation space area corresponding to the blank page in the second address range space, respectively; and erase the target page.

[0100] Optionally, the processor 1410 is further configured to: update an address mapping table corresponding to the migration data.

[0101] Optionally, the processor 1410 is further used to: determine that the target write position is a starting position of a next data storage sub-region adjacent to the target data storage sub-region, wherein the target data storage sub-region is an end data storage sub-region corresponding to a previous write operation.

[0102] The electronic device provided in the embodiment of the present application can achieve Figures 1 to 11 To avoid repetition, the various processes implemented in the illustrated method embodiment will not be described again here.

[0103] It should be understood that in the embodiment of the present application, the input unit 1404 may include a graphics processor (Graphics Processing Unit, GPU) 14041 and a microphone 14042, and the graphics processor 14041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1406 may include a display panel 14061, and the display panel 14061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1407 includes a touch panel 14071 and at least one of other input devices 14072. The touch panel 14071 is also called a touch screen. The touch panel 14071 may include two parts: a touch detection device and a touch controller. Other input devices 14072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0104] The memory 1409 can be used to store software programs and various data. The memory 1409 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1409 may include a volatile memory or a non-volatile memory, or the memory 1409 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1409 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0105] The processor 1410 may include one or more processing units; optionally, the processor 1410 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1410.

[0106] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned data writing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0107] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0108] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned data writing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0109] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0110] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned data writing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0111] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0112] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0113] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A data writing method, characterized in that: include: Receiving data to be written, and determining the data length of the data to be written; In the case where the data length is less than the first length, starting from the target write position, the data to be written are written into the first address range space in sequence, wherein the first address range space is composed of N pages of the first capacity, each page includes M data storage sub-areas of the second capacity and a first compensation space area corresponding to each of the data storage sub-areas, the first compensation space area is used to store a first ECC check code corresponding to the first data, the first data is the data stored in the data storage sub-area corresponding to the first compensation space area, the first length is the sum of M second capacities, N is an integer greater than or equal to 1, and M is an integer greater than 1.

2. The method according to claim 1, characterized in that: The method further comprises: If a target page exists in the first address range space, data stored in the target page is migrated to the second address range space in units of pages; Among them, the second address range space is composed of X pages of the first capacity, each page includes a data storage area and a second compensation space area corresponding to the data storage area, the second compensation space area is used to store a second ECC check code corresponding to the second data, the second data is the data stored in the data storage area, the capacity of the data storage area is the first length, the target page is a page in which M of the data storage sub-areas are fully written, and X is an integer greater than or equal to 1.

3. The method according to claim 2, characterized in that The method further comprises: When the data length is equal to the first length, writing the data to be written into the second address range space in sequence; When the data length is greater than the first length, the third data is written into the second address range space in sequence, and the fourth data is written into the first address range space in sequence, wherein the length of the third data is an integer multiple of the first length, and the length of the fourth data is the difference between the data length and the length of the third data.

4. The method according to claim 2, characterized in that: The step of sequentially writing the data to be written into the first address range space includes: For any data storage sub-area corresponding to the current write operation, when valid data has been written into the data storage sub-area, the first ECC check code is generated based on the valid data, and the first ECC check code is written into the first compensation space area corresponding to the data storage sub-area.

5. The method according to claim 4, characterized in that The method further comprises: When the valid data has been written into the data storage sub-region and is not full, invalid data is written into the remaining storage space of the data storage sub-region except the valid data.

6. The method according to claim 2, characterized in that The step of migrating the data stored in the target page to the second address range space in units of pages includes: When the length of the data stored in the target page reaches the first length, merging the data in the M data storage sub-areas in the target page to obtain the migration data of the first length; Generate the second ECC check code based on the migration data of the first length; Writing the migration data of the first length into a target data storage area, and writing the second ECC check code into a target compensation space area, wherein the target data storage area and the target compensation space area are the data storage area and the second compensation space area corresponding to the blank page in the second address range space, respectively; The target page is erased.

7. The method according to claim 6, characterized in that The method further comprises: The address mapping table corresponding to the migration data is updated.

8. The method according to claim 1, characterized in that Before writing the data to be written into the first address range space in sequence starting from the target writing position, the method further includes: The target write position is determined to be a starting position of a next data storage sub-region adjacent to the target data storage sub-region, wherein the target data storage sub-region is an end data storage sub-region corresponding to a previous write operation.

9. A data writing device, characterized in that: The device comprises: A receiving module, used for receiving data to be written and determining the data length of the data to be written; A writing module, used for, when the data length is less than the first length, writing the data to be written in sequence into a first address range space starting from a target writing position, wherein the first address range space is composed of N pages of a first capacity, each page includes M data storage sub-areas of a second capacity and a first compensation space area corresponding to each of the data storage sub-areas, the first compensation space area is used to store a first ECC check code corresponding to the first data, the first data is the data stored in the data storage sub-area corresponding to the first compensation space area, the first length is the sum of the M second capacities, N is an integer greater than or equal to 1, and M is an integer greater than 1.

10. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the data writing method according to any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Processing method for enhancing reliability of flash memory data and flash memory

    CN119620942A

  • Processing method for enhancing flash memory data reliability and flash memory storage

    CN119620942B

  • Flash memory data processing method and system based on filling position variability

    CN120255793A