Reverse-order programming implementation method and device based on Flash memory

By identifying data characteristics and allocating reverse-order physical blocks for reverse writing, the problem of inflexible writing in Flash memory is solved, improving the intelligence and efficiency of the memory and extending its service life.

CN121704778APending Publication Date: 2026-03-20SHENZHEN JIADE SEMICONDUCTOR TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

The write operation of existing Flash memory is relatively mechanical, lacking flexibility and intelligence, making it difficult to achieve reverse writing to improve the intelligence and flexibility of the memory.

Method used

By obtaining the size and keyword of the data to be written, its modification frequency is determined, and the reverse physical blocks are allocated using the free block queue for writing, thus realizing data characteristic-driven reverse programming.

Benefits of technology

It improves the intelligence and flexibility of Flash memory, extends the lifespan of the memory, optimizes write efficiency, and reduces the risk of data loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121704778A_ABST
    Figure CN121704778A_ABST
Patent Text Reader

Abstract

The invention discloses a reverse programming implementation method and device based on a Flash memory, which are applied to electronic equipment, and the electronic equipment comprises the Flash memory. The method comprises the steps of obtaining a data size of to-be-written data to obtain a first data size; performing keyword extraction on the to-be-written data to obtain a target keyword; determining a first modification frequency of the to-be-written data according to the target keyword; when the first data size is smaller than the first preset data size and the first modification frequency is smaller than the first preset modification frequency, according to the first data size, distributing reverse-order physical blocks from the free block queue for the data to be written, and obtaining n reverse-order physical blocks; and writing the to-be-written data into the n inverted physical blocks. By adopting the method and the device, reverse writing of the Flash memory can be intelligently realized, so that the intelligence and the flexibility of the Flash memory are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage technology, and specifically to a method and apparatus for implementing reverse programming based on Flash memory. Background Technology

[0002] Flash memory is typically a non-volatile memory used in embedded systems to store system data, applications, and other information. Currently, Flash memory primarily uses sequential storage, resulting in a relatively mechanical and inflexible writing process. Therefore, the challenge of intelligently implementing reverse-order writing to Flash memory to improve its intelligence and flexibility urgently needs to be addressed. Summary of the Invention

[0003] This invention provides a method and apparatus for reverse programming based on Flash memory, which can identify the data characteristics of the data and intelligently realize reverse writing of Flash memory based on the data characteristics, so as to improve the intelligence and flexibility of Flash memory.

[0004] In a first aspect, embodiments of the present invention provide a method for reverse programming based on Flash memory, applied to an electronic device, the electronic device including Flash memory; the method for reverse programming based on Flash memory includes: Get the size of the data to be written, and obtain the first data size; Keyword extraction is performed on the data to be written to obtain the target keywords; Determine the first modification frequency of the data to be written based on the target keyword; When the first data size is less than the first preset data size and the first modification frequency is less than the first preset modification frequency, the data to be written is allocated in reverse order from the free block queue according to the first data size, resulting in n reverse order physical blocks; n is a positive integer. The data to be written is written into the n reverse-order physical blocks.

[0005] Secondly, embodiments of the present invention provide a reverse programming implementation device based on Flash memory, applied to an electronic device, the electronic device including Flash memory; the reverse programming implementation device based on Flash memory includes: an acquisition unit, an extraction unit, a determination unit, an allocation unit, and a writing unit, wherein, The acquisition unit is used to acquire the data size of the data to be written, and obtain the first data size; The extraction unit is used to extract keywords from the data to be written to obtain target keywords; The determining unit is configured to determine a first modification frequency of the data to be written based on the target keyword. The allocation unit is configured to allocate reverse-order physical blocks from the free block queue for the data to be written according to the first data size when the first data size is less than the first preset data size and the first modification frequency is less than the first preset modification frequency, thereby obtaining n reverse-order physical blocks; n is a positive integer. The writing unit is used to write the data to be written into the n reverse-order physical blocks.

[0006] Thirdly, embodiments of the present invention provide an electronic device, including a processor, a flash memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the flash memory and configured to be executed by the processor, and the programs include instructions for performing the steps in the first aspect of the present invention.

