Flash-based data access method
By using circular storage in the address space and segmented storage in the data space according to address value, the problems of wasted FLASH storage space and unnecessary erasure are solved, achieving efficient data access and extending device life.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2026-03-27
AI Technical Summary
In existing technologies, wasted FLASH storage space and unnecessary erasure issues lead to underutilization of storage space, affecting device lifespan.
The address space circular storage method is adopted. The storage start address is dynamically adjusted by detecting data read instructions. Combined with the data space being stored in segments according to address value, the circular storage and reading of data is realized, reducing the number of FLASH erases.
It achieves efficient data storage recycling, maximizes the use of FLASH storage space, and extends the lifespan of the device.
Smart Images

Figure CN118860908B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of data management and relates to a FLASH-based data access method. BACKGROUND
[0002] During positioning, speed measurement and timing after power-on of a navigation receiver installed on an aircraft, positioning, speed measurement, timing and other related data used in flight are continuously stored in FLASH at intervals of seconds. When flight data playback is required after the end of flight or when flight abnormal processes are judged and abnormal data are analyzed, the stored positioning, speed measurement, timing and other related data need to be read out from the nonvolatile FLASH. The storage and reading processes need to be cyclic and continuous, and cannot have the situation of interrupting storage after storage is full or the situation of emptying previously stored data before storage is full. In the prior art, a FLASH storage data method is used to allocate storage positions, and storage and reading addresses are fixed. This method can cause waste of storage space and cannot maximize the amount of stored data. In fixed storage space, cyclic storage is performed according to ID numbers, and real cyclic storage of data is not realized. When the size of stored data changes, storage and reading positions need to be re-allocated. Fixed storage space can cause unnecessary FLASH erasing and reduce the erasing and writing life of FLASH.
[0003] In summary, the prior art has the problems of unnecessary FLASH erasing and FLASH storage space waste. SUMMARY
[0004] The application aims to provide a FLASH-based data access method, which solves the problems of unnecessary FLASH erasing and FLASH storage space waste in the prior art.
[0005] The technical solution of the application is a FLASH-based data access method, which comprises the following steps.
[0006] Step 1: obtaining a next data storage starting address, and detecting whether a data reading instruction exists or not when a FLASH memory executes a data storage instruction;
[0007] Step 2: when a data reading instruction is detected, the FLASH memory stops executing the data storage instruction and executes the data reading instruction; if no data reading instruction is detected, the FLASH memory continues to execute the data storage instruction.
[0008] When the FLASH memory executes the data reading instruction, the next data storage starting address is a data reading end point; when the FLASH memory executes the data storage instruction, the next data storage starting address is a data storage starting point.
[0009] The application also has the characteristics that:
[0010] The FLASH memory comprises an address space, address data in the address space is stored in order from small to large according to the address value of the address space, and after the address space is full, the address data stored in the address space is erased and the data is stored again from the address space with the smallest address value.
[0011] The FLASH memory further comprises a data space, the data space is divided into a plurality of storage spaces with the same size in order according to the size of the address value, the data to be stored is first stored in the storage space with the small address value, and after the data space is full, the storage data in the storage space with the smallest address value is erased and the data is continuously stored in the storage space.
[0012] The specific steps of obtaining the starting address of the next data storage are as follows:
[0013] Step A1, reading the values of four continuous bytes in order from small to large in the address space from the initial address of the address space;
[0014] Step A2, if the values of the four continuous bytes are 0xFF respectively, the address value in the previous group of four bytes of the four continuous bytes is the starting address of the next data storage, and the address is saved; if the values of the four continuous bytes are not 0xFF respectively, the address of the storage space with the smallest address value is the starting address of the next data storage, and the address is saved.
[0015] When the starting address of the next data storage is the address of the storage space with the smallest address value, the storage data in the address space is erased before the data to be stored is stored.
[0016] The specific steps of the FLASH memory executing the data storage instruction are as follows:
[0017] Step B1, obtaining the data to be stored, the data length, and the starting address of the next data storage;
[0018] Step B2, storing the data to be stored in the data space in units of X bytes, and when the data to be stored is less than the unit value, the data is spliced after the next frame of data arrives and then stored in the data space;
[0019] The value range of X is 1-256.
[0020] When the FLASH memory executes the data storage instruction, the starting address of the next data storage is increased by X after X bytes of data are stored each time, and when the starting address of the next data storage exceeds the maximum storage address of the data space, the address of the storage space with the smallest address value is taken as the starting address of the next data storage.
[0021] The specific steps of the FLASH memory executing the data reading instruction are as follows:
[0022] Step C1, obtaining the data hour time length to be read;
[0023] Step C2, converting the data hour time length to be read into the data byte length to be read;
[0024] Step C3, calculating the start address of the data to be read by combining the data byte length to be read and the next data storage start address;
[0025] Step C4, reading the data stored in the data space corresponding to the address between the start address of the data to be read and the next data storage start address.
[0026] When the FLASH memory executes the data read instruction, if the data byte length to be read is greater than the number of bytes stored in the data space, the start address of the data to be read is the address of the storage space with the smallest address value.
[0027] The beneficial effects of the present application are: the design of the address space in the present application, combined with the algorithm for obtaining the start address of the stored data, can simply and efficiently obtain the FLASH address to be stored or read at present, is not affected by the power failure of the device, and realizes the purpose of cyclic storage; compared with erasing the FLASH every time the address is updated, the cyclic storage mode in the address space reduces the number of times of erasing the FLASH of the address space, and increases the service life of the FLASH; the organization of the stored and read data can maximize the use of the FLASH storage space and store more data. BRIEF DESCRIPTION OF DRAWINGS
[0028] Figure 1 is the flowchart of the FLASH-based data access method of the present application. DETAILED DESCRIPTION
[0029] The present application will be described in detail below in combination with the drawings and specific embodiments.
[0030] The FLASH-based data access method, as shown in Figure 1 includes the following steps:
[0031] Step one, obtaining the next data storage start address, the FLASH memory executes the data storage instruction, and detecting whether there is a data read instruction;
[0032] The specific steps of obtaining the next data storage start address are as follows:
[0033] Step A1, reading the values of four consecutive bytes in the address space from small to large from the initial address of the address space;
[0034] Step A2, if the values of the read consecutive 4 bytes are 0xFF respectively, the address value in the previous group of 4 bytes of the consecutive 4 bytes is the next data storage starting address, and the address is saved; if the values of the read consecutive 4 bytes are not all 0xFF, the address of the storage space with the minimum address value is the next data storage starting address, and the address is saved;
[0035] When the next data storage starting address is the address of the storage space with the minimum address value, the storage data in the address space is erased before the storage of the data to be stored;
[0036] Step two, when the data read instruction is detected, the FLASH memory stops executing the data storage instruction and executes the data read instruction; if the data read instruction is not detected, the FLASH memory continues to execute the data storage instruction;
[0037] When the FLASH memory executes the data read instruction, the next data storage starting address is the data read end point; when the FLASH memory executes the data storage instruction, the next data storage starting address is the data storage start point;
[0038] The FLASH memory includes an address space, the address data in the address space is stored in order from small to large according to the address value of the address space, and after the address space is full, the address data stored in the address space is erased and the data is stored from the address space with the minimum address value again;
[0039] The FLASH memory further includes a data space, the data space is divided into a plurality of storage spaces with the same size in order according to the address value, the data to be stored is first stored in the storage space with a small address value, and after the data space is full, the storage data in the storage space with the minimum address value is erased and the data is continuously stored in the storage space;
[0040] The specific steps of the FLASH memory executing the data storage instruction are as follows:
[0041] Step B1, obtaining the data to be stored, the data length, and the next data storage starting address;
[0042] Step B2, storing the data to be stored in the data space in units of X bytes, and when the data to be stored is less than the unit value, waiting for the next frame of data to arrive, splicing the data and then storing the data in the data space;
[0043] The value range of X is 1-256;
[0044] When the FLASH memory executes the data storage instruction, the next data storage starting address is increased by X after X bytes of data are stored each time, and when the next data storage starting address exceeds the maximum storage address of the data space, the address of the storage space with the minimum address value is the next data storage starting address.
[0045] The specific steps of the FLASH memory executing the data reading instruction are as follows:
[0046] Step C1, obtaining the data hour time length to be read;
[0047] Step C2, converting the data hour time length to be read into the data byte length to be read;
[0048] Step C3, calculating the start address of the data to be read by combining the data byte length to be read and the next data storage start address;
[0049] Step C4, reading the data stored in the data space corresponding to the address between the start address of the data to be read and the next data storage start address;
[0050] When the FLASH memory executes the data reading instruction, if the data byte length to be read is greater than the number of bytes already stored in the data space, the start address of the data to be read is the address of the storage space with the smallest address value.
[0051] Embodiment 1
[0052] As shown in Figure 1 , the embodiment proposes a FLASH-based data access method, including the following steps:
[0053] Step 1, obtaining the next data storage start address, the FLASH memory executing the data storage instruction, and detecting whether there is a data reading instruction;
[0054] The specific steps of obtaining the next data storage start address are as follows:
[0055] Step A1, reading the values of four consecutive bytes from small to large in the address space starting from the initial address of the address space;
[0056] Step A2, when the values of the four consecutive bytes read are 0xFF, the address value in the previous group of four bytes of the four consecutive bytes is the next data storage start address, and the address is saved;
[0057] Step 2, detecting the data reading instruction, the FLASH memory stopping executing the data storage instruction and executing the data reading instruction;
[0058] When the FLASH memory executes the data reading instruction, the next data storage start address is the data reading end point; when the FLASH memory executes the data storage instruction, the next data storage start address is the data storage start point;
[0059] The specific steps of the FLASH memory executing the data storage instruction are as follows:
[0060] Step B1, obtaining the data to be stored and the data length, the next data storage starting address;
[0061] Step B2, storing the data to be stored in the data space in units of 256 bytes, and when the data to be stored is less than the unit value, waiting for the next frame of data to arrive and then storing the data after splicing;
[0062] When the FLASH memory executes the data storage instruction, the next data storage starting address is increased by 256 after storing 256 bytes of data each time, and when the next data storage starting address exceeds the maximum storage address of the data space, the address of the storage space with the smallest address value is taken as the next data storage starting address;
[0063] The specific steps of the FLASH memory executing the data reading instruction are as follows:
[0064] Step C1, obtaining the time length of the data to be read;
[0065] Step C2, converting the time length of the data to be read into the byte length of the data to be read;
[0066] Step C3, calculating the starting address of the data to be read based on the byte length of the data to be read and the next data storage starting address;
[0067] Step C4, reading the data stored in the data space corresponding to the addresses from the starting address of the data to be read to the next data storage starting address.
[0068] Embodiment 2
[0069] As shown in the following table, the embodiment proposes a FLASH-based data access method, including the following steps: Figure 1
[0070] Step one, obtaining the next data storage starting address, the FLASH memory executing the data storage instruction, detecting whether there is a data reading instruction;
[0071] The specific steps of obtaining the next data storage starting address are as follows:
[0072] Step A1, reading the values of 4 consecutive bytes in the address space from small to large from the initial address of the address space;
[0073] Step A2, when the values of the 4 consecutive bytes are not all 0xFF, the address of the storage space with the smallest address value is the next data storage starting address, and the address is saved;
[0074] When the next data storage starting address is the address of the storage space with the smallest address value, the storage data in the address space is erased before the data to be stored is stored;
[0075] Step 2: Upon detecting a data read command, the FLASH memory stops executing data storage commands and executes data read commands.
[0076] When a FLASH memory executes a data read instruction, the next data storage start address is the data read end address; when a FLASH memory executes a data storage instruction, the next data storage start address is the data storage start address.
[0077] The specific steps for a FLASH memory to execute data storage instructions are as follows:
[0078] Step B1: Obtain the data to be stored, its length, and the starting address for the next data storage.
[0079] Step B2: Store the data to be stored in the data space in units of 1 byte. If the stored data is less than the unit value, wait until the next frame of data arrives, then concatenate the data and store it in the data space.
[0080] When the FLASH memory executes a data storage instruction, after storing 1 byte of data, the starting address of the next data storage is increased by 1. When the starting address of the next data storage exceeds the maximum storage address of the data space, the address of the storage space with the smallest address value is taken as the starting address of the next data storage.
[0081] The specific steps for executing a data read instruction in a FLASH memory are as follows:
[0082] Step C1: Obtain the hourly duration of the data to be read;
[0083] Step C2: Convert the hour duration of the data to be read into the length of the data in bytes;
[0084] Step C3: Calculate the starting address of the data to be read by combining the length of the data to be read in bytes with the starting address of the next data storage;
[0085] Step C4: Read the data stored in the data space corresponding to the address between the starting address of the data to be read and the starting address of the next data storage;
[0086] When a FLASH memory executes a data read instruction, if the length of the data byte to be read is greater than the number of bytes already stored in the data space, the starting address of the data to be read is the address of the storage space with the smallest address value.
[0087] Example 3
[0088] like Figure 1 As shown, this embodiment proposes a data access method based on FLASH, including the following steps:
[0089] Step one, obtaining the next data storage starting address, the FLASH memory executes the data storage instruction, and detects whether there is a data read instruction;
[0090] The specific steps of obtaining the next data storage starting address are as follows:
[0091] Step A1, starting from the initial address of the address space, sequentially read the values of 4 consecutive bytes in the address space from small to large;
[0092] Step A2, when the values of the 4 consecutive bytes read are 0xFF respectively, the address value in the previous group of 4 bytes of the 4 consecutive bytes is the next data storage starting address, and the address is saved;
[0093] Step two, if no data read instruction is detected, the FLASH memory continues to execute the data storage instruction;
[0094] When the FLASH memory executes the data storage instruction, the next data storage starting address is the data storage starting point;
[0095] The specific steps of the FLASH memory executing the data storage instruction are as follows:
[0096] Step B1, obtaining the data to be stored, the data length, and the next data storage starting address;
[0097] Step B2, storing the data to be stored in the data space in units of 128 bytes, and when the data to be stored is less than the unit value, waiting for the next frame of data to arrive and then storing the data after splicing;
[0098] When the FLASH memory executes the data storage instruction, the next data storage starting address is increased by 128 after storing 128 bytes of data, and when the next data storage starting address exceeds the maximum storage address of the data space, the address of the storage space with the smallest address value is taken as the next data storage starting address.
Claims
1. A data storage and retrieval method based on FLASH, characterized in that, Includes the following steps: Step 1: Obtain the starting address for the next data storage; the FLASH memory executes the data storage instruction and checks for any data read instructions. The specific steps for obtaining the starting address of the next data storage are as follows: Step A1: Starting from the initial address in the address space, read the values of 4 consecutive bytes in the address space from smallest to largest; Step A2: If the values of the four consecutive bytes read are all 0xFF, the address value of the previous group of four bytes is the starting address of the next data storage, and this address is saved; if the values of the four consecutive bytes read are not all 0xFF, the address of the storage space with the smallest address value is the starting address of the next data storage, and this address is saved. Step 2: If a data read command is detected, the FLASH memory stops executing data storage commands and executes data read commands; if no data read command is detected, the FLASH memory continues to execute data storage commands. When the FLASH memory executes a data read instruction, the next data storage start address is the data read end address; when the FLASH memory executes a data storage instruction, the next data storage start address is the data storage start address.
2. The data access method based on FLASH according to claim 1, characterized in that, The FLASH memory includes an address space. The address data in the address space is stored sequentially from smallest to largest address value. When the address space is full, the address data stored in the address space is erased and the data is stored again starting from the address space with the smallest address value.
3. The FLASH-based data access method according to claim 2, characterized in that, The FLASH memory also includes a data space, which is divided into several storage spaces of the same size according to the address value. The data to be stored is first stored in the storage space with the smaller address value. After the data space is full, the stored data in the storage space with the smallest address value is erased, and data is stored in that storage space.
4. The FLASH-based data access method according to claim 3, characterized in that, When the starting address of the next data storage is the address of the storage space with the smallest address value, the storage data in the address space is erased before the data to be stored is stored.
5. The FLASH-based data access method according to claim 4, characterized in that, The specific steps for the FLASH memory to execute data storage instructions are as follows: Step B1: Obtain the data to be stored, its length, and the starting address for the next data storage. Step B2: Store the data to be stored in the data space in units of X bytes. If the stored data is less than the unit value, wait until the next frame of data arrives, then concatenate the data and store it in the data space. The value of X ranges from 1 to 256.
6. The FLASH-based data access method according to claim 5, characterized in that, When the FLASH memory executes a data storage instruction, after storing X bytes of data, the starting address of the next data storage is increased by X bytes. When the starting address of the next data storage exceeds the maximum storage address of the data space, the address of the storage space with the smallest address value is taken as the starting address of the next data storage.
7. The FLASH-based data access method according to claim 6, characterized in that, The specific steps for the FLASH memory to execute data read instructions are as follows: Step C1: Obtain the hourly duration of the data to be read; Step C2: Convert the hour duration of the data to be read into the length of the data in bytes; Step C3: Calculate the starting address of the data to be read by combining the length of the data to be read in bytes with the starting address of the next data storage; Step C4: Read the data stored in the data space corresponding to the address between the starting address of the data to be read and the starting address of the next data storage.
8. The FLASH-based data access method according to claim 7, characterized in that, When the FLASH memory executes a data read instruction, if the length of the data byte to be read is greater than the number of bytes already stored in the data space, the starting address of the data to be read is the address of the storage space with the smallest address value.
Citation Information
Patent Citations
Capacity identification method and capacity identification system of FLASH
CN113345510A
Storage space management method of Flash memory and data read-write system
CN117194279A