Data processing method and data processing device for flash memory

By dividing the flash memory into multiple storage regions and optimizing address mapping lookup, the problems of low update efficiency and rapid aging in existing technologies are solved, achieving more efficient data updates and a longer lifespan.

CN116547652BActive Publication Date: 2026-07-10HUAWEI TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2020-12-03
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing flash memory data update methods require erasing the entire page when updating partial data, resulting in low efficiency, accelerated aging, and reduced lifespan.

Method used

The flash memory page is divided into an initial data area, a remapped data area, and an address remapped area. By storing the updated data and its address mapping relationship in the remapped area, the entire page is avoided from being erased with each update, and the address mapping lookup process is optimized by using a marked area.

Benefits of technology

It improves data update efficiency, reduces flash memory aging, and extends lifespan.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116547652B_ABST
    Figure CN116547652B_ABST
Patent Text Reader

Abstract

A data updating method and a data processing device for a flash memory are provided. In a page of the flash memory, in addition to an initial data area for storing initial data, a remapping data area for storing updated data and an address remapping area for storing a mapping relationship between the address of the updated data and an original address are also divided. When data in the original address in the initial data area is updated, the updated data is stored in the remapping data area, and the mapping relationship between the original address and the address of the updated data is recorded. With the method, the data in the entire page does not need to be erased and all the data containing the updated data need to be reprogrammed every time the data is updated, so that the data updating efficiency of the flash memory can be improved, and the aging speed of the flash memory can be reduced to improve the service life of the flash memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of storage, and more specifically, to a data processing method and a data processing apparatus for flash memory. Background Technology

[0002] Flash memory is a type of storage chip that allows data stored in it to be modified or updated through specific programs. Flash memory can be used to store bootloaders, operating systems, or program code, or it can be used directly as a hard drive.

[0003] In existing flash data update methods, when updating data stored in a page, even if the page only needs to update 1 bit of data, the entire page's data must first be read and cached in memory, and then the entire page must be erased. After erasing, the data stored in memory is written back to the page, and the updated data at that address is written as the latest value. After writing, the entire page's data is read out and compared with the data stored in memory to determine whether the written data is correct.

[0004] With the widespread use of Flash, large-capacity Flash content is becoming increasingly common. Large-capacity Flash designs typically have a large page size. According to the existing page update process, each time data in a portion of the page needs to be updated, a complete page update is required. This not only takes a long time and affects update efficiency, but also causes unnecessary erasure of other addresses, accelerating the aging of the Flash content. Summary of the Invention

[0005] This application provides a new data processing method and device for flash memory, which can improve data update efficiency, thereby improving the business interaction performance of flash memory; it can also slow down the aging speed of flash memory and extend its service life.

[0006] In a first aspect, this application provides a data processing method for flash memory. Pages in the flash memory are divided into multiple storage areas, including an initial data area, a remapped data area, and an address remapping area. The method includes: receiving a data update request message, the data update request message being used to request updating data at a specified address of a specified page in the flash memory to specified data, the specified address being an address in the initial data area; writing the specified data to a currently available address in the remapped data area; and writing the address mapping relationship between the specified address and the currently available address in the remapped data area into the address remapping area.

[0007] In this method, the flash memory, in addition to the initial data area storing the initial data, is further divided into a remapped data area for storing updated data and an address remapping area for storing the mapping relationship between the storage address of the updated data and the original address. Furthermore, when updating data at the original address in the initial data area, this method stores the updated data in the remapped data area and records the mapping relationship between the original address and the address storing the updated data. Therefore, when updating data in the flash memory using this method, it is not necessary to erase the entire page of data and rewrite all data containing the updated data every time data is updated. This improves the data update efficiency of the flash memory and reduces the aging rate of the flash memory, thereby extending its lifespan.

[0008] In conjunction with the first aspect, in a first possible implementation, the designated page further includes a marker region. Accordingly, the method further includes: determining whether there are still available marker bits in the marker region, the marker bits indicating whether an address mapping relationship is stored in the address remapping region corresponding to the marker bits; and, if there are still available marker bits in the marker region, determining the currently available address in the address remapping region based on the available marker bits in the marker region.

[0009] In this implementation, an additional flag region is allocated within the flash memory. This flag region uses marker bits to indicate whether the corresponding addresses in the addrremap region already have address mapping relationships stored. Thus, based on the marker bits in the flag region, it can be determined whether there is still storage space in the addrremap region capable of storing address mapping relationships. If there is such storage space, the currently available addresses in the addrremap are calculated based on the marker bit positions. This eliminates the need to read the contents of each address in the addrremap region one by one to determine if there is still storage space for address mapping relationships and to search for currently available addresses. This saves time searching for currently available addresses in the addrremap region, thereby improving the data update efficiency of the flash memory.

[0010] In conjunction with the first possible implementation, in the second possible implementation, the method further includes: receiving a data read request message, the data read request message being used to request reading data from the specified address in the specified page; determining whether the marked area is empty; if the marked area is not empty, determining the end storage address in the address remapping region based on the number of flag bits in the marked area representing the address already stored in the corresponding address in the address remapping region, the end storage address being the last address in the address remapping region that has stored an address mapping relationship; querying the storage space between the start storage address and the end storage address in the address remapping region for a target address mapping relationship containing the specified address, the start storage address being the address of the first stored address mapping relationship in the address remapping region; reading data from the target address in the remapping data region according to the target address mapping relationship, the target address being an address in the target address mapping relationship that has a mapping relationship with the specified address; if the marked area is not empty, reading data from the specified address.