[0007] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform some or all of the steps described in the first aspect of the present invention.

[0008] Implementing the embodiments of the present invention has the following beneficial effects: As can be seen, the reverse programming method and apparatus based on Flash memory described in this embodiment of the invention are applied to electronic devices, which include Flash memory. The method involves obtaining the size of the data to be written, obtaining a first data size, extracting keywords from the data to be written, obtaining target keywords, determining a first modification frequency of the data to be written based on the target keywords, and allocating reverse physical blocks from the free block queue according to the first data size when the first data size is less than a first preset data size and the first modification frequency is less than the first preset modification frequency. This results in n reverse physical blocks, where n is a positive integer. The data to be written is then written into these n reverse physical blocks. Since the data size and keywords reflect the data characteristics, it is possible not only to identify whether the data to be written meets the reverse writing conditions based on the data characteristics, but also to intelligently allocate corresponding reverse physical blocks based on the data characteristics. Furthermore, the reverse writing operation for the data to be written is completed based on these reverse physical blocks. Thus, reverse writing of the Flash memory can be intelligently implemented based on the data characteristics of the data itself, thereby improving the intelligence and flexibility of the Flash memory. Attached Figure Description

[0009] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0010] Figure 1 This is a flowchart illustrating a reverse programming implementation method based on Flash memory provided in an embodiment of the present invention; Figure 2 This is a first structural schematic diagram of an electronic device provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the second structure of an electronic device provided in an embodiment of the present invention; Figure 4 This is a functional unit block diagram of a reverse programming implementation device based on Flash memory provided in an embodiment of the present invention. Detailed Implementation

[0011] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0012] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.

[0013] It should be understood that the term "and / or" in this document 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. Additionally, the character " / " in this document indicates that the preceding and following related objects are in an "or" relationship. In the embodiments of this invention, "multiple" refers to two or more.

[0014] In this invention, "at least one item" or similar expressions refer to any combination of these items, including any combination of a single item or multiple items. "One or more" means one or more, while "multiple" means two or more. For example, "at least one item" of a, b, or c can represent the following seven cases: a, b, c, a and b, a and c, b and c, a, b, and c. Each of a, b, and c can be an element or a set containing one or more elements.

[0015] In the embodiments of this invention, "connection" refers to various connection methods such as direct connection or indirect connection to achieve communication between devices. The embodiments of this invention do not impose any limitations on this.

[0016] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0017] In this embodiment of the invention, the electronic device involved can be understood as an electronic device with Flash memory. The electronic device may include smart home devices (such as smart TVs, smart refrigerators, smart washing machines, smart switch panels, etc.), Internet of Things devices, in-vehicle devices (smart dashcams, smart in-vehicle cameras, smart in-vehicle speakers, etc.), smart wearable devices (smart glasses, smart bracelets, smartwatches, etc.), computing devices or other processing devices connected to a wireless modem, as well as various forms of user equipment (UE), mobile station (MS), terminal device, smart portable hard drive, smart memory, smart chip, etc.

[0018] The embodiments of the present invention will be described in detail below.

[0019] Please see Figure 1 , Figure 1 This is a flowchart illustrating a reverse programming implementation method based on Flash memory provided by an embodiment of the present invention, applied to an electronic device, wherein the electronic device includes Flash memory; the reverse programming implementation method based on Flash memory includes: S101. Obtain the size of the data to be written, and get the first data size.

[0020] Among them, such as Figure 2As shown, the electronic device may include a Flash memory, which can be used to store data, for example, to write data or to read data. The data to be written may include at least one of the following: image data, video data, audio data, text data, program data, log data, sensor data, etc., without limitation.

[0021] In practice, the electronic device can obtain the size of the data to be written, thus obtaining a first data size. This data size reflects the characteristics of the data to some extent. On the one hand, the erase operation of Flash memory is performed in blocks, not bytes. If the data to be written spans multiple blocks, multiple erase operations may be required. On the other hand, reverse writing may affect the performance of Flash memory because Flash memory write operations are usually performed from low address to high address. Reverse writing may reduce the efficiency of write operations, especially when frequent erase and write operations are required. Therefore, the data to be written should not be too large when writing in reverse order.

