Memory data access method, system, device and storage medium

By dynamically adjusting the data storage location in the memory, using free areas to write data and erasing the memory when necessary, the problem of frequent memory cell erasure is solved, improving the memory's lifespan and device stability.

CN116301614BActive Publication Date: 2025-11-28SHENZHEN LETRON POWER TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310190976.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-22
Publication Date
2025-11-28
Estimated Expiration
2043-02-22

AI Technical Summary

Technical Problem

In existing technologies, some memory cells fail rapidly due to frequent write and erase operations, affecting the lifespan of the memory and the stability of the device.

Method used

By identifying free areas in the memory, the storage location of data is dynamically adjusted to avoid saving data to a fixed area. The first address pointer is used to find free areas and write data. If necessary, the memory is erased to obtain free areas.

Benefits of technology

This improves the lifespan of the memory and the overall operational stability and reliability of the device, making full use of storage resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116301614B_ABST
    Figure CN116301614B_ABST
Patent Text Reader

Abstract

The application relates to a memory data access method, system, device and storage medium, which comprises the following steps: constructing data to be stored; searching for a free area in the memory by judging the content pointed by a first address pointer, wherein the first address pointer determines the starting address of the free area; and writing the data to be stored into the free area if the free area is found. The application writes the data to be stored into the free area by judging the content pointed by the first address pointer. In addition, when reading data, the storage position adjacent to the free area is positioned to read. Through the reading and writing mode, the data is no longer saved to a fixed area, but the storage position of the data is dynamically adjusted according to the storage state of the current storage area, so that some storage units are avoided from being concentratedly and frequently written and erased, the storage resource is fully utilized, the service life of the memory and the whole device is improved, and the stability and reliability of the whole device are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data storage, in particular to a memory data access method, system, device and storage medium. BACKGROUND

[0002] In the control of various electronic appliances, it is often necessary to save some data into EEPROM / Flash, such as correction parameters, user preference options, cumulative working time, etc. These data are usually not large in number, far less than the capacity of the MCU built-in or external storage chip, but are very important for the normal operation of the device. If these data are fixedly saved in the address of EEPROM / Flash, the storage units will be concentratedly and frequently written and erased, resulting in rapid failure and scrap, thereby affecting the service life of the entire memory. SUMMARY

[0003] The technical problem to be solved by the present application is to provide a memory data access method, system, device and storage medium for solving the problem that part of the storage units of the memory are frequently written and erased when data is saved in the prior art, and to dynamically adjust the storage location of data according to the storage state of the current storage area.

[0004] The technical scheme adopted by the present application to solve the technical problem is to provide a memory data access method, the method comprising the following steps:

[0005] constructing to-be-stored data;

[0006] finding an idle area in the memory by judging the content pointed to by a first address pointer, wherein the first address pointer determines the starting address of the idle area;

[0007] if the idle area is found, writing the to-be-stored data into the idle area.

[0008] Optionally, before the step of writing the to-be-stored data into the idle area if the idle area is found, the method further comprises:

[0009] constructing a data structure for saving the to-be-stored data and determining the size of the to-be-stored data;

[0010] logically dividing the storage area into a plurality of storage blocks according to the size of the to-be-stored data, and each storage block can store a set of to-be-stored data.

[0011] Optionally, the first address pointer points to the starting address or a specified address of the memory.

[0012] Optionally, the step of finding an idle area by judging the content pointed to by a first address pointer comprises:

[0013] finding the free area in the memory from a preset start address through the first address pointer;

[0014] If the first address pointer does not point to the free area, updating the first address pointer and continuing to find the free area in the memory.

[0015] Optionally, the updating of the first address pointer comprises:

[0016] updating the first address pointer according to the first address pointer and the size of the data to be stored.

[0017] Optionally, the method further comprises:

[0018] If the free area is not found, performing an erasing operation on all storage areas in the memory to obtain the free area.

[0019] After the free area is obtained, the first address pointer is updated to the start address of the free area, and the data to be stored is written into the free area.

[0020] Optionally, the method further comprises:

[0021] finding the free area in the memory through a second address pointer, wherein the second address pointer is used to point to the start address of a storage area when data is read;

[0022] If the free area is found, reading the content in a storage block corresponding to the size of the data to be read before the free area.

[0023] If the free area is not found, reading the content in a storage block corresponding to the size of the data to be read at the last of the storage area.

