Flash memory writing method, system and equipment and storage medium
By determining the storage page layout and calculating the write offset, the problem of inconsistent page layouts of different manufacturers of TLC flash memory chips is solved, and normal data writing and testing efficiency are improved.
Patent Information
- Application Number
- CN202410860869.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-09-06
AI Technical Summary
The page layout of TLC flash memory chips from different manufacturers is inconsistent, resulting in the need to confirm according to the manual when writing and testing, affecting test efficiency and convenience.
By determining the storage page layout of the flash memory under test, calculating the write offset, and adjusting the written data to the target storage page, ensure that the data is written normally and avoid data loss.
It improves test efficiency and convenience, enables normal debugging of data writing to any storage page, without relying on flash memory manual restrictions, and enhances writing flexibility.
Smart Images

Figure CN118609633A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer memory, and in particular to a flash memory writing method, system, device and storage medium. Background Art
[0002] For different flash memories, in order to determine their flash memory quality, that is, the quality of NAND FLASH, the host computer usually specifies the block, page and other information to be written to NAND FLASH. The memory firmware interface receives these parameter information, calls the software interface for writing NAND FLASH, and writes data to the NAND FLASH location specified by the host computer. After the data is written, the written data is verified to be different from the actual written data content, and the quality of NAND FLASH can be confirmed.
[0003] For TLC (Triple-Level Cell) flash memory, a storage unit (the smallest unit for reading and writing data in flash memory, in pages) contains 1 to 3 storage pages. When writing NAND FLASH, it is necessary to write several consecutive pages in one storage unit together, otherwise data loss will occur. However, the page layout of TLC of each manufacturer is different, and it needs to be confirmed according to the manual of each model of NAND FLASH, which brings inconvenience to the writing and testing of TLC chips and affects the test efficiency. Summary of the invention
[0004] In view of this, an object of the present invention is to overcome the deficiencies in the prior art and to provide a flash memory writing method, system, device and storage medium.
[0005] The present invention provides the following technical solutions:
[0006] In a first aspect, the present application provides a flash memory writing method, comprising:
[0007] Determine the storage page layout of the flash memory to be tested, and determine the starting storage page of the storage unit corresponding to the input start writing storage page according to the storage page layout;
[0008] Determine a target start storage page corresponding to the start storage page of the storage unit, calculate a first difference between the input start writing storage page and the target start storage page, and determine the first difference as a write offset;
[0009] According to the write offset and the target start storage page, data is written starting from the target start storage page.
[0010] In one implementation, determining the starting storage page of the storage unit corresponding to the input start writing storage page according to the storage page layout includes:
[0011] Determine, according to the storage page layout, a range where the input data storage page for starting to be written is located and the number of storage pages within the range;
[0012] The starting storage page corresponding to the storage unit where the input data storage page for starting writing is located is determined according to the range where the input data storage page for starting writing is located and the number of storage pages in the range.
[0013] In one implementation, writing data starting from the target starting storage page according to the write offset and the target starting storage page includes:
[0014] Determine whether the write offset is 0. If the write offset is 0, the target write page is the target start storage page, and the write data is written starting from the target start storage page;
[0015] If the write offset is not 0, the target write page is the target start storage page, the pages between the target start storage page and the input start write storage page are all filled with 0, and the write data is written starting from the input start write storage page.
[0016] In one implementation manner, after writing data according to the target write page, the method includes:
[0017] Acquire the input end-writing data storage page, and determine the end storage page of the storage unit corresponding to the input end-writing data storage page;
[0018] It is determined whether the last storage page of the storage unit is a target last storage page of the target end storage unit.
[0019] In one implementation, determining the end storage page of the storage unit corresponding to the input end writing data storage page includes:
[0020] According to the storage page layout, determining a range where the inputted end-writing data storage page is located and the number of storage pages within the range;
[0021] The target end storage page of the storage unit where the input end-writing data storage page is located is determined according to the range where the input end-writing data storage page is located and the number of storage pages in the range.
[0022] In one implementation, the determining whether the last storage page of the storage unit is a target last storage page of the target end storage unit includes:
[0023] If the input end-writing data storage page is the target end storage page of the target end storage unit, then the writing is ended;
[0024] If the input end-write data storage page is not the target end storage page of the target end storage unit, all pages between the input end-write data storage page and the target end storage page are filled with 0s, and writing is completed at the target end storage page.
[0025] In a second aspect, the present application provides a flash memory writing system, comprising:
[0026] A determination module, used to determine the storage page layout of the flash memory to be tested, and determine the starting storage page of the storage unit corresponding to the input start writing storage page according to the storage page layout;
[0027] a calculation module, configured to determine a target start storage page corresponding to the start storage page of the storage unit, calculate a first difference between the input start writing storage page and the target start storage page, and determine the first difference as a write offset;
[0028] A writing module is used to write data starting from the target starting storage page according to the writing offset and the target starting storage page.
[0029] In a third aspect, the present application provides an electronic device, comprising a memory and at least one processor, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the flash memory writing method as described in the first aspect.
[0030] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, the flash memory writing method as described in the first aspect is implemented.
[0031] The embodiments of the present invention have the following beneficial effects:
[0032] The flash memory writing method provided by the present invention can adjust the data written to any storage page before writing, so that any data written to any storage page can be debugged normally, and there is no need to limit the location or number of written data according to the user manual of the flash memory, thereby improving the efficiency and convenience of testing.
[0033] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and understandable, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0035] Figure 1 A schematic diagram of a flash memory writing method flow is shown;
[0036] Figure 2 A schematic diagram of a method for confirming a data writing start storage page is shown;
[0037] Figure 3 A schematic diagram of a method for confirming a target starting storage page for writing data is shown;
[0038] Figure 4 A schematic diagram of a method for determining the last storage page of a flash memory is shown;
[0039] Figure 5 A schematic diagram of the framework structure of a flash memory writing system is shown.
[0040] Description of main component symbols:
[0041] 500, flash memory writing system; 501, determination module; 502, calculation module; 503, writing module. DETAILED DESCRIPTION
[0042] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0043] It should be noted that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0044] 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 in the specification of the template are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0045] Example 1
[0046] See also Figure 1 , Figure 1 A schematic flow chart of a flash memory writing method provided in this embodiment is mainly applied to TLC flash memory, and can also be applied to chips with the same or similar writing method as TLC flash memory. The method includes:
[0047] S101, determining a storage page layout of a flash memory to be tested, and determining a starting storage page of a storage unit corresponding to an input start writing storage page according to the storage page layout.
[0048] The storage unit of the flash memory is the smallest unit for writing data to the flash memory. Therefore, when writing data, it is written according to the storage unit. For TLC flash memory, a storage unit can have up to 3 storage pages. However, since data is not necessarily written from the starting storage page of a storage unit to the last storage page, it may start or end writing from the middle of a storage unit. It is necessary to adjust the data writing to start from the starting storage page of the storage unit and write to the last storage page of the storage unit.
[0049] However, the total number of storage pages of the flash memory and the number of storage pages corresponding to each storage unit can be determined. Therefore, the storage page layout of the flash memory can be determined first, and then the starting storage page and the ending storage page corresponding to each storage unit can be determined according to the storage page layout to facilitate subsequent data writing.
[0050] See also Figure 2 , step S101 further includes:
[0051] S1011. Determine, according to the storage page layout, a range where the input data storage page for starting writing is located and the number of storage pages within the range.
[0052] For example, first determine that the storage page of the flash memory to be tested is 2048 pages, that is, 2048 pages, among which, in the 10 pages between page0-9, each storage unit is 2 pages, that is, the first 10 pages have a total of 5 storage units. In the 1803 pages between page10 and 1812, each storage unit is 3 pages, that is, there are a total of 601 storage units, and each storage unit of the 236 pages between page1813 and 2048 is 2 pages. Based on this, for any incoming storage page, the number of storage pages corresponding to the storage unit where it is located can be obtained according to its range.
[0053] For example: page100 is between page10 and 1812, and the number of storage pages in its storage unit is 3.
[0054] S1012: Determine the starting storage page corresponding to the storage unit where the input data storage page for starting writing is located according to the range where the input data storage page for starting writing is located and the number of storage pages in the range.
[0055] Subtract the difference between the incoming storage page and the starting storage page of the storage page range that is consistent with the number of storage pages of the storage unit where the storage page is located, and then take the modulus of the difference with the number of storage pages of the storage units in the range to obtain the storage page offset of the incoming storage page in the storage unit, and then subtract the incoming storage page from the storage page offset to obtain the starting storage page of the storage unit where it is located.
[0056] After obtaining the starting storage page of the storage unit, the starting storage page of the storage unit + the number of storage pages of the storage unit - 1 is the ending storage page of the storage unit;
[0057] For example: the incoming storage page is page10, and the starting storage page of the storage page range whose number of storage pages of the storage unit where the storage page is located is consistent with that of the storage unit is 10. The incoming storage page - the starting storage page of the storage page range whose number of storage pages of the storage unit where the storage page is located is consistent with that of the storage unit, that is, 10-10 is 0. The remainder of the difference and the number of storage pages of the storage units in the range is 0 divided by 3. Its value is 0, which means that its offset is 0. Then the starting storage page of the storage unit where it is located is 10, and the storage unit starting storage page + the number of storage unit storage pages - 1 obtains the storage unit ending storage page of 12. Similarly, the remainder obtained by the same algorithm for storage page 11 is 1, which means that its offset is 1. page11-offset obtains the starting storage page of the storage unit where it is located as 10, and the storage unit starting storage page + the number of storage unit storage pages - 1 obtains the storage unit ending storage page of 12.
[0058] This embodiment determines the storage page layout of the flash memory, as well as the start storage page and the end storage page corresponding to each storage unit through the characteristics of the flash memory, thereby providing a data basis for subsequent data writing.
[0059] S102: Determine a target starting storage page corresponding to the starting storage page of the storage unit, calculate a first difference between the input start writing storage page and the target starting storage page, and determine the first difference as a write offset.
[0060] For example, if the input start writing storage page is page 11, that is, page 10, then the input start writing storage page is exactly the same as the starting storage page of the sixth storage unit, and the write offset is 10-10=0.
[0061] If the input start writing storage page is page 12, that is, page 11, the input start writing storage page is in the sixth storage unit, but the starting storage page of the sixth storage unit is page 10, and the write offset is 11-10=1.
[0062] This embodiment calculates the write offset to facilitate the formulation of subsequent data write rules, so that the data written according to the write rules can be easily debugged.
[0063] S103 . Writing data starting from the target starting storage page according to the write offset and the target starting storage page.
[0064] See also Figure 3 , step S103 further includes:
[0065] S1031. Determine whether the write offset is 0. If the write offset is 0, the target write page is the target start storage page, and write the write data starting from the target start storage page.
[0066] For example, if the input start writing storage page is page 11, that is, page 10, the input start writing storage page is exactly the same as the start storage page of the sixth storage unit, and the write offset is 0, then the write data can be written directly from the start storage page.
[0067] S1032. If the write offset is not 0, the target write page is the target start storage page, and all pages between the target start storage page and the input start write storage page are filled with 0, and the write data is written starting from the input start write storage page.
[0068] For example, if the incoming start writing storage page is page 12, that is, page 11, the incoming start writing storage page is in the sixth storage unit, but the starting storage page of the sixth storage unit is page 10, and the write offset is 11-10=1. At this time, it is necessary to start writing from the actual writing page, that is, page 11.
[0069] In this embodiment, the target write page is determined by the write offset and the target start storage page, so that the data written according to the target write page can meet the debugging requirements without causing data loss.
[0070] Due to the characteristics of TLC flash memory, if multiple consecutive storage pages of a storage unit are not written simultaneously, data loss may occur. Therefore, if the write offset is not 0, the page between the target starting storage page and the actual write page can be filled with 0, which will not cause data loss and can perform the test normally.
[0071] See also Figure 4 , Figure 4 A schematic flow chart of a method for determining the last storage page of a flash memory write provided by this embodiment.
[0072] In one embodiment, after writing data from the target starting storage page, the method further includes:
[0073] S104: Acquire the input data writing end storage page, and determine the end storage page of the storage unit corresponding to the input data writing end storage page.
[0074] Specifically, firstly, according to the storage page layout, a range of the inputted end-writing data storage page and the number of storage pages within the range are determined;
[0075] The end storage page of the storage unit where the input end-writing data storage page is located is determined according to the range where the input end-writing data storage page is located and the number of storage pages in the range.
[0076] S105 , determining whether the last storage page of the storage unit is the target last storage page of the target end storage unit.
[0077] If the input end-writing data storage page is the target end storage page of the target end storage unit, then the writing is ended;
[0078] If the input end-write data storage page is not the target end storage page of the target end storage unit, all pages between the input end-write data storage page and the target end storage page are filled with 0s, and writing is completed at the target end storage page.
[0079] Among them, the confirmation principle of the end storage page of the storage unit corresponding to the input end data writing storage page is basically the same as the confirmation method of the start storage page of the storage unit corresponding to the input start data writing page, so it will not be repeated here to avoid repetition.
[0080] For example, the storage pages included in the 7th storage unit are page 13 to page 15, that is, page 12-page 14. Therefore, the storage page at the end of the storage unit can be page 14.
[0081] If the incoming end-write data storage page is page14, it means that the write data has just filled up the 7th storage unit. At this time, the write can be terminated directly and the test result can be fed back.
[0082] If the incoming end write data storage page is not the last storage page of the target storage unit, for example, the end storage page is page13, it means that the write data does not fill the 7th storage unit. At this time, the pages between the incoming end write data storage page and the last storage page can be filled with 0, that is, the content of page14 can be filled with 0, so that data loss will not occur during the TLC flash memory write test due to the fact that the 7th storage unit is not full.
[0083] After determining the target write page for writing data, this embodiment determines the location of the storage page where writing needs to end by judging whether the input end write data storage page is the end storage page of the target storage unit, so that the written data just fills an integer number of storage units, and data loss will not occur due to incomplete writing of storage units in subsequent tests.
[0084] Example 2
[0085] See also Figure 5 The present application also provides a flash memory writing system 500, comprising:
[0086] A determination module 501 is used to determine a storage page layout of the flash memory to be tested, and determine a starting storage page of a storage unit corresponding to an input start writing storage page according to the storage page layout;
[0087] A calculation module 502 is used to determine a target start storage page corresponding to the target storage unit, calculate a first difference between the input start writing storage page and the target start storage page, and determine the first difference as a write offset;
[0088] The writing module 503 is used to write data starting from the target starting storage page according to the writing offset and the target starting storage page.
[0089] The flash memory writing system provided in this embodiment can adjust the data written to any storage page before writing, so that any data written to any storage page can be debugged normally. There is no need to limit the location or number of data written according to the flash memory user manual, thereby improving the efficiency and convenience of testing.
[0090] It can be understood that the implementation method of the flash memory writing method described in the above embodiment 1 is also applicable to this embodiment, so it will not be repeated here.
[0091] Example 3
[0092] The embodiment of the present application also provides a computer device, for example, the computer device can be, but is not limited to, a desktop computer, a notebook, etc., and its existence form is not limited, mainly depending on whether it needs to support the interface display function of the browser web page, etc. Exemplarily, the computer device includes a memory and at least one processor, the memory stores a computer program, and the processor is used to execute the computer program to implement the flash memory writing method described in the above embodiment 1.
[0093] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU) and a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. At least one of the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.
[0094] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.
[0095] Furthermore, the memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data (such as iteration data, version data, etc.) created according to the use of the computer device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0096] Example 4
[0097] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute the flash memory writing method described in the above embodiment 1.
[0098] It can be understood that the implementation method of the flash memory writing method described in the above embodiment 1 is also applicable to this embodiment, so it will not be repeated here.
[0099] The computer-readable storage medium may be either a non-volatile storage medium or a volatile storage medium. For example, the computer-readable storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0100] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0101] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0102] If the function is implemented in the form of a software function module 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 can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0103] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
[0104] In all examples shown and described herein, any specific values should be interpreted as merely exemplary and not as limiting, and thus other examples of the exemplary embodiments may have different values.
[0105] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0106] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. A flash memory writing method, It is characterized in that include: Determine the storage page layout of the flash memory to be tested, and determine the starting storage page of the storage unit corresponding to the input start writing storage page according to the storage page layout; Determine a target start storage page corresponding to the start storage page of the storage unit, calculate a first difference between the input start writing storage page and the target start storage page, and determine the first difference as a write offset; According to the write offset and the target start storage page, data is written starting from the target start storage page.
2. The flash memory writing method according to claim 1, It is characterized in that The step of determining the starting storage page of the storage unit corresponding to the input start writing storage page according to the storage page layout includes: Determine, according to the storage page layout, a range where the input data storage page for starting to be written is located and the number of storage pages within the range; The starting storage page corresponding to the storage unit where the input data storage page for starting writing is located is determined according to the range where the input data storage page for starting writing is located and the number of storage pages in the range.
3. The flash memory writing method according to claim 1, It is characterized in that The step of writing data from the target starting storage page according to the write offset and the target starting storage page includes: Determine whether the write offset is 0. If the write offset is 0, the target write page is the target start storage page, and the write data is written starting from the target start storage page; If the write offset is not 0, the target write page is the target start storage page, the pages between the target start storage page and the input start write storage page are all filled with 0, and the write data is written starting from the input start write storage page.
4. The flash memory writing method according to claim 3, It is characterized in that After the data is written from the target starting storage page, the method includes: Acquire the input end-writing data storage page, and determine the end storage page of the storage unit corresponding to the input end-writing data storage page; It is determined whether the last storage page of the storage unit is a target last storage page of the target end storage unit.
5. The flash memory writing method according to claim 4, It is characterized in that The step of determining the end storage page of the storage unit corresponding to the input end writing data storage page comprises: According to the storage page layout, determining a range where the input end-writing data storage page is located and the number of storage pages within the range; The end storage page of the storage unit where the input end-writing data storage page is located is determined according to the range where the input end-writing data storage page is located and the number of storage pages in the range.
6. The flash memory writing method according to claim 4, It is characterized in that The step of judging whether the last storage page of the storage unit is a target last storage page of the target end storage unit comprises: If the input end-writing data storage page is the target end storage page of the target end storage unit, then the writing is ended; If the input end-write data storage page is not the target end storage page of the target end storage unit, all pages between the input end-write data storage page and the target end storage page are filled with 0s, and writing is completed at the target end storage page.
7. A flash memory writing system, It is characterized in that include: A determination module, used to determine the storage page layout of the flash memory to be tested, and determine the starting storage page of the storage unit corresponding to the input start writing storage page according to the storage page layout; a calculation module, configured to determine a target start storage page corresponding to the start storage page of the storage unit, calculate a first difference between the input start writing storage page and the target start storage page, and determine the first difference as a write offset; A writing module is used to write data starting from the target starting storage page according to the writing offset and the target starting storage page.
8. An electronic device, It is characterized in that The method comprises a memory and at least one processor, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the flash memory writing method according to any one of claims 1 to 6.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed, the flash memory writing method according to any one of claims 1 to 6 is implemented.