[0022] S102. Extract keywords from the data to be written to obtain target keywords.

[0023] Keywords can include at least one of the following: strings, numbers, Chinese characters, images, etc., without limitation. Keywords reflect the inherent characteristics of the data to a certain extent, such as the importance of the data.

[0024] In practice, the number of target keywords can be one or more. Specifically, the electronic device can extract keywords from the data to be written to obtain target keywords, which are related to the modification frequency of the data to be written to some extent.

[0025] S103. Determine the first modification frequency of the data to be written based on the target keyword.

[0026] In a specific implementation, a pre-stored mapping relationship between keywords and modification frequencies can be used to determine the first modification frequency of the data to be written corresponding to the target keyword based on the mapping relationship.

[0027] Modification frequency can be understood as the number of write and erase operations performed on the Flash memory within a certain period of time. Modification frequency is typically used to measure the dynamism of data or the speed at which data is updated.

[0028] S104. When the first data size is less than the first preset data size and the first modification frequency is less than the first preset modification frequency, allocate reverse physical blocks from the free block queue for the data to be written according to the first data size, and obtain n reverse physical blocks; n is a positive integer.

[0029] The first preset data size can be preset or be the system default. The first preset data size can be related to the attribute information of the Flash memory, or it can be related to the environmental information of the Flash memory. The environmental information can include at least one of the following: the hardware environment information of the Flash memory, the software environment information of the Flash memory, the physical environment information of the Flash memory, etc., which are not limited here.

[0030] The attribute information of the Flash memory may include at least one of the following: the model of the Flash memory, the memory size of the Flash memory, the usage time of the Flash memory, etc., which are not limited here.

[0031] The hardware environment information of the Flash memory may include at least one of the following: hardware configuration information, circuit wiring information, interface standards, physical size, operating voltage, etc., which are not limited here.

[0032] The software environment information of the flash memory may include at least one of the following: development tools, drivers, file systems, firmware management and security mechanisms, etc., without limitation.

[0033] The physical environment information of the Flash memory may include at least one of the following: temperature, humidity, magnetic field interference, etc., which are not limited here.

[0034] The first preset modification frequency can be preset or set by system default. The first preset modification frequency can be related to the attribute information of the Flash memory, or the first preset modification frequency can be related to the environmental information of the Flash memory.

[0035] The free block queue can include multiple free blocks, which can include some sequential physical blocks and some reverse-order physical blocks.

[0036] In specific implementation, if the first data size is less than the first preset data size and the first modification frequency is less than the first preset modification frequency, it indicates that the data size and modification frequency meet the reverse writing condition, meaning the data to be written meets the reverse writing condition. Therefore, reverse physical blocks can be allocated from the free block queue based on the first data size, resulting in n reverse physical blocks; n is a positive integer, meaning that reverse physical blocks can be dynamically allocated based on the data size. Conversely, if the first data size is not less than the first preset data size, and / or the first modification frequency is not less than the first preset modification frequency, it can be considered that the data to be written does not meet the reverse writing condition.

[0037] S105. Write the data to be written into the n reverse physical blocks.

[0038] In a practical implementation, the data to be written can be written to n reverse-order physical blocks. Specifically, the mapping relationship between the reverse-order physical blocks and their addresses can be pre-stored, and this mapping relationship can be stored in a block mapping table, which can be included in the Flash memory. For example, each reverse-order physical block can correspond to a portion of the data to be written, that is, it corresponds to a specific memory address, and that portion of the data is stored based on that memory address.

[0039] In practice, reverse writing can balance the wear and tear of Flash memory. Since each block of Flash memory has a certain number of erase and write cycles, excessive erase and write can damage the block. By writing in reverse order, data can be distributed among different blocks, thereby reducing the number of erase and write cycles for a single block and extending the lifespan of the memory. In addition, reverse writing can also improve data recovery capability. For example, when a block fails, the data may have already been distributed on other blocks, so reverse writing can reduce the risk of data loss.

[0040] In practice, using reverse writing in Flash memory can overcome the limitations of its physical characteristics and structural design, optimize writing efficiency, and extend the lifespan of the memory.