[0011] In conjunction with the first aspect, in a third possible implementation, the method further includes: determining whether there are still available addresses in the address remapping region. Accordingly, writing the specified data to the currently available address in the remapping data region includes: if there are still available addresses in the address remapping region, writing the specified data to the currently available address in the remapping data region.

[0012] In this implementation, the specified data is written to the remap data area only if there are still available addresses in the addr remap area, and the corresponding address mapping relationship is written to the addr remap area. This can avoid data overflow and thus avoid data loss.

[0013] In conjunction with the third possible implementation, in the fourth possible implementation, the method further includes: receiving a data read request message, the data read request message being used to request reading data from the specified address in the specified page; querying a target address mapping relationship containing the specified address in the storage space between the start storage address and the end storage address of the address remapping region, the start storage address being the address of the first stored address mapping relationship in the address remapping region, and the end storage address being the address of the last stored address mapping relationship in the address remapping region; and reading data from the target address in the remapping data region according to the target address mapping relationship, the target address being an address in the target address mapping relationship that has a mapping relationship with the specified address.

[0014] In a fifth possible implementation, combining the second or fourth possible implementations, the step of querying the target address mapping relationship containing the specified address in the storage space between the starting storage address and the ending storage address of the address remapping region includes: sequentially reading the address mapping relationships stored in the storage space corresponding to each address in the address remapping region in the order from the ending storage address to the starting storage address, and determining whether the address mapping relationship in each address is an address mapping relationship containing the specified address, until the read address mapping relationship is an address mapping relationship containing the specified address, and taking the last read address mapping relationship as the target address mapping relationship.

[0015] Secondly, this application provides a flash memory data processing apparatus, wherein pages in the flash memory are divided into multiple storage areas, the multiple storage areas including an initial data area, a remapped data area and an address remapped area, and the apparatus may include one or more functional modules for implementing the method in the first aspect or any of the implementations thereof, each functional module being implemented by software and / or hardware.

[0016] For example, the device includes a receiving module and a writing module. The receiving module is used to receive a data update request message, which requests that data at a specified address of a specified page in the flash memory be updated to specified data, where the specified address is an address in the initial data area. The writing module is used to write the specified data to a currently available address in the remapped data area. The writing module is also used to write the address mapping relationship between the specified address and the currently available address in the remapped data area into the address remapping area.

[0017] In a first possible implementation, the designated page further includes a marker region. Correspondingly, the device further includes a judgment module and a determination module. The judgment module is used to determine whether there are any available marker bits in the marker region, the marker bits indicating whether an address mapping relationship is stored in the address remapping region corresponding to the marker bits; the determination module is used to determine the currently available address in the address remapping region based on the available marker bits in the marker region, if there are no available marker bits in the marker region.

[0018] In conjunction with the first possible implementation, in the second possible implementation, the receiving module is further configured to receive a data read request message, which is used to request the reading of data from the specified address on the specified page.

[0019] Accordingly, the device further includes a judgment module, a determination module, a query module, and a reading module. The judgment module is used to determine whether the marked area is empty; the determination module is used, when the marked area is not empty, to determine the end storage address in the address remapping region based on the number of flag bits in the marked area representing the address already stored in the corresponding address in the address remapping region, wherein the end storage address is the last address in the address remapping region that has stored an address mapping relationship; the query module is used to query the storage space between the start storage address and the end storage address of the address remapping region for a target address mapping relationship containing the specified address, wherein the start storage address is the address of the first stored address mapping relationship in the address remapping region; the reading module is used to read data from the target address in the remapping data region according to the target address mapping relationship, wherein the target address is the address in the target address mapping relationship that has a mapping relationship with the specified address; the reading module is also used to read data from the specified address when the marked area is not empty.

[0020] In another possible implementation, the device further includes a judgment module and a determination module, wherein the judgment module is used to determine whether there are still available addresses in the address remapping region, and the determination module is used to determine the currently available addresses.

[0021] Accordingly, the writing module is specifically used to: write the specified data into the currently available address in the remapped data area when there is still a usable address in the address remapping area.

[0022] In this implementation, optionally, the receiving module is further configured to receive a data read request message, the data read request message being used to request the reading of data from the specified address on the specified page.

[0023] Accordingly, the device further includes a query module and a read module. The query module is used to query the storage space between the starting storage address and the ending storage address of the address remapping region for a target address mapping relationship containing the specified address. The starting storage address is the address of the first stored address mapping relationship in the address remapping region, and the ending storage address is the address of the last stored address mapping relationship in the address remapping region. The read module is used to read data from the target address in the remapping data region according to the target address mapping relationship. The target address is the address in the target address mapping relationship that has a mapping relationship with the specified address.