[0024] The application further provides a memory data access system, which comprises:

[0025] a data construction module for constructing data to be stored;

[0026] a free area finding module for finding a free area in the memory by judging the content pointed to by a first address pointer, wherein the first address pointer determines the start address of the free area.

[0027] a data writing module for writing the data to be stored into the free area if the free area is found.

[0028] The application further provides a computer device, comprising a memory, a processor, and a memory data access program stored in the memory and executable on the processor, the memory data access program being configured to implement the steps of the memory data access method.

[0029] The application further provides a computer readable storage medium, the storage medium storing a memory data access program, the memory data access program being executable on a processor to implement the steps of the memory data access method.

[0030] The memory data access method, system, device and storage medium of the application have the following beneficial effects: the free area is found by judging the content pointed to by the first address pointer, and the to-be-stored data is written in the free area. In addition, when reading data, the storage position adjacent to the free area is located to read. Through the read-write mode, the data is no longer saved to a fixed area, but the storage position of the data is dynamically adjusted according to the storage state of the current storage area, so that the concentrated frequent writing and erasing of some storage units is avoided, the storage resources are fully utilized, and the service life of the memory and the entire device, and the stability and reliability of the overall work of the device are improved. BRIEF DESCRIPTION OF DRAWINGS

[0031] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only some embodiments of the application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.

[0032] In the drawings:

[0033] Figure 1 Fig. 1 is one of the flowcharts of the memory data access method in an embodiment;

[0034] Figure 2 Fig. 2 is the flowchart of updating the first address pointer in an embodiment;

[0035] Figure 3 Fig. 3 is the second flowchart of the memory data access method in an embodiment;

[0036] Figure 4 Fig. 4 is the third flowchart of the memory data access method in an embodiment;

[0037] Figure 5 Fig. 5 is the flowchart of updating the second address pointer in an embodiment;

[0038] Figure 6A structural block diagram of a memory data access system in one embodiment;

[0039] Figure 7 A structural block diagram of a computer device in one embodiment. DETAILED DESCRIPTION

[0040] It should be understood that the specific embodiments described herein are merely illustrative of the present application and should not be taken as limiting thereof.

[0041] It should be noted that the terms "comprise", "comprising", "include", "including", and "have", "having" and any variations thereof in the specification and in the claims are intended to cover a non-exclusive inclusion. For example, a process, method, system, product, or device that comprises a list of steps or elements does not necessarily comprise only those listed steps or elements but can include other steps or elements not expressly listed or inherent to such process, method, system, product, or device. The terms "first", "second", and the like, as used in the specification and in the claims, do not connote any actual relationships between the entities / operations / objects so designated, but are used merely to distinguish one from another.

[0042] Referring to Figure 1 The present application provides a memory data access method, which can be applied to a device of an embedded system, and the embodiment is exemplified by being applied to an embedded system; of course, the method can also be applied to other computer systems independently. The memory of the embodiment can be an EEPROM (Electronic Erasable Programmable Read-Only Memory) or a FLASH (Flash Memory).

[0043] The memory data access method of the present application specifically comprises the following steps:

[0044] S1: constructing to-be-stored data.

[0045] The to-be-stored data is data that needs to be frequently written into the memory. Optionally, the to-be-stored data includes but is not limited to correction parameters of an electrical appliance, cumulative working time of the electrical appliance, and the like, which are not limited herein.

[0046] S2: finding an idle area in the memory by judging the content pointed to by a first address pointer, wherein the first address pointer determines the start address of the idle area.

[0047] Specifically, the storage area in the memory is divided into free area and non-free area, and the free area is a storage area in the memory which has not yet stored data. The memory has many storage areas, each of which has one or more storage units, and each storage unit occupies a storage address. Some storage areas have written data in the early stage, so the first address pointer can be used to find the free area from the start address.

[0048] The storage area in the memory is divided into free area or non-free area. The free area is found by judging the content pointed by the first address pointer. If it is free, the first address pointer points to the start address of the free area. If it is non-free area, the first address pointer is updated to continue searching.

[0049] S3: If the free area is found, the to-be-stored data is written into the free area.

[0050] In this embodiment, the free area is found by judging the content pointed by the first address pointer, and the to-be-stored data is written into the free area when the free area is found. Instead of saving the data to the fixed area, the storage position of the data is dynamically adjusted according to the storage state of the current storage area, so as to avoid that some storage units are frequently written and erased, fully utilize the storage resources, and improve the service life of the memory and the entire device, as well as the stability and reliability of the entire device.