[0041] As can be seen, the reverse programming implementation method based on Flash memory described in this embodiment of the invention is applied to an electronic device, which includes a Flash memory. The method involves obtaining the size of the data to be written, obtaining a first data size, extracting keywords from the data to be written to obtain target keywords, determining a first modification frequency of the data to be written based on the target keywords, and allocating reverse physical blocks from the free block queue according to the first data size when the first data size is less than a first preset data size and the first modification frequency is less than the first preset modification frequency. This results in n reverse physical blocks, where n is a positive integer. The data to be written is then written into these n reverse physical blocks. Since the data size and keywords reflect the data characteristics, it is possible not only to identify whether the data to be written meets the reverse writing conditions based on the data characteristics, but also to intelligently allocate corresponding reverse physical blocks based on the data characteristics. Furthermore, the reverse writing operation for the data to be written is completed based on these reverse physical blocks. Thus, reverse writing of the Flash memory can be intelligently implemented based on the data characteristics of the data itself, thereby improving the intelligence and flexibility of the Flash memory.

[0042] In some possible examples, the following steps may also be included: When the first data size is greater than or equal to the first preset data size and less than the second preset data size, determine the first part of the data to be written associated with the target keyword and the second part of the data not associated with the target keyword; the first preset data size is less than the second preset data size. Determine the size of the first part of the data to obtain the second data size; Determine the size of the second part of the data to obtain the size of the third part of the data; When the second data size is greater than the third preset data size, the first part of the data is allocated in reverse order from the free block queue according to the second data size, resulting in m reverse order physical blocks; m is a positive integer less than or equal to n; Based on the third data size, sequential physical blocks are allocated from the free block queue for the second part of the data, resulting in a sequential physical blocks; where a is a positive integer. The first part of the data is written into the m reverse-order physical blocks, and the second part of the data is written into the a sequential physical blocks.

[0043] The second preset data size can be pre-set or set by system default, and the first preset data size is smaller than the second preset data size. The second preset data size can be related to the attribute information of the Flash memory, or it can be related to the environmental information of the Flash memory.

[0044] The third preset data size can be pre-set or set by system default. The third preset data size can be related to the attribute information of the Flash memory, or it can be related to the environmental information of the Flash memory.

[0045] In practice, if the first data size is greater than or equal to the first preset data size and less than the second preset data size, it indicates that the data to be written is slightly large. In this case, a portion of the data can be written in reverse order, while a portion is written sequentially. Specifically, the first part of the data to be written that is associated with the target keyword can be determined. This means the target keyword can be used to locate the corresponding data position within the data to be written. Then, combined with the data context, the portion of data related to the target keyword is extracted to obtain the first part of the data. Correspondingly, the data to be written excluding the first part is the second part of the data, which is the second part of the data not associated with the target keyword. The first and second parts of the data can then be concatenated to form the data to be written.

[0046] Next, we can determine the size of the first part of the data to obtain the second data size, and then determine the size of the second part of the data to obtain the third data size. If the second data size is greater than the third preset data size, it means that the second part of the data is not too small and has the significance of being written in reverse order. Then, we can allocate reverse physical blocks from the free block queue for the first part of the data according to the second data size, and obtain m reverse physical blocks; m is a positive integer less than or equal to n. We write the first part of the data into m reverse physical blocks, that is, we can dynamically allocate the corresponding reverse physical blocks based on the data size and complete the corresponding reverse writing.

[0047] Specifically, the mapping relationship between reversed physical blocks and addresses can be pre-stored, and this mapping relationship can be stored in a block mapping table, which can be included in the Flash memory. For example, each reversed physical block can correspond to a portion of the first part of the data, that is, it corresponds to a corresponding storage address, and that portion of the data is stored based on that storage address.

[0048] Accordingly, sequential physical blocks can be allocated from the free block queue for the second part of the data based on the size of the third data, resulting in a sequential physical blocks; where a is a positive integer, and then the second part of the data is written into a sequential physical blocks.