[0024] In some possible implementations, the query module may be further configured to: sequentially read the address mapping relationships stored in the storage space corresponding to each address in the address remapping region in the order from the end storage address to the start storage address, and determine whether the address mapping relationship in each address is an address mapping relationship that includes the specified address, until the address mapping relationship read is the address mapping relationship of the specified address, and take the first read address mapping relationship as the target address mapping relationship.

[0025] Thirdly, this application provides a flash data processing apparatus, which may include a processor coupled to a memory. The memory is used to store program code, and the processor is used to execute the program code in the memory to implement the method in the first aspect or any of the implementations thereof.

[0026] Optionally, the device may also include the memory.

[0027] When the device is an electronic device, in some implementations the device may also include a transceiver for communicating with other devices; or it may also include input / output devices for user interaction.

[0028] When the device is a chip for use in an electronic device, in some implementations the device may also include a communication interface for communicating with other devices in the electronic device, such as for communicating with the transceiver of the electronic device.

[0029] Fourthly, this application provides a computer-readable storage medium that stores program code for execution by a processor, the program code including instructions for implementing the methods in the first aspect or any of the possible implementations thereof.

[0030] Fifthly, this application provides a computer program product containing instructions that, when executed on a processor, cause the processor to implement the method in the first aspect or any of the implementations thereof.

[0031] In a sixth aspect, this application provides a chip including logic circuitry and flash memory, the logic circuitry and flash memory being used to implement the method in the first aspect or any of the possible implementations thereof. Attached Figure Description

[0032] Figure 1 This is an illustrative example of an application scenario for the technical solution of this application embodiment;

[0033] Figure 2 This is a schematic diagram of the flash data storage structure according to an embodiment of this application;

[0034] Figure 3 This is a flowchart illustrating a data update method according to an embodiment of this application;

[0035] Figure 4 This is a flowchart illustrating a data reading method according to an embodiment of this application;

[0036] Figure 5 This is a flowchart illustrating a data update method according to an embodiment of this application;

[0037] Figure 6 This is a flowchart illustrating a data reading method according to another embodiment of this application;

[0038] Figure 7 A flowchart illustrating another embodiment of the data update method of this application;

[0039] Figure 8 This is a schematic diagram of the data storage structure of flash memory according to another embodiment of this application;

[0040] Figure 9 This is a schematic structural diagram of a data processing apparatus according to an embodiment of this application;

[0041] Figure 10 This is a schematic structural diagram of a data processing apparatus according to another embodiment of this application. Detailed Implementation

[0042] To better understand the technical solutions of the embodiments of this application, some concepts used in the embodiments of this application will be introduced below.

[0043] A device driver is a special program that enables communication between a computer and a device; it can be considered an interface to the hardware.

[0044] In some applications, drivers are independent of the operating system; in others, they are included within it. Regardless of the scenario, the operating system can only control the hardware device through this interface.

[0045] The flash driver in this application embodiment is a program that enables communication between the computer and the flash memory. The computer's operating system controls the flash memory's operation through the flash driver.

[0046] For example, such as Figure 1 As shown in the diagram on the left, applications running on the processor of an electronic device can use the operating system to call the flash driver to write data to, update, or read data from the flash memory.

[0047] As another possible implementation, such as Figure 1 As shown in the diagram on the right, an application running on the processor of an electronic device can write data to, update, or read data from the chip through the operating system. The chip may include a communication interface, logic circuits, and flash memory. After the communication interface receives a data write request, data update request, or data read request, the logic circuits can write data to, update, or read data from the flash memory according to the request.

[0048] Figure 2 This is a schematic diagram of the data storage structure of a Flash page according to one embodiment of this application. For example... Figure 2 As shown, this embodiment divides a Flash page into 5 regions: header region, initial data region, address remap region, remap data region, and flag region.

[0049] The head section is used to store the header information of this page, and the header information can be customized.

[0050] The initial data area, also known as the initial data space, is used to store the code and data initially written to the page. This code and data are collectively referred to as data information, or simply data.

[0051] The remap data area is reserved space. When updating data at a specified address in the initial data area, the address in the remap data area can be used to store the expected updated data at the specified address in the initial data area.

[0052] When updating data at a specified address in the initial data region, each address in the addr remap region is used to map the specified address in the initial data region to the new address of the updated data in the remap data region.

[0053] The flag area contains multiple flag bits, each corresponding one-to-one with a specific address in the addr remap area. Each flag bit in the flag area indicates whether the corresponding address in the addr remap area stores an address mapping relationship.

[0054] In this embodiment, when the flag bit indicates that the address corresponding to the address in the addr remap region has an address mapping relationship stored, it can be said that the flag bit is set to valid, or that the flag bit is valid; when the flag bit indicates that the address corresponding to the address in the addr remap region has no address mapping relationship stored, it can be said that the flag bit is invalid.

[0055] For example, a value of "1" indicates that the flag is valid, meaning that the address in the addr remap area has stored an address mapping relationship; a value of "0" indicates that the flag is invalid, meaning that the address in the addr remap area has not yet stored an address mapping relationship.

[0056] It is understood that the correspondence between the value of each flag bit in the above-mentioned flag area and whether the flag bit is valid, that is, whether the address in the addrremap area stores an address mapping relationship, is only an example, and this embodiment does not limit it.

