FLASH data storage method
By acquiring and generating target serial numbers, the problem of shortened lifespan caused by traditional FLASH data storage methods is solved, achieving the effect of reducing the number of erasures and extending usage time.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-28
- Publication Date
- 2026-03-10
AI Technical Summary
Traditional FLASH data storage methods lead to premature consumption of FLASH memory, especially in high-frequency usage scenarios where usage time is significantly shortened.
By obtaining the sequence number of the latest data packet in the target sector as the standard sequence number, it is confirmed whether the maximum supported sequence number has been reached. If not, a target sequence number is generated, and a target data packet is generated and written based on the data to be stored and the standard sequence number, thereby reducing the number of erase cycles.
It extends the lifespan of the FLASH memory, reduces the number of erasures, avoids repeated writing and erasing of the same area, and extends the lifespan of the device.
Smart Images

Figure CN121635809A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of memory technology, and more particularly to a FLASH data storage method. Background Technology
[0002] Flash memory (FLASH) is a commonly used non-volatile storage medium in microcontrollers. Data is retained even when power is off, and it's used to store program code and user parameters (such as device operating thresholds and configuration information). The traditional data writing method involves first erasing the old data from the FLASH sectors and then writing the new user data into the sectors. However, FLASH typically has a fixed lifespan, such as 100,000 erase / write cycles. Frequent erasing and writing will rapidly deplete the FLASH's lifespan, significantly shortening its lifespan in high-frequency usage scenarios. Summary of the Invention
[0003] This invention provides a FLASH data storage method, which aims to solve the problem that current FLASH data storage methods consume FLASH lifespan too quickly.
[0004] In a first aspect, embodiments of the present invention provide a FLASH data storage method, the method comprising: Controlled by the write command that writes the data to be stored, obtain the sequence number of the latest data packet in the target sector to obtain the standard sequence number; Confirm whether the standard serial number has reached the maximum supported serial number of the target sector; If the standard serial number does not reach the maximum supported serial number, then a target serial number is generated based on the standard serial number; A target data packet is generated based on the data to be stored and the standard serial number, and the target data packet is written into the target sector.
[0005] Secondly, embodiments of the present invention also provide a FLASH data storage device, the device comprising: The first acquisition unit is used to acquire the sequence number of the latest data packet in the target sector to obtain a standard sequence number, controlled by the write instruction that writes the data to be stored. The first confirmation unit is used to confirm whether the standard serial number has reached the maximum supported serial number of the target sector; The first generation unit is configured to generate a target sequence number based on the standard sequence number if the standard sequence number does not reach the maximum supported sequence number. The second generation unit is used to generate a target data packet based on the data to be stored and the standard sequence number, and write the target data packet into the target sector.
[0006] Thirdly, embodiments of the present invention also provide a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.
[0007] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the above-described method.
[0008] This invention provides a FLASH data storage method. The method includes: obtaining a standard sequence number by acquiring the sequence number of the latest data packet in the target sector, controlled by a write instruction to write data to be stored; confirming whether the standard sequence number reaches the maximum supported sequence number of the target sector; if the standard sequence number does not reach the maximum supported sequence number, generating a target sequence number based on the standard sequence number; generating a target data packet based on the data to be stored and the standard sequence number, and writing the target data packet into the target sector. This invention allows the latest data packet sequence number to be used as the standard sequence number during data writing. If the standard sequence number does not reach the maximum supported sequence number of the target sector, a target data packet can be generated based on the data to be stored and the standard sequence number, and then written to the target sector. This reduces the number of erase operations and extends the FLASH memory's lifespan. Attached Figure Description
[0009] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are 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 the FLASH data storage method provided in an embodiment of the present invention; Figure 2 This is a schematic block diagram of the FLASH data storage device provided in the embodiments of the present invention; Figure 3 This is a schematic block diagram of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0011] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. 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] It should be understood that, when used in this specification and the appended claims, the terms “comprising” and “including” indicate the presence of the described features, integrals, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, operations, elements, components and / or collections thereof.
[0013] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.
[0014] Please see Figure 1 , Figure 1 This is a flowchart illustrating the FLASH data storage method provided in an embodiment of the present invention. This FLASH data storage method can be applied to computer devices, such as IoT terminal devices and industrial control equipment, to write data and improve the lifespan of the FLASH memory. Figure 1 As shown, the method includes steps S110 to S140.
[0015] S110, controlled by the write command that writes the data to be stored, obtains the sequence number of the latest data packet in the target sector to obtain the standard sequence number.
[0016] In this embodiment of the invention, the data packet structure may include a frame header, a sequence number, user data, and a checksum. The frame header is 0xaa55, and its binary value is alternating between 1 and 0 to prevent frame header corruption. The sequence number represents the number of times the data is stored, and it increases incrementally. The user data has a fixed data length, which is user-defined and does not exceed the minimum erase sector of the microcontroller by 4. The checksum is the lower 8 bits of the sum from the frame header to the user data, which are then stored as the checksum value.
[0017] When data needs to be written to the storage, that is, when a write command is received, the target sector can be traversed to obtain the sequence number of the latest data packet. The sequence number of the latest data packet refers to the sequence number corresponding to the last data packet written. For example, the microcontroller configuration information can be read to determine the starting address of the target sector (such as 0x08004000) and the total length of a single data packet (frame header length + sequence number length + user data length + checksum length). Then, starting from the starting address, each data packet is read sequentially until the latest data packet is read, and the sequence number of the latest data packet is used as the standard sequence number.
[0018] S120, confirm whether the standard serial number has reached the maximum supported serial number of the target sector.
[0019] In this embodiment of the invention, the maximum supported sequence number can be obtained by dividing the target sector capacity by the length of a single data packet. For example, if the target sector capacity is 2048 bytes and the total length of a single data packet is 105 bytes, then the maximum supported sequence number is 2048÷105-1≈19-1=18 (rounded down to ensure that all data packets can be completely stored in the sector).
[0020] Setting a maximum supported serial number can prevent data packets from exceeding the sector storage range, and recycling sectors can prevent repeated erasure and writing of the same area, thereby extending the usage time.
[0021] S130, if the standard serial number does not reach the maximum supported serial number, then generate a target serial number based on the standard serial number.
[0022] In this embodiment of the invention, if the standard serial number has not reached its maximum value, a target serial number can be generated based on the standard serial number, wherein the target serial number = standard serial number + 1. For example, if the standard serial number = 9, then the target serial number = 10, maintaining the continuous incrementing characteristic of the serial number. Each serial number uniquely corresponds to one storage operation, which not only provides a clear basis for subsequent traversal and reading of the latest data, but also avoids frequent erasure and writing of the same storage unit by distributing the write addresses.
[0023] S140, Generate a target data packet based on the data to be stored and the standard serial number, and write the target data packet into the target sector.
[0024] In this embodiment of the invention, the data packet structure may include a frame header, a sequence number, user data, and a checksum. The frame header is fixedly filled with 0xaa55 for subsequent verification. The sequence number is the target sequence number, and the user data is the data to be stored. The checksum is obtained by calculating the sum of the frame header, sequence number, and user data, and then using the lower 8 bits as the checksum value to ensure unaltered data transmission. That is, after obtaining the target sequence number and the data to be stored, a checksum can be generated based on the frame header, target sequence number, and data to be stored. Then, a target data packet is generated based on the frame header, sequence number, user data, and checksum. Finally, the target data packet is written to the target sector using the FLASH erase / write function.
[0025] For example, suppose a microcontroller's FLASH erase sector size is 2048 bytes. The user needs to store device operating parameters (such as temperature threshold and voltage setting value). The user data length is 100 bytes. The single data packet format is frame header (2 bytes) + serial number (4 bytes) + user data (100 bytes) + checksum (1 byte). Then the total length of a single data packet is 107 bytes, and the sector can hold 19 data packets (2048 ÷ 107 ≈ 19.14, rounded down to 19 packets, the maximum serial number is 18).
[0026] First write (serial number starts from 0) Get the current serial number: After the microcontroller is powered on, it traverses the FLASH and finds no historical stored data. The default standard serial number is 0 (initial base value).
[0027] Determine if the sequence number is the largest: 0 < 18; Serial number increment: 0+1=1, target serial number is 1; Generate target data packet: Frame header: 0xaa55; Target serial number: 0x00000001; User data: Assuming a temperature threshold of 25℃ (0x19), a voltage setting of 3.3V (0x0D03), etc., totaling 100 bytes of fixed-length data; Checksum: The checksum is accumulated sequentially from the frame header (0xaa55) to the user data, and the total sum is 0x123456. The lower 8 bits, 0x56, are taken as the checksum.
[0028] Call the FLASH write function, specify the starting address of the sector (e.g., 0x08004000), and write the complete 107-byte data packet.
[0029] 5th write Get the current serial number: Traverse the FLASH to find the last stored data packet, the standard serial number is 4; Determine if the sequence number is the largest: 4 < 18; The serial number increments: 4 + 1 = 5, so the target serial number is 5; Data packet assembly: The frame header remains 0xaa55, the target sequence number is updated to 0x00000005, the user data is updated to the latest operating parameters (such as the temperature threshold of 26℃), and the checksum is recalculated (assuming a total of 0x234567 and a lower 8-bit value of 0x67).
[0030] Write the target data packet to the specified address 0x08004000 + 4 × 10⁷ bytes = 0x080041B4.
[0031] In some embodiments, such as this embodiment, the following is further included after step S120: If the standard serial number reaches the maximum supported serial number, then the backup area will be erased. Write the data packet corresponding to the standard serial number into the backup area, and erase the target sector after writing is complete; Reset the serial number of the target sector and generate a new serial number; The new serial number is used as the target serial number, and the process proceeds to the step of generating a target data packet based on the data to be stored and the standard serial number.
[0032] In this embodiment of the invention, when the standard serial number reaches the maximum supported serial number, the data in the backup area can be erased. The backup area is a critical data storage area specially divided in FLASH. By clearing the data in the backup area, the mixing of old and new data can be avoided, and the backup data can be kept clean.
[0033] Then, the data packet corresponding to the standard sequence number is read and written completely into the backup area. The backup area is physically isolated from the target sector, so even if the target sector erase fails, the backup data can still be traced.
[0034] Finally, unlock the target sector and perform a full sector erase. After the erase is complete, reset the target sector's sequence number counter to 0, and set the new sequence number to 0 (as the target sequence number for the next write). Using the new sequence number = 0 as the target sequence number, return to step S140, generate the target data packet by adding frame header + 0 + data to be stored + checksum, and write it to the target sector, starting a new round of incremental write loop.
[0035] For example, writing to the entire area Get the current serial number: The last stored serial number was 18 (the maximum supported serial number for the area has been reached). Check if the sequence number is the maximum: 18 = 18, trigger full area preprocessing; Full area preprocessing: Backup data: Read the data packet corresponding to serial number 18 and write it to the preset backup area; Erase area: Unlock FLASH and erase the entire 2K storage area; Serial Number Reset: Resets the base serial number to 0; Serial number increment: 0+1=1, target serial number is 1; The frame header is 0xaa55, the sequence number is 0x00000001, the user data is the latest parameter, a new checksum is calculated, and the target data packet is generated.
[0036] Write operation: Rewrite the target data packet from the starting address of the segment 0x08004000, completing the first incremental write after the segment is full.
[0037] In some embodiments, such as this embodiment, the following is further included after step S140: Read the target data packet to obtain the data packet to be verified; A first verification value is generated based on the data packet to be verified, and a second verification value is generated based on the target data packet; If the first check value is the same as the second check value, then the writing of the target data packet is completed; If the first check value is different from the second check value, then proceed to the step of generating the target serial number based on the standard serial number.
[0038] In this embodiment of the invention, the target data packet can be verified to ensure the correctness of the stored data. That is, the data packet just written can be reread from the write address in S140, recorded as the data packet to be verified, and then the first verification value and the second verification value can be calculated respectively.
[0039] First verification value: Directly extract the verification code field from the data packet to be verified; The second check value is calculated by recalculating the sum of the "frame header + sequence number + user data" of the data packet to be checked, and taking the lower 8 bits.
[0040] If the first check value matches the second check value, the data writing is considered successful. If they do not match, it means that the data has been tampered with or lost during the writing process. Return to step S130 to regenerate the target sequence number to avoid data corruption caused by a single write failure.
[0041] In some embodiments, such as this embodiment, the FLASH data storage method further includes: Obtain the starting address and single data packet length of the target sector; Based on the starting address and the single data packet length, all data packets of the target sector are read sequentially. If the read data packet is the initial value, then stop reading data and set the previous data packet corresponding to the initial value as the latest data packet; If the data packet read is not the initial value, continue reading the next data packet until the data packet read is the initial value.
[0042] In this embodiment of the invention, the starting address of the target sector (e.g., 0x08004000) and the total length of a single data packet (determined by the sum of the lengths of the frame header, sequence number, user data, and checksum) can be read from the microcontroller system configuration. Then, the target sector is traversed and read starting from the starting address to determine the latest data packet.
[0043] For example, starting from index i, data is read sequentially according to the formula: current address = starting address + i × total length of single data packet. After each read, it is checked whether the data is 0xFFFFFFFF (FLASH initial value). If it is, the traversal stops and the data packet corresponding to index i-1 is the latest valid data packet. If not, i is incremented by 1 and the next address is read until the entire target sector is traversed.
[0044] If 0xFFFFFFFF is not found after traversing all addresses (sector is completely full), then the latest valid data packet is the data packet corresponding to index i = the maximum supported sequence number (i.e., standard sequence number = maximum supported sequence number).
[0045] In some embodiments, such as this embodiment, the FLASH data storage method further includes: The target sector is traversed and read upon power-up; If the sequence number of the read data packet is zero, then read the data packet from the backup area.
[0046] In this embodiment of the invention, during incremental writing, it can first check whether the current data packet sequence number has reached the maximum supported value of the sector. If the sequence number is equal to the maximum value, it means that the sector is full and the anti-loss backup process is triggered; if it has not reached the maximum value, no backup is required and incremental writing is performed directly.
[0047] After triggering the backup process to prevent data loss, the system traverses the sectors to find the last stored data packet (i.e., the data packet with the maximum sequence number). It confirms that this data passes the frame header and checksum (ensuring that the backed-up data is valid), then reads the valid data packet completely and writes it to the preset backup area. After backup is complete, the FLASH memory is unlocked, and a complete erase operation is performed on the main storage sectors. The incrementing base sequence number is reset to 0, and subsequent new data is written starting from the sector's starting address with the sequence number incremented by 1, forming a circular storage pattern.
[0048] After power-on, a traversal read is performed. If the sequence number of the last stored data packet is found to be 0, the historical valid data stored in the backup area is immediately read. The data packet is verified according to the frame header and checksum. If the verification passes, the data is directly used as the system running parameters to avoid the absence of valid data after the main sector is erased. If the backup verification fails (such as due to an unexpected power outage during backup), the system default parameters are enabled.
[0049] For example, assuming the 2K sector is full with 19 packets of data, a backup is triggered: The data packet with sequence number 18 has been verified (the frame header 0xaa55 and the checksum match). Write the data packet to the backup area; Erase the main sector (data becomes 0xFFFFFFFF), reset the serial number to 0; The new data is rewritten to the main sector according to sequence number 1; If power is applied at this time, the system will find that the latest serial number of the main sector is 0. It will then read the data packet with serial number 18 from the backup sector. After verification, the data will be used directly.
[0050] The FLASH data storage method of the present invention can use the sequence number of the latest data packet as the standard sequence number when writing data. If the standard sequence number does not reach the maximum supported sequence number of the target sector, a target data packet can be generated according to the data to be stored and the standard sequence number, and then written into the target data packet. This can reduce the number of erasures and extend the usage time of the FLASH.
[0051] Figure 2 This is a schematic block diagram of a FLASH data storage device 100 provided in an embodiment of the present invention. Figure 2 As shown, corresponding to the above-described FLASH data storage method, the present invention also provides a FLASH data storage device 100. This FLASH data storage device 100 includes a unit for executing the above-described FLASH data storage method. Specifically, please refer to... Figure 2 The FLASH data storage device 100 includes a first acquisition unit 110, a first confirmation unit 120, a first generation unit 130, and a second generation unit 140.
[0052] The first acquisition unit 110 is used to acquire the sequence number of the latest data packet in the target sector to obtain a standard sequence number, controlled by a write instruction to write the data to be stored. The first confirmation unit 120 is used to confirm whether the standard serial number has reached the maximum supported serial number of the target sector; The first generation unit 130 is used to generate a target sequence number based on the standard sequence number if the standard sequence number does not reach the maximum supported sequence number. The second generation unit 140 is used to generate a target data packet based on the data to be stored and the standard sequence number, and write the target data packet into the target sector.
[0053] In some embodiments, such as this one, the FLASH data storage device 100 further includes a first erasure unit, a second erasure unit, a third generation unit, and a first jump unit.
[0054] The first erasure unit is used to erase the backup area if the standard serial number reaches the maximum supported serial number. The second erasure unit is used to write the data packet corresponding to the standard serial number into the backup area, and erase the target sector after the writing is completed; The third generation unit is used to reset the serial number of the target sector and generate a new serial number; The first jump unit is used to use the new sequence number as the target sequence number and proceed to the step of generating a target data packet based on the data to be stored and the standard sequence number.
[0055] In some embodiments, such as this one, the FLASH data storage device 100 further includes a first reading unit, a fourth generating unit, a first confirming unit, and a second jump unit.
[0056] The first reading unit is used to read the target data packet to obtain the data packet to be verified; The fourth generation unit is used to generate a first verification value based on the data packet to be verified, and to generate a second verification value based on the target data packet; The first confirmation unit is used to complete the writing of the target data packet if the first verification value is the same as the second verification value. The second jump unit is used to proceed to the step of generating a target serial number based on the standard serial number if the first verification value is different from the second verification value.
[0057] In some embodiments, such as this one, the FLASH data storage device 100 further includes a second acquisition unit, a second reading unit, a first setting unit, and a first looping unit.
[0058] The second acquisition unit is used to acquire the starting address and single data packet length of the target sector; The second reading unit is used to sequentially read all data packets of the target sector based on the starting address and the single data packet length; The first setting unit is used to stop reading data if the read data packet is an initial value, and set the previous data packet of the data packet corresponding to the initial value as the latest data packet; The first loop unit is used to continue reading the next data packet if the read data packet is not the initial value, until the read data packet is the initial value.
[0059] In some embodiments, such as this one, the FLASH data storage device 100 further includes a third reading unit and a fourth reading unit.
[0060] The third reading unit is used to traverse and read the target sector when powered on. The fourth reading unit is used to read data packets in the backup area if the sequence number of the read data packet is zero.
[0061] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned FLASH data storage device and each unit can be referred to the corresponding description in the foregoing method embodiments. For the sake of convenience and brevity, it will not be repeated here.
[0062] The aforementioned FLASH data storage device can be implemented as a computer program, which can be used in, for example... Figure 3 It runs on the computer device shown.
[0063] Please see Figure 3 , Figure 3 This is a schematic block diagram of a computer device provided in an embodiment of this application. The computer device 500 includes a processor 502, a memory, and an interface 507 connected via a system bus 501, wherein the memory may include a non-volatile storage medium 503 and internal memory 504.
[0064] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, it causes the processor 502 to execute a FLASH data storage method.
[0065] The processor 502 provides computing and control capabilities to support the operation of the entire computer device 500.
[0066] The internal memory 504 provides an environment for the execution of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a FLASH data storage method.
[0067] This interface 505 is used for communication with other devices. Those skilled in the art will understand that... Figure 3The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 500 to which the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0068] It should be understood that in the embodiments of this application, the processor 502 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (FSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0069] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program may be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0070] Therefore, the present invention also provides a storage medium. This storage medium can be a computer-readable storage medium. The storage medium stores a computer program. When executed by a processor, the computer program implements any embodiment of the above-described FLASH data storage method.
[0071] The storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.
[0072] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0073] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0074] The steps in the method of this invention can be adjusted, merged, or reduced in order according to actual needs. The units in the device of this invention can be merged, divided, or reduced according to actual needs. Furthermore, the functional units in the various embodiments of this 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.
[0075] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present 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 storage medium and includes several instructions to cause a computer device to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0076] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0077] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Since these modifications and variations fall within the scope of the claims and their equivalents, this invention also intends to include these modifications and variations.
[0078] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A FLASH data storage method, characterized by, The method comprises: controlled by a write instruction of writing to-be-stored data, acquiring a serial number of a latest data packet of a target sector to obtain a standard serial number; confirming whether the standard serial number reaches a maximum supported serial number of the target sector; if the standard serial number does not reach the maximum supported serial number, generating a target serial number according to the standard serial number; generating a target data packet according to the to-be-stored data and the standard serial number, and writing the target data packet to the target sector.
2. The method of claim 1, wherein, After the step of confirming whether the standard serial number reaches the maximum supported serial number of the target sector, the method further comprises: if the standard serial number reaches the maximum supported serial number, performing an erasing action on a backup area; writing a data packet corresponding to the standard serial number to the backup area, and erasing the target sector after the writing is completed; resetting the serial number of the target sector, and generating a new serial number; taking the new serial number as the target serial number and entering the step of generating a target data packet according to the to-be-stored data and the standard serial number.
3. The method of claim 1, wherein, After the step of writing the target data packet to the target sector, the method further comprises: reading the target data packet to obtain a to-be-verified data packet; generating a first check value according to the to-be-verified data packet, and generating a second check value according to the target data packet; if the first check value is the same as the second check value, completing the writing of the target data packet.
4. The method of claim 3, wherein, After the step of generating the second check value according to the target data packet, the method further comprises: if the first check value is different from the second check value, entering the step of generating a target serial number according to the standard serial number.
5. The method of claim 1, wherein, The method further comprises: acquiring a starting address and a single data packet length of the target sector; sequentially reading all data packets of the target sector based on the starting address and the single data packet length; if the read data packet is an initial value, stopping data reading, and setting a previous data packet of the data packet corresponding to the initial value as the latest data packet.
6. The method of claim 5, wherein, After the step of sequentially reading all data packets of the target sector based on the starting address and the single data packet length, the method further comprises: if the read data packet is not the initial value, continuing to read a next data packet until the read data packet is the initial value.
7. The method of claim 1, wherein, The method further comprises: performing traversal reading on the target sector when power is turned on; if a serial number of the read data packet is zero, reading a data packet in a backup area.
8. A FLASH data storage device, characterized by The device comprises: a first acquisition unit configured to, controlled by a write instruction of writing to-be-stored data, acquire a serial number of a latest data packet of a target sector to obtain a standard serial number; a first confirmation unit configured to confirm whether the standard serial number reaches a maximum supported serial number of the target sector; a first generation unit configured to, if the standard serial number does not reach the maximum supported serial number, generate a target serial number according to the standard serial number; a second generation unit configured to generate a target data packet according to the to-be-stored data and the standard serial number, and write the target data packet to the target sector.
9. A computer device, comprising: The computer device comprises a memory and a processor connected to the memory; the memory is used to store a computer program; and the processor is used to run the computer program stored in the memory to execute the steps of the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the method according to any one of claims 1-7.