[0049] Specifically, the mapping relationship between sequential physical blocks and addresses can be pre-stored, and this mapping relationship can be stored in a block mapping table, which can be included in the Flash memory. For example, each sequential physical block can correspond to a portion of the second part of the data, that is, it corresponds to a corresponding storage address, and that portion of the data is stored based on that storage address.

[0050] In this way, when the data to be written is slightly large, the writing operation can be performed by writing some data in reverse order and some data in sequence. That is, by using some data to write in sequence and some data to write in reverse order, intelligent hybrid writing can be achieved, which helps to improve data writing efficiency.

[0051] In some possible examples, the following steps may also be included: When the first data size is greater than or equal to the second preset data size, sequential physical blocks are allocated from the free block queue according to the first data size to obtain b sequential physical blocks; b is a positive integer. The data to be written is written into the b sequential physical blocks.

[0052] In specific implementation, if the first data size is greater than or equal to the second preset data size, it indicates that the data to be written is too large and not suitable for reverse writing. Therefore, sequential physical blocks can be allocated from the free block queue according to the first data size, resulting in b sequential physical blocks (b is a positive integer). The data to be written is then written into b sequential physical blocks. In other words, when the data to be written is not suitable for reverse writing, suitable sequential physical blocks are dynamically allocated based on the data characteristics for sequential writing. In this way, reverse writing of the Flash memory can be intelligently implemented based on the data characteristics of the data itself, thereby improving the intelligence and flexibility of the Flash memory.

[0053] In some possible examples, the following steps may also be included: Obtain the data source identifier of the data to be written; When the data source identifier belongs to a preset data source identifier, the step of obtaining the data size of the data to be written is executed.

[0054] The preset data source identifier can be set in advance or be the system default. The preset data source identifier can include at least one data source identifier, which is used to represent the data source.

[0055] In specific implementation, the data source identifier of the data to be written can be obtained. If the data source identifier belongs to the preset data source identifier, it means that the data comes from the specified source. Then the step of obtaining the data size of the data to be written can be executed. In this way, only the data from the specified source can be identified, and for the data from the specified source, the Flash memory can be intelligently written in reverse order based on the data characteristics of the data itself, so as to improve the intelligence and flexibility of the Flash memory.

[0056] In some possible examples, the above step of determining the first modification frequency of the data to be written based on the target keyword can be implemented as follows: Obtain the first attribute information of the Flash memory; Determine a first mapping relationship corresponding to the first attribute information, wherein the first mapping relationship is a preset mapping relationship between keywords and modification frequency; The first modification frequency corresponding to the target keyword is determined based on the first mapping relationship.

[0057] The first attribute information of the Flash memory may include at least one of the following: the model of the Flash memory, the memory size of the Flash memory, the usage time of the Flash memory, etc., which are not limited here.

[0058] In specific implementation, the first attribute information of the Flash memory can be obtained, and the mapping relationship corresponding to the attribute information can be stored in advance. Different attribute information can correspond to different mapping relationships. Each mapping relationship is a mapping relationship between a preset keyword and a modification frequency. Thus, the first mapping relationship corresponding to the first attribute information can be determined. The first mapping relationship is a mapping relationship between a preset keyword and a modification frequency. Finally, the first modification frequency corresponding to the target keyword can be determined according to the first mapping relationship. In this way, the corresponding modification frequency can be determined based on the data characteristics of the data to be written.

[0059] Please see Figure 3 , Figure 3 This is a schematic diagram of a second structure of an electronic device provided in an embodiment of the present invention. As shown in the figure, the electronic device includes a processor, a memory, a communication interface, and one or more programs. The one or more programs are stored in the memory and configured to be executed by the processor. In this embodiment of the present invention, the memory includes a Flash memory. The programs include instructions for performing the following steps: Get the size of the data to be written, and obtain the first data size; Keyword extraction is performed on the data to be written to obtain the target keywords; Determine the first modification frequency of the data to be written based on the target keyword; When the first data size is less than the first preset data size and the first modification frequency is less than the first preset modification frequency, the data to be written is allocated in reverse order from the free block queue according to the first data size, resulting in n reverse order physical blocks; n is a positive integer. The data to be written is written into the n reverse-order physical blocks.