[0057] Figure 3 yes Figure 2 The diagram shows an exemplary flowchart of a flash data update method. Figure 3 As shown, the method may include steps 301, 302, 303, 304, 305, 306, 307 and 308.

[0058] The method in this embodiment is executed by a flash data processing device. As an example, this data processing device is a flash driver running on a processor, or in other words, a processor running a flash driver. As another example, the data processing device is logic circuitry on a chip containing flash memory.

[0059] In this embodiment, the data processing device can record the address range of each region of the flash memory. For example, it can record the start address, end address, and size of each storage space in each region, or record the start address, total storage space size, and size of each storage space in each region.

[0060] 301, Receive a data update request message, the data update request message being used to request that the data in a specified address of a specified page in the flash be updated to the specified data.

[0061] For example, a data processing device can receive data update request messages from the operating system, or it can receive data update request messages sent by an application through the operating system. This message requests that data at a specified address on a specified page in Flash be updated to specified data.

[0062] When the data processing device is a driver, as an example, the data update request message may carry indication information of the specified page, the specified address, and the specified data.

[0063] When the data processing device is a logic circuit in a chip, the message may only carry the specified data.

[0064] 302, Read the information stored in the flag area of ​​the specified page.

[0065] For example, the data processing device can read all the flag bits in the storage space corresponding to the pre-recorded address range of the flag region of the specified page.

[0066] 303. Determine whether there are any available flag bits in the flag area. If yes, proceed to step 304; otherwise, proceed to step 308.

[0067] Alternatively, it can be said that it checks if there are any invalid flag bits in the flag region. Or, it can be said that it checks if all flag bits in the flag region are valid.

[0068] For example, following the order in which all the flag bits read in step 302 are used, starting from the first flag bit, each flag bit is checked sequentially to determine whether it is valid. That is, it is determined whether each flag bit indicates that the address mapping relationship is stored in the corresponding address in the addrremap area of ​​the specified page. If an invalid flag bit is found, that is, a flag bit indicating that the address mapping relationship is not stored in the corresponding address in the addrremap area, it is determined that there are still available flag bits in the flag area, and this flag bit is recorded as the currently available flag bit. If the last flag bit is valid, that is, the last flag bit indicates that the address mapping relationship is stored in the corresponding address in the addrremap area, it is determined that there are no available flag bits in the flag area.

[0069] 304. Determine the currently available address in the addr remap area based on the available flag bits in the flag area.

[0070] For example, the data processing device can pre-record the mapping relationship between the position of the flag bit in the flag region and the address corresponding to that flag bit in the addr remap region. In this way, the driver can find the corresponding address in the addr remap region based on the position of the currently available flag bit in the flag region and the mapping relationship. For ease of description, this embodiment refers to this address as the currently available address in the addr remap region.

[0071] 305, Store the mapping relationship between the specified address and the currently available address in the remap data area of ​​the specified page into the currently available address in the addr remap area.

[0072] As an example, the data processing device can write, store, or burn data into the remap data area in ascending or descending order of address, and record the address where the data is stored after each write. In this case, the data processing device can determine the currently available address in the remap data area based on that address.

[0073] 306, Store the specified data in the currently available address in the remap data area.

[0074] As an example, after the data processing device stores the specified data in the currently available address in the remap data area, it records the currently available address so that when updating the data next time, the next currently available address can be determined based on the current available address.

[0075] 307. Write a value to the currently available flag bit in the flag area, indicating that the currently available addresses in the addr remap area have stored address mapping relationships.

[0076] In other words, the currently available flag bits in the flag area are programmed as valid.

[0077] 308, entering the page transition process.

[0078] For example, all the content of the specified page can be written to another page, and then the content of the specified page can be erased. After erasing the content of the specified page, the content of the other page and the updated data can be written to the specified page.

[0079] The page-turning process described above is merely an example, and this embodiment does not limit it. Other page-turning processes can be implemented using existing technologies, which will not be elaborated here.

[0080] In the data update method of this embodiment, in the flash memory, in addition to the initial data area which stores the initial data, there is also a remap data area for storing updated data and an addr remap area for storing the mapping relationship between the storage address of the updated data and the original address. When updating the data in the original address in the initial data area, the updated data is stored in the remap data area, and the mapping relationship between the original address and the address in the remap data area where the updated data is stored is recorded, so that the data processing device can read the updated data based on the original address and the address mapping relationship.

[0081] This data update method does not require erasing the entire page data and rewriting all data containing the updated data every time a data update is performed. This can improve the data update efficiency of Flash and reduce the aging speed of Flash to extend its lifespan.

[0082] Furthermore, in this embodiment, an additional flag region is defined. This flag region uses marker bits to indicate whether the corresponding address in the addr remap region has already stored an address mapping relationship. This allows the data processing device to determine whether there is still storage space in the addr remap region that can store address mapping relationships based on the marker bits in the flag region. And if there is still storage space in the addr remap region that can store address mapping relationships, the device calculates the currently available address in the addr remap based on the position of the marker bits, instead of reading the contents of each address in the addr remap region one by one to determine whether there is still storage space in the addr remap region that can store address mapping relationships and searching for the currently available address in the addr remap region. This saves the time of searching for the currently available address in the addr remap region, thereby improving the data update efficiency of the flash memory.