[0051] In one embodiment, before the step of writing the to-be-stored data into the free area when the free area is found, the method further includes:

[0052] S21: Constructing a data structure for saving the to-be-stored data, and determining the size of the to-be-stored data.

[0053] Specifically, the type of the data structure includes but is not limited to set, linear structure, tree structure, and graph structure, which are not limited herein. According to the actual application scenario, a suitable data structure is constructed to improve the storage efficiency of the data. For example, a union can be constructed, which is convenient for defining multiple different data types, and is also convenient for data writing serialization and data reading and parsing content.

[0054] If the data amount or data type of the to-be-stored data is single in the actual application scenario, a complex data structure does not need to be constructed. For example, the maximum allowed length of the indefinite length data such as string can be assumed, and space is reserved for it when the data structure is constructed. In addition, when constructing the data structure, the field of the data structure should be avoided to be the same as the free area, otherwise it will be mistaken that the area which has saved data is the free area. For example, the field is 1 to represent free, the field of the data structure is 1, and the field of the free area is also 1. Therefore, an additional field can be added when the data is constructed, and the additional field is set to be non-all-1, so as to distinguish the data structure and the free area.

[0055] In the foregoing step, the data structure is constructed, and the size of the memory region occupied by the data structure is calculated. For example, the size of the memory occupied by the constructed data structure is N bytes, where N is an exponential power of 2 or an integer multiple of an exponential power of 2. After the data structure is constructed, the size of the data to be stored is determined, and the program can perform subsequent operations according to the size, without the need to determine the size of the data to be stored each time.

[0056] S23: logically divide the memory region into a plurality of storage blocks according to the size of the data to be stored, each storage block being capable of storing a set of data to be stored.

[0057] A storage unit is a basic unit of the memory, and the capacity of one storage unit is generally 1 byte. Each storage block has one or more storage units. For example, when the size of the data to be stored is N bytes, the N storage units occupied by the data to be stored can be regarded as “one storage block”. If the current address is not idle, the first address pointer needs to move “one storage block”, that is, move an amount of N storage units, to find whether the storage unit of the next storage block is idle.

[0058] In this embodiment, the size of the data to be stored is determined by first defining the data structure frequently read and written in the application scenario, so as to divide the memory region into a plurality of storage blocks capable of storing the data to be stored, thereby saving storage resources.

[0059] In one embodiment, the first address pointer points to the starting address or a specified address of the memory.

[0060] The memory includes a fixed data region and a frequently read and written region. The fixed data region is a storage region in the memory in which data has been stored and the data is not frequently changed, which is not discussed in the present application. The frequently read and written region is a storage region in the memory in which data is frequently read or written. The starting address is the starting position of the frequently read and written region, and the specified address is an address in the frequently read and written region specified by software according to application needs.

[0061] In one embodiment, the step of searching for an idle region in the memory through the first address pointer includes:

[0062] S22: searching for an idle region in the memory from a preset starting address through the first address pointer.

[0063] Specifically, the first address pointer points to which position in the preset region, and the search starts from the position. The preset region of the memory can be a part of the memory or the entire memory, and the range of the memory region is divided according to actual needs.

[0064] S24: If the first address pointer does not point to the free area, updating the first address pointer and continuing to search for the free area in the memory.

[0065] Specifically, the initial value of the first address pointer can be understood as a set starting address, and the free area is searched from the preset starting address. When the first address pointer does not point to the free area, the first address pointer needs to be updated and the free area continues to be searched.

[0066] In one embodiment, updating the first address pointer comprises:

[0067] The first address pointer is updated by the first address pointer and the size of the data to be stored.

[0068] Specifically, when the first address pointer does not point to the free area, the first address pointer needs to be re-determined in order to continue searching for the free area. The first address pointer is updated by the first address pointer and the size of the data to be stored, which can be the sum of the first address pointer and the size of the data to be stored to obtain the updated first address pointer. For example, referring to Figure 2 Here, the first address pointer A is 3, pointing to the starting address 3, that is, searching from the storage unit 3 of the memory, and the size of the data to be stored is 4, so the number of bytes N read from the storage area is 4. Starting from the storage unit 3, 4 bytes of data are read, and it is judged whether the storage unit 3, the storage unit 4, the storage unit 5, and the storage unit 6 are idle units. If they are idle units, the data to be stored is written into the storage unit 3, the storage unit 4, the storage unit 5, and the storage unit 6. If they are not idle units, the first address pointer A is updated. In this example, the way to update the first address pointer A is to add the first address pointer A and the size of the data to be stored, that is, A = A + N, to obtain the latest first address pointer A as 7. Continue searching from the storage unit 7, and if the storage unit 7, the storage unit 8, the storage unit 9, and the storage unit 10 meet the writing of the data to be stored, the storage unit 7 pointed to by the first address pointer A is the starting position of the free area.