[0060] As can be seen, the electronic device described in this embodiment of the invention includes a Flash memory. It acquires the size of the data to be written, obtaining a first data size. It extracts keywords from the data to be written to obtain target keywords. Based on the target keywords, it determines a first modification frequency for the data to be written. When the first data size is less than a first preset data size and the first modification frequency is less than the first preset modification frequency, it allocates reverse-order physical blocks from the free block queue based on the first data size, obtaining n reverse-order physical blocks; n is a positive integer. The data to be written is written into the n reverse-order physical blocks. Since the data size and keywords reflect the data characteristics, it can not only identify whether the data to be written meets the reverse-order writing conditions based on the data characteristics, but also intelligently allocate corresponding reverse-order physical blocks based on the data characteristics. Furthermore, it completes the reverse-order writing operation for the data to be written based on the reverse-order physical blocks. Thus, it can intelligently realize reverse-order writing of the Flash memory based on the data characteristics of the data itself, thereby improving the intelligence and flexibility of the Flash memory.

[0061] In some possible examples, the above procedure also includes instructions for performing the following steps: When the first data size is greater than or equal to the first preset data size and less than the second preset data size, determine the first part of the data to be written associated with the target keyword and the second part of the data not associated with the target keyword; the first preset data size is less than the second preset data size. Determine the size of the first part of the data to obtain the second data size; Determine the size of the second part of the data to obtain the size of the third part of the data; When the second data size is greater than the third preset data size, the first part of the data is allocated in reverse order from the free block queue according to the second data size, resulting in m reverse order physical blocks; m is a positive integer less than or equal to n; Based on the third data size, sequential physical blocks are allocated from the free block queue for the second part of the data, resulting in a sequential physical blocks; where a is a positive integer. The first part of the data is written into the m reverse-order physical blocks, and the second part of the data is written into the a sequential physical blocks.

[0062] In some possible examples, the above procedure also includes instructions for performing the following steps: When the first data size is greater than or equal to the second preset data size, sequential physical blocks are allocated from the free block queue according to the first data size to obtain b sequential physical blocks; b is a positive integer. The data to be written is written into the b sequential physical blocks.

[0063] In some possible examples, the above procedure also includes instructions for performing the following steps: Obtain the data source identifier of the data to be written; When the data source identifier belongs to a preset data source identifier, the step of obtaining the data size of the data to be written is executed.

[0064] In some possible examples, in determining the first modification frequency of the data to be written based on the target keyword, the above procedure further includes instructions for performing the following steps: Obtain the first attribute information of the Flash memory; Determine a first mapping relationship corresponding to the first attribute information, wherein the first mapping relationship is a preset mapping relationship between keywords and modification frequency; The first modification frequency corresponding to the target keyword is determined based on the first mapping relationship.

[0065] Figure 4 This is a functional unit block diagram of a Flash memory-based reverse programming implementation device 400 according to an embodiment of the present invention. The Flash memory-based reverse programming implementation device 400 is applied to an electronic device, which includes a Flash memory; the Flash memory-based reverse programming implementation device 400 includes: an acquisition unit 410, an extraction unit 420, a determination unit 430, an allocation unit 440, and a writing unit 450, wherein... The acquisition unit 410 is used to acquire the data size of the data to be written, and obtain the first data size; The extraction unit 420 is used to extract keywords from the data to be written to obtain target keywords; The determining unit 430 is used to determine the first modification frequency of the data to be written based on the target keyword; The allocation unit 440 is configured to allocate reverse-order physical blocks from the free block queue for the data to be written according to the first data size when the first data size is less than the first preset data size and the first modification frequency is less than the first preset modification frequency, thereby obtaining n reverse-order physical blocks; n is a positive integer. The writing unit 450 is used to write the data to be written into the n reverse-order physical blocks.