[0083] It is understood that the execution order of steps 305 to 307 in this embodiment is just an example, and this embodiment does not limit the execution order of these three steps.

[0084] In response to the above-mentioned data update method for reading updated data, this application further proposes a new data reading method. Figure 4 This is a flowchart illustrating a data reading method according to an embodiment of this application.

[0085] like Figure 4 As shown, the data reading method of this embodiment may include steps 401, 402, 403, 404, 405, 406 and 407.

[0086] Figure 4 The method shown is performed by a data processing device. As an example, this data processing device is a flash driver running on a processor, or in other words, a processor running a flash driver. As another example, the data processing device is logic circuitry on a chip containing flash memory.

[0087] 401, Receive a data read request message, the data read request message being used to request the reading of data from a specified address in a specified page of the flash.

[0088] For example, the data read request message may include page indication information in the flash to indicate the page to which the data to be read belongs; the data read request message may also include address information in the specified page to indicate the address space of the data to be read.

[0089] 402. Read the information stored in the flag area of ​​the specified page. This step can be referred to step 302, and will not be repeated here.

[0090] 403. Determine whether the flag area is empty. If it is, proceed to step 407; otherwise, proceed to step 404.

[0091] As an example, read the contents of all flag bits in the flag area. If any flag bit indicates that the address mapping relationship has not yet been stored in the corresponding address in the addr remap area of ​​the specified page, then the flag area can be determined to be empty; otherwise, the flag area can be determined to be not empty.

[0092] 404. Based on the number of flag bits in the flag area that represent the address in the address corresponding to the address in the addr remap area of ​​the specified page that has stored the address mapping relationship, determine the end storage address in the addr remap area. The end storage address is the last address in the addr remap area that has stored the address mapping relationship.

[0093] For example, the data processing device can calculate the last address in the addr remap region that has stored the address mapping relationship based on the above quantity, the starting address of the addr remap region, and the unit address size in the addr remap region, and use this address as the end storage address.

[0094] It is understandable that the starting storage address of the addr remap region refers to the address where the first address mapping is stored in the addr remap region, and generally speaking, the data processing device stores the address mappings in the addr remap region in descending or ascending order of address.

[0095] 405. Query the target address mapping relationship containing the specified address in the storage space between the starting storage address and the ending storage address of the addr remap region, where the starting storage address is the address of the first storage address mapping relationship in the addr remap region.

[0096] As an example, the data processing device can sequentially read the address mapping relationships stored in the storage space corresponding to each address in the addr remap region, starting from the starting storage address and ending the storage address, and determine whether the address mapping relationship contains the specified address. If the address mapping relationship contains the specified address, then the address mapping relationship is determined as the target address mapping relationship.

[0097] As another example, the data processing device can sequentially read the address mapping relationships stored in the storage space corresponding to each address in the addr remap region, starting from the end storage address and proceeding to the start storage address, and determine whether the address mapping relationship contains the specified address. If the address mapping relationship contains the specified address, then the address mapping relationship is determined as the target address mapping relationship.

[0098] If the data at the specified address has been updated two or more times before reading the data at the specified address, then the latter example, compared with the former example, can query the latest target address mapping relationship of the specified address, thereby querying the storage address of the latest data, and thus being able to read the latest data.

[0099] 406. Read the data in the target address of the remap data area of ​​the specified page according to the target address mapping relationship, wherein the target address is an address that has a mapping relationship with the specified address and is included in the target address mapping relationship.

[0100] 407, Read the data at the specified address in the initial data area.

[0101] In this embodiment, if no address mapping relationship containing the specified address is found in step 405 until all storage space between the starting storage address and the ending storage address has been queried, then step 407 can be executed.

[0102] In another embodiment of this application, the flag region may not be divided in the flash memory. For example... Figure 8 As shown, the flash in this embodiment can be divided into a head region, an addr remap region, a remap data region, and an initial data region.

[0103] Accordingly, the flash data update method of this embodiment may not include steps 302, 303, 304, and 307. In this embodiment, after step 301 and before step 305, the following steps may be included: determining whether there are still available addresses in the addrremap region; if so, then executing step 305; otherwise, executing step 308.

[0104] The following examples illustrate how to determine if there are still available addresses in the addr remap region. It is understood that the embodiments in this application are not limited to a single implementation method for determining whether there are still available addresses in the addr remap region.

[0105] As an example, the data processing device writes address mapping expressions into the addr remap region, writing them in ascending order of address. In this example, when the data processing device determines whether there are still available addresses in the addr remap region, it can sequentially read the contents of the storage space corresponding to each address in the addr remap region in ascending order of address, and determine whether the storage space is available based on whether an address mapping relationship is already stored in that storage space. If an address mapping relationship is already stored in that storage space, then the address corresponding to that storage space is determined to be an unavailable address, and the device continues to read the contents of the storage space corresponding to the next address, repeating the aforementioned operation; otherwise, the address corresponding to that storage space is determined to be a available address, that is, it is determined that there are still available addresses in the addr remap region, and this available address is determined as the currently available address in the addr remap region.