[0069] Referring to Figure 3 In one embodiment, the memory data access method further comprises:

[0070] S4: If the free area cannot be found, performing an erase operation on all storage areas in the memory to obtain the free area;

[0071] The erase operation is to restore the storage area of the stored data to a state without stored data. For example, the storage bits of the non-stored data are all 1, and the content field of the storage area of the stored data has 0. The erase operation is performed on the storage area, that is, all the storage bits are restored from 0 to 1.

[0072] S5: After obtaining the free area, the first address pointer is updated as the start address of the free area, and the data to be stored is written into the free area.

[0073] The embodiment considers the case where there is no free area in the memory, obtains a free area by erasing all the storage areas, and updates the first address pointer as the start address of the free area, so as not to affect the writing of the latest data into the memory, improve the resource utilization of the memory, and perform the erasing operation only when there is no free area in the memory, thereby prolonging the service life of the memory.

[0074] Referring to Figure 4 In one embodiment, the memory data access method further comprises:

[0075] S6: Searching for a free area in the memory through a second address pointer, wherein the second address pointer is used to point to the start address of the storage area when data is read.

[0076] Specifically, since the data structure of the data to be stored is fixed, the size of the data to be read can be determined, and thus the size of the storage area (storage block) to be searched for in the memory can be determined. For example, the stored data is the cumulative working time of an electric appliance, and if the cumulative working time of the electric appliance is to be read, the storage block in which the latest cumulative working time of the electric appliance is stored needs to be searched for in the memory. It can be understood that the second address pointer can be the first address pointer used when the data to be stored is written.

[0077] S7: If the free area is found, the content in the storage block in front of the free area corresponding to the size of the data to be read is read.

[0078] S8: If the free area is not found, the content of the last storage block corresponding to the size of the data to be read is read.

[0079] Specifically, there is data in the storage block corresponding to the size of the data to be read, and the data is read out and assigned to each field in the data structure, so that the latest content written before can be successfully read. Since the data is not stored in a fixed storage area, the address of the storage area where the latest data is stored is variable. There is data in the storage block corresponding to the size of the data to be read, and the next storage block is free. The data in the storage block is the latest data. Considering that when the data is written, only one storage block is left in the storage area, and the latest data can be stored in this last storage block, when the free area is not found, the data in the last storage block corresponding to the size of the data to be read in the storage area is read, and the data in the storage block is the latest data.

[0080] In the data reading process, the storage block to be read is found. If the next storage block of the storage area where the data to be read is located is not a free area, the second address pointer is updated. For example, referring to Figure 5 Here, the second address pointer B is 3, pointing to the starting address 3, that is, the data is searched from the storage unit 3. The size of the data to be read is 4, and 4 bytes of data are read from the storage unit 3. Here, each storage unit can store 1 byte of data. It is judged whether the storage block (storage unit 3, storage unit 4, storage unit 5, storage unit 6) is free. If the storage block is not free and the next adjacent storage block (storage unit 7, storage unit 8, storage unit 9, storage unit 10) is free, the data in the storage unit 3, the storage unit 4, the storage unit 5, and the storage unit 6 is read, and these data are the latest data. If neither the storage block nor the next adjacent storage block is free, the second address pointer is updated. In this example, the way to update the second address pointer B is to add the size of the data to be read to the second address pointer B, that is, B = B + N, and the latest second address pointer B is 7. The data is searched from the storage unit 7.

[0081] The application also provides a memory data access system, which comprises:

[0082] a data construction module 200, configured to construct data to be stored;

[0083] a free area searching module 202, configured to search for a free area in the memory by judging the content pointed to by a first address pointer, wherein the first address pointer determines the starting address of the free area;

[0084] a data writing module 204, configured to write the data to be stored into the free area if the free area is found.

[0085] Referring to Figure 6 The memory data access system provided by the application further comprises:

[0086] a data reading module 206, configured to search for a free area in the memory by using a second address pointer, wherein the second address pointer is used to point to the starting address of the storage area where the data to be read is located during data reading;

[0087] if the free area is found, the content in the storage block corresponding to the size of the data to be read before the free area is read;

[0088] if the free area is not found, the content in the last storage block corresponding to the size of the data to be read in the storage area where the data to be read is located is read.

[0089] The storage cell erasure module 208 is used to perform an erasure operation when there is no free area to store new data, restoring some or all of the storage cells of the memory to a free state.

[0090] Figure 7 An internal structural diagram of a computer device in one embodiment is shown. This computer device can specifically be an embedded system or a computer. Figure 7 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and may also store a computer program. When executed by the processor, this computer program enables the processor to implement a memory data access method. The internal memory may also store a computer program, which, when executed by the processor, enables the processor to implement a memory data access method. Those skilled in the art will understand that… Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present invention and does not constitute a limitation on the computer device to which the present invention is applied. A specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0091] In one embodiment, a computer device is provided, the device comprising: a memory, a processor, and a memory data access program stored in the memory and executable on the processor, the memory data access program being configured to implement the steps of the memory data access method described above.

[0092] In one embodiment, a computer-readable storage medium is provided, on which a program for accessing memory data is stored, wherein the program for accessing memory data is executed by a processor to implement the steps of the memory data access method described above.

[0093] It is understood that the above-described memory data access methods, systems, computer devices, and computer-readable storage media belong to the same general inventive concept, and the embodiments are applicable to each other.

[0094] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0095] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be noted that for ordinary skilled persons in the art, without departing from the concept of the present application, several modifications and improvements can be made, which are within the protection scope of the present application.

Claims

1. A method for accessing data in a memory, characterized in that, The method includes: Construct the data to be stored; By determining the content pointed to by the first address pointer, a free area is searched in the memory, wherein the first address pointer determines the starting address of the free area; If the free area is found, the data to be stored is written into the free area; If the free area cannot be found, an erase operation is performed on all storage areas in the memory to obtain the free area.

2. The memory data access method according to claim 1, characterized in that, Before the step of writing the data to be stored into the free area if the free area is found, the method further includes: Construct a data structure to store the data to be stored, and determine the size of the data to be stored; Based on the size of the data to be stored, the storage area is logically divided into multiple storage blocks, and each storage block can store a set of the data to be stored.

3. The memory data access method according to claim 1, characterized in that, The first address pointer points to the starting address or a specified address of the memory.

4. The memory data access method according to claim 1, characterized in that, The step of searching for a free area in memory by determining the content pointed to by the first address pointer includes: Using the first address pointer, the free area is located in the memory from a preset starting address; If the current first address pointer does not point to the free region, then update the first address pointer and continue searching for the free region in the memory.

5. The memory data access method according to claim 4, characterized in that, Updating the first address pointer includes: The first address pointer is updated based on the size of the first address pointer and the data to be stored.

6. The memory data access method according to claim 1, characterized in that, The method further includes: After obtaining the free area, the first address pointer is updated to the starting address of the free area, and the data to be stored is written into the free area.

7. The memory data access method according to claim 1, characterized in that, The method further includes: The second address pointer is used to locate a free area in the memory, wherein the second address pointer is used to point to the starting address of the memory area when data is read. If the free area is found, the contents of the storage block preceding the free area that corresponds to the size of the data to be read are read. If no free area is found, the contents of the last storage block in the storage area that corresponds to the size of the data to be read are read.

8. A memory data access system, characterized in that, The system includes: The data construction module is used to construct the data to be stored. The free area search module is used to search for a free area in the memory by determining the content pointed to by the first address pointer, wherein the first address pointer determines the starting address of the free area; The data writing module is used to write the data to be stored into the free area if the free area is found. The storage cell erasure module 208 is used to perform an erasure operation when there is no free area to store new data, restoring some or all of the storage cells of the memory to a free state.

9. A device, characterized in that, The device includes: a memory, a processor, and a memory data access program stored in the memory and executable on the processor, the memory data access program being configured to implement the steps of the memory data access method as described in any one of claims 1 to 7.

10. A storage medium, characterized in that, The storage medium stores a program for accessing memory data, which, when executed by a processor, implements the steps of the memory data access method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and system for allocating space on a storage device

    WO2014114947A1