[0066] As can be seen, the Flash memory-based device described in this embodiment of the invention is applied to an electronic device, which includes a Flash memory. The device acquires the size of the data to be written, obtaining a first data size. It then extracts keywords from the data to be written to obtain target keywords. Based on the target keywords, it determines a first modification frequency for the data to be written. When the first data size is less than a first preset data size and the first modification frequency is less than the first preset modification frequency, it allocates reverse-order physical blocks from the free block queue based on the first data size, obtaining n reverse-order physical blocks; n is a positive integer. The data to be written is written into the n reverse-order physical blocks. Since the data size and keywords reflect the data characteristics, it can not only identify whether the data to be written meets the reverse-order writing conditions based on the data characteristics, but also intelligently allocate corresponding reverse-order physical blocks based on the data characteristics. Furthermore, it completes the reverse-order writing operation for the data to be written based on these reverse-order physical blocks. Thus, it can intelligently realize reverse-order writing of the Flash memory based on the data characteristics of the data itself, thereby improving the intelligence and flexibility of the Flash memory.

[0067] In some possible examples, the Flash memory-based reverse programming implementation device 400 is also specifically used for: When the first data size is greater than or equal to the first preset data size and less than the second preset data size, determine the first part of the data to be written associated with the target keyword and the second part of the data not associated with the target keyword; the first preset data size is less than the second preset data size. Determine the size of the first part of the data to obtain the second data size; Determine the size of the second part of the data to obtain the size of the third part of the data; When the second data size is greater than the third preset data size, the first part of the data is allocated in reverse order from the free block queue according to the second data size, resulting in m reverse order physical blocks; m is a positive integer less than or equal to n; Based on the third data size, sequential physical blocks are allocated from the free block queue for the second part of the data, resulting in a sequential physical blocks; where a is a positive integer. The first part of the data is written into the m reverse-order physical blocks, and the second part of the data is written into the a sequential physical blocks.

[0068] In some possible examples, the Flash memory-based reverse programming implementation device 400 is also specifically used for: When the first data size is greater than or equal to the second preset data size, sequential physical blocks are allocated from the free block queue according to the first data size to obtain b sequential physical blocks; b is a positive integer. The data to be written is written into the b sequential physical blocks.

[0069] In some possible examples, the Flash memory-based reverse programming implementation device 400 further includes: Obtain the data source identifier of the data to be written; When the data source identifier belongs to a preset data source identifier, the step of obtaining the data size of the data to be written is executed.

[0070] In some possible examples, in determining the first modification frequency of the data to be written based on the target keyword, the determining unit 430 is specifically used for: Obtain the first attribute information of the Flash memory; Determine a first mapping relationship corresponding to the first attribute information, wherein the first mapping relationship is a preset mapping relationship between keywords and modification frequency; The first modification frequency corresponding to the target keyword is determined based on the first mapping relationship.

[0071] It is understood that the functions of each program module of the Flash memory-based reverse programming implementation device in this embodiment can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can be referred to the relevant descriptions in the above method embodiments, and will not be repeated here.

[0072] This invention also provides a computer storage medium storing a computer program for electronic data interchange, which causes a computer to perform some or all of the steps of any of the methods described in the above method embodiments.

[0073] This invention also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods described in the above method embodiments. This computer program product can be a software installation package.

[0074] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0075] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0076] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above 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 devices or units may be electrical or other forms.

[0077] The units described above 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.

[0078] Furthermore, the functional units in the various embodiments of the present invention 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. The integrated unit can be implemented in hardware or as a software functional unit.

[0079] If the aforementioned integrated units are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory 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 invention. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0080] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage device, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.

[0081] The embodiments of the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for implementing reverse programming based on Flash memory, characterized in that, Applied to electronic devices, wherein the electronic devices include Flash memory; The reverse programming implementation method based on Flash memory includes: Get the size of the data to be written, and obtain the first data size; Keyword extraction is performed on the data to be written to obtain the target keywords; Determine the first modification frequency of the data to be written based on the target keyword; When the first data size is less than the first preset data size and the first modification frequency is less than the first preset modification frequency, the data to be written is allocated in reverse order from the free block queue according to the first data size, resulting in n reverse order physical blocks; n is a positive integer. The data to be written is written into the n reverse-order physical blocks.