[0106] If address mappings are stored in all storage spaces within the addr remap region, then it can be determined that there are no usable addresses left in the addr remap region.

[0107] As another example, when the data processing device writes address mappings to the addr remap region, it writes them in ascending order of address size. After each write, the device records the address to be mapped. Thus, when the data processing device needs to determine if there are still usable addresses in the addr remap region, it can check if the recorded address is the largest address in the region. If so, it can determine that there are no usable addresses left; otherwise, it can determine that there are still usable addresses. Adding the recorded address to the unit storage space size yields the currently usable address in the addr remap region.

[0108] As can be seen from the above embodiments, in the technical solution of this application, when the data processing device receives a message requesting to update the data in the specified address of the specified page in the flash to the specified data, it only needs to store the specified data in the storage space of the remap data area and record the mapping relationship between the new address corresponding to the storage space and the specified address in the addr remap area.

[0109] In other words, in the data update method proposed in this application, such as Figure 5 As shown, as long as steps 501, 502, 503, 504, and 505 are included, the goal of updating the data at the specified address can be achieved without erasing the entire page content, thereby saving data update time and increasing the lifespan of the flash memory.

[0110] 501, Receive a data update request message, the data update request message being used to request that the data at a specified address of a specified page in the flash be updated to the specified data.

[0111] This step can be referred to as step 301, and will not be repeated here.

[0112] 502. Determine whether there are still available addresses in the addr remap area of ​​the specified page. If yes, proceed to step 503; otherwise, proceed to step 505.

[0113] The method for determining whether there are still available addresses in the addr remap area of ​​the specified page is described in the aforementioned content and will not be repeated here.

[0114] Only when there are no available addresses in the addr remap area will the specified data be written to the remapdata area. The corresponding address mapping relationship is written to the addr remap area, which can avoid data overflow and thus avoid data loss.

[0115] 503. Write the address mapping relationship between the specified address and the currently available address in the remap data area of ​​the specified page into the currently available address in the addr remap area of ​​the specified page.

[0116] As an example, after writing the address mapping relationship into the currently available address in the addr remap area, the currently available address can be recorded as the end storage address.

[0117] 504, Write the specified data to the currently available address in the remap data area of ​​the specified page.

[0118] 505, Proceeding to the page transition process. This step can be referred to as step 308, and will not be repeated here.

[0119] Figure 5 A flowchart illustrating a data reading method corresponding to the data update method shown is as follows: Figure 6 As shown. The method may include steps 601, 602 and 603.

[0120] 601, Receive a data read request message, the data read request message being used to request the reading of data from a specified address in a specified page of the flash.

[0121] 602. Query the target address mapping relationship containing the specified address in the storage space between the starting storage address and the ending storage address of the addr remap area of ​​the specified page. The starting storage address is the address of the first stored address mapping relationship in the addr remap area, and the ending storage address is the address of the last stored address mapping relationship in the addr remap area.

[0122] 603. Read the data in the target address of the remap data area of ​​the specified page according to the target address mapping relationship, wherein the target address is an address that has a mapping relationship with the specified address and is included in the target address mapping relationship.

[0123] In this embodiment, steps 601, 602 and 603 can be referred to steps 401, 405 and 406 respectively, and will not be repeated here.

[0124] In some other embodiments of this application, optionally, the storage space of each page in flash can be designed to be large, and further, the addr remap area and remap data area can be designed to be large, for example, large enough that the storage space of all data updated during the lifecycle of the page will not exceed the storage space of the remap data area, and correspondingly, the storage space required for the address mapping relationship generated by the update will not exceed the storage space of the addr remap area.

[0125] The flowchart of the data update method in this embodiment is shown below. Figure 7 As shown. The method may include steps 701, 702 and 703.

[0126] 701, Receive a data update request message, the data update request message being used to request that the data at a specified address of a specified page in the flash be updated to the specified data.

[0127] 702. Write the address mapping relationship between the specified address and the currently available address in the remap data area of ​​the specified page into the currently available address in the addr remap area of ​​the specified page.

[0128] 703, Write the specified data to the currently available address in the remap data area of ​​the specified page.

[0129] Steps 701, 702, and 703 in this embodiment can be referred to as steps 501, 503, and 504 respectively, and will not be repeated here.

[0130] The data reading method corresponding to the data update method in this embodiment can be found in [reference]. Figure 6 The method shown will not be elaborated here.

[0131] It is understood that the data update method and data reading method in this application can be collectively referred to as the flash data processing method. Furthermore, the flash memory in various embodiments of this application may not include a header area. Additionally, the names of the header area, addr remap area, flag area, remap data area, and initial area in various embodiments of this application are merely examples; this application does not limit the names of these areas. As long as their functions are consistent with the functions of the areas in the foregoing embodiments, they fall within the protection scope of this application.

[0132] Figure 9 This is a schematic diagram of the structure of a data processing apparatus provided in one embodiment of this application. Figure 9The apparatus shown can be used to perform the method described in any of the foregoing embodiments. For example... Figure 9 As shown, the device 900 of this embodiment may include a receiving module 901 and a writing module 902. Optionally, the device 900 may further include a query module 903 and a reading module 904. Further, the device 900 may further include a judging module 905 and a determining module 906.

[0133] In one example, device 900 can be used to perform... Figure 3 The method described herein. For example, receiving module 901 can be used to execute step 301, reading module 906 can be used to execute step 302, judging module 905 can be used to execute step 303, determining module 906 can be used to execute step 304, and writing module 902 can be used to execute steps 305 to 308.

[0134] In one example, device 900 can be used to perform... Figure 4 The method described herein. For example, receiving module 901 can be used to execute step 401, reading module 906 can be used to execute step 402, judging module 905 can be used to execute step 403, determining module 906 can be used to execute step 404, querying module 903 can be used to execute step 405, and reading module 906 can also be used to execute steps 406 and 407.

[0135] In one example, device 900 can be used to perform... Figure 5 The method described herein. For example, the receiving module 901 can be used to execute step 501, the judging module 905 can be used to execute step 502, and the writing module 902 can be used to execute steps 503 to 505.

[0136] In one example, device 900 can be used to perform... Figure 6 The method described herein. For example, receiving module 901 can be used to execute step 601, query module 903 can be used to execute step 602, and reading module 906 can also be used to execute step 603.

[0137] In one example, device 900 can be used to perform... Figure 7 The method described herein. For example, receiving module 901 can be used to perform step 701, and writing module 902 can be used to perform steps 702 and 703.

[0138] Figure 10 This is a schematic diagram of the structure of a data processing apparatus provided in another embodiment of this application. Figure 10 The apparatus shown can be used to perform the method described in any of the foregoing embodiments.

[0139] like Figure 10As shown, the device 1000 of this embodiment includes: a memory 1001, a processor 1002, a communication interface 1003, and a bus 1004. The memory 1001, the processor 1002, and the communication interface 1003 are interconnected via the bus 1004.

[0140] The memory 1001 can be a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1001 can store programs, and when the program stored in the memory 1001 is executed by the processor 602, the processor 602 uses it to execute... Figures 3 to 7 The steps of the method shown in any figure.

[0141] The processor 1002 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, used to execute relevant programs to implement the methods in the various embodiments of this application.

[0142] The processor 1002 can also be an integrated circuit chip with signal processing capabilities. In implementation, each step of the method in the various embodiments of this application can be accomplished by the integrated logic circuitry in the hardware of the processor 1002 or by software instructions.

[0143] The processor 1002 described above can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0144] The steps of the method disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory 1001. Processor 1002 reads information from memory 1001 and, in conjunction with its hardware, performs the functions required by the units included in the apparatus of this application; for example, it can execute... Figures 3 to 7 Each step / function of the embodiment shown in any figure.

[0145] The communication interface 1003 can use, but is not limited to, transceivers to enable communication between the device 1000 and other devices or communication networks.

[0146] Bus 1004 may include a pathway for transmitting information between various components of device 1000 (e.g., memory 1001, processor 1002, communication interface 1003).

[0147] It should be understood that the device 1000 shown in the embodiments of this application may be an electronic device, or it may be a chip configured in an electronic device.

[0148] It should be understood that the processor in the embodiments of this application can be a central processing unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0149] It should also be understood that the memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM).

[0150] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.

[0151] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. A and B can be singular or plural. Additionally, the character " / " in this article generally indicates an "or" relationship between the preceding and following related objects, but it can also represent an "and / or" relationship. Please refer to the context for a more accurate understanding.

[0152] In this application, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or multiple items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0153] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0154] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0155] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0156] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0157] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0158] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0159] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.

[0160] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A data processing method for flash memory, characterized in that, The pages in the flash memory are divided into multiple storage areas, including an initial data area, a remapped data area, and an address remapping area; the method includes: Receive a data update request message, the data update request message being used to request that the data in a specified address of a specified page in the flash memory be updated to specified data, the specified address being an address in the initial data area; Write the specified data to the currently available address in the remapped data region; Write the address mapping relationship between the specified address and the currently available address in the remapping data area into the address remapping area; If the specified page includes a marked area, the method further includes: Receive a data read request message, the data read request message being used to request the reading of data from the specified address in the specified page; Determine whether the marked area is empty; If the marked area is not empty, the end storage address in the address remapping area is determined according to the number of marked bits in the marked area that indicate the address mapping relationship stored in the corresponding address in the address remapping area. The end storage address is the last address in the address remapping area that has stored the address mapping relationship. In the storage space between the starting storage address and the ending storage address of the address remapping region, query the target address mapping relationship containing the specified address, where the starting storage address is the address of the first storage address mapping relationship in the address remapping region; Data in the target address of the remapped data region is read according to the target address mapping relationship, wherein the target address is an address that has a mapping relationship with the specified address and is included in the target address mapping relationship; If the marked area is empty, read the data from the specified address.

2. The method according to claim 1, characterized in that, The method further includes: Determine whether there are still available flag bits in the marked area. The flag bits are used to indicate whether an address mapping relationship is stored in the address remapping area corresponding to the flag bits. If there are still available flag bits in the flag region, the current available address in the address remapping region is determined based on the available flag bits in the flag region.