2. The reverse programming implementation method based on Flash memory as described in claim 1, characterized in that, The reverse programming implementation method based on Flash memory also includes: When the first data size is greater than or equal to the first preset data size and less than the second preset data size, determine the first part of the data to be written associated with the target keyword and the second part of the data not associated with the target keyword; the first preset data size is less than the second preset data size. Determine the size of the first part of the data to obtain the second data size; Determine the size of the second part of the data to obtain the size of the third part of the data; When the second data size is greater than the third preset data size, the first part of the data is allocated in reverse order from the free block queue according to the second data size, resulting in m reverse order physical blocks; m is a positive integer less than or equal to n; Based on the third data size, sequential physical blocks are allocated from the free block queue for the second part of the data, resulting in a sequential physical blocks; where a is a positive integer. The first part of the data is written into the m reverse-order physical blocks, and the second part of the data is written into the a sequential physical blocks.

3. The reverse programming implementation method based on Flash memory as described in claim 2, characterized in that, The reverse programming implementation method based on Flash memory also includes: When the first data size is greater than or equal to the second preset data size, sequential physical blocks are allocated from the free block queue according to the first data size to obtain b sequential physical blocks; b is a positive integer. The data to be written is written into the b sequential physical blocks.

4. The reverse programming implementation method based on Flash memory as described in any one of claims 1-3, characterized in that, The reverse programming implementation method based on Flash memory also includes: Obtain the data source identifier of the data to be written; When the data source identifier belongs to a preset data source identifier, the step of obtaining the data size of the data to be written is executed.

5. The reverse programming implementation method based on Flash memory as described in any one of claims 1-3, characterized in that, The step of determining the first modification frequency of the data to be written based on the target keyword includes: Obtain the first attribute information of the Flash memory; Determine a first mapping relationship corresponding to the first attribute information, wherein the first mapping relationship is a preset mapping relationship between keywords and modification frequency; The first modification frequency corresponding to the target keyword is determined based on the first mapping relationship.

6. A reverse programming implementation device based on Flash memory, characterized in that, Applied to electronic devices, wherein the electronic devices include Flash memory; The reverse programming implementation device based on Flash memory includes: an acquisition unit, an extraction unit, a determination unit, an allocation unit, and a writing unit, wherein, The acquisition unit is used to acquire the data size of the data to be written, and obtain the first data size; The extraction unit is used to extract keywords from the data to be written to obtain target keywords; The determining unit is used to determine a first modification frequency of the data to be written based on the target keyword; The allocation unit is configured to allocate reverse-order physical blocks from the free block queue for the data to be written according to the first data size when the first data size is less than the first preset data size and the first modification frequency is less than the first preset modification frequency, thereby obtaining n reverse-order physical blocks; n is a positive integer. The writing unit is used to write the data to be written into the n reverse-order physical blocks.

7. The reverse programming implementation device based on Flash memory as described in claim 6, characterized in that, The Flash memory-based reverse programming implementation device is also specifically used for: When the first data size is greater than or equal to the first preset data size and less than the second preset data size, determine the first part of the data to be written associated with the target keyword and the second part of the data not associated with the target keyword. The first preset data size is smaller than the second preset data size; Determine the size of the first part of the data to obtain the second data size; Determine the size of the second part of the data to obtain the size of the third part of the data; When the second data size is greater than the third preset data size, the first part of the data is allocated in reverse order from the free block queue according to the second data size, resulting in m reverse order physical blocks; m is a positive integer less than or equal to n; Based on the third data size, sequential physical blocks are allocated from the free block queue for the second part of the data, resulting in a sequential physical blocks; where a is a positive integer. Write the second part of the data into the a sequential physical blocks.

8. The reverse programming implementation device based on Flash memory as described in claim 7, characterized in that, The Flash memory-based reverse programming implementation device is also specifically used for: When the first data size is greater than or equal to the second preset data size, sequential physical blocks are allocated from the free block queue according to the first data size to obtain b sequential physical blocks; b is a positive integer. The data to be written is written into the b sequential physical blocks.

9. An electronic device, characterized in that, The device includes a processor, a flash memory, a communication interface, and one or more programs stored in the flash memory and configured to be executed by the processor. The programs include instructions for performing the steps of the method as described in any one of claims 1-5.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that is executed by a processor to implement the method of any one of claims 1 to 5.