3. The method according to claim 1, characterized in that, If the specified page does not include a marked area, the method further includes: determining whether there are still available addresses in the address remapping area; Accordingly, writing the specified data to the currently available address in the remapped data region includes: If there are still available addresses in the address remapping region, the specified data is written to the currently available address in the remapping data region.

4. The method according to claim 3, characterized in that, The method further includes: Receive a data read request message, the data read request message being used to request the reading of data from the specified address in the specified page; In the storage space between the starting storage address and the ending storage address of the address remapping region, query the target address mapping relationship containing the specified address. The starting storage address is the address of the first stored address mapping relationship in the address remapping region, and the ending storage address is the address of the last stored address mapping relationship in the address remapping region. Data in the target address of the remapped data region is read according to the target address mapping relationship, wherein the target address is an address that has a mapping relationship with the specified address and is included in the target address mapping relationship.

5. The method according to claim 1 or 4, characterized in that, The step of querying the target address mapping relationship containing the specified address in the storage space between the starting storage address and the ending storage address of the address remapping region includes: Following the order from the end storage address to the start storage address, the address mapping relationships stored in the storage space corresponding to each address in the address remapping region are read sequentially, and it is determined whether the address mapping relationship in each address is an address mapping relationship that includes the specified address, until the address mapping relationship read is an address mapping relationship that includes the specified address, and the last address mapping relationship read is taken as the target address mapping relationship.

6. A flash memory data processing apparatus, characterized in that, The pages in the flash memory are divided into multiple storage areas, including an initial data area, a remapped data area, and an address remapping area; the device includes: A receiving module is used to receive a data update request message, wherein the data update request message is used to request that the data in a specified address of a specified page in the flash memory be updated to specified data, and the specified address is an address in the initial data area; The writing module is used to write the specified data to the currently available address in the remapped data region; The writing module is further configured to write the address mapping relationship between the specified address and the currently available address in the remapping data area into the address remapping area; If the specified page includes a marked area, the receiving module is further configured to receive a data read request message, which is used to request the reading of data from the specified address on the specified page; The device also includes a judgment module, a determination module, a query module, and a reading module; The judgment module is used to determine whether the marked region is empty; The determining module is used to determine the end storage address in the address remapping region based on the number of flag bits in the flag region that represent the address in the address remapping region that have stored the address mapping relationship, when the flag region is not empty. The end storage address is the last address in the address remapping region that has stored the address mapping relationship. The query module is used to query the target address mapping relationship containing the specified address in the storage space between the starting storage address and the ending storage address of the address remapping region, where the starting storage address is the address of the first storage address mapping relationship in the address remapping region; The reading module is used to read data in the target address in the remapped data region according to the target address mapping relationship, wherein the target address is an address that has a mapping relationship with the specified address included in the target address mapping relationship; The reading module is also used to read data from the specified address when the marked area is empty.

7. The apparatus according to claim 6, characterized in that, The device further includes a judgment module and a determination module; The judgment module is used to determine whether there are still available marker bits in the marker area. The marker bits are used to indicate whether there is an address mapping relationship stored in the address remapping area corresponding to the marker bits. The determining module is used to determine the currently available address in the address remapping region based on the available flag bits in the flag region, if there are still available flag bits in the flag region.

8. The apparatus according to claim 6, characterized in that, If the specified page does not include a marked area, the device further includes a determination module for determining whether there are still available addresses in the address remapping area; Accordingly, the writing module is specifically used for: If there are still available addresses in the address remapping region, the specified data is written to the currently available address in the remapping data region.

9. The apparatus according to claim 8, characterized in that, The receiving module is also configured to receive a data read request message, the data read request message being used to request the reading of data from the specified address in the specified page; Accordingly, the device also includes a query module and a read module; The query module is used to query the target address mapping relationship containing the specified address in the storage space between the start storage address and the end storage address of the address remapping region. The start storage address is the address of the first stored address mapping relationship in the address remapping region, and the end storage address is the address of the last stored address mapping relationship in the address remapping region. The reading module is used to read data in the target address in the remapped data region according to the target address mapping relationship, wherein the target address is an address that has a mapping relationship with the specified address included in the target address mapping relationship.

10. The apparatus according to claim 6 or 9, characterized in that, The query module is specifically used for: Following the order from the end storage address to the start storage address, the address mapping relationships stored in the storage space corresponding to each address in the address remapping region are read sequentially, and it is determined whether the address mapping relationship in each address is an address mapping relationship that includes the specified address, until the address mapping relationship read is the address mapping relationship of the specified address, and the last address mapping relationship read is taken as the target address mapping relationship.

11. A flash memory data processing apparatus, characterized in that, The apparatus includes a processor coupled to a memory for executing program code in the memory to implement the method as described in any one of claims 1 to 5.

12. A computer-readable medium, characterized in that, The readable medium stores a computer program or instructions that, when executed by a processor, implement the method as described in any one of claims 1 to 5.

13. A chip, characterized in that, The device includes logic circuitry and flash memory, wherein pages in the flash memory are divided into multiple storage regions, including an initial data region, a remapped data region, and an address remapped region, and the logic circuitry is used to implement the method as described in any one of claims 1 to 5.

14. A computer program product capable of running on a processor, characterized in that, The computer program product includes instructions for implementing the method as described in any one of claims 1 to 5.