A high-reliability embedded memory structure, a forming method thereof, an electronic device, and a storage medium

By using a structure of configuration blocks, index blocks, and data blocks, combined with multi-level verification and sequential write mechanisms, the problems of bad block identification, garbage collection, and power failure security in embedded storage are solved, achieving high-reliability data storage and system scalability to meet the needs of different application scenarios.

CN122240011APending Publication Date: 2026-06-19SHENZHEN CHANGER MEDICAL TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN CHANGER MEDICAL TECH CO LTD
Filing Date
2026-01-22
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing embedded storage technologies suffer from several problems: lack of block-level state management, inability to identify bad blocks affecting subsequent data storage; low garbage collection efficiency, long processing time and high power consumption; weak power-loss security; lack of atomicity guarantees for index and data updates; and a fixed number of index entries, making it unsuitable for different application scenarios and functional expansions.

Method used

It adopts a structure of configuration blocks, index blocks, and data blocks. It uses block status information to isolate bad blocks and perform garbage collection. The configuration blocks store system parameters, the index blocks manage data records, and the data blocks store actual data. It uses a multi-level verification and sequential write mechanism to ensure power failure safety, and the reserved fields in the configuration area support function expansion.

Benefits of technology

It achieves a 99.99% data corruption detection rate, reduces the number of garbage collections, extends device lifespan, ensures power-down safety and system scalability, and supports dynamic index management and encryption functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122240011A_ABST
    Figure CN122240011A_ABST
Patent Text Reader

Abstract

This application discloses a high-reliability embedded storage structure, its formation method, electronic device, and storage medium, including a configuration block, an index block, and multiple data blocks. The configuration block stores global system parameters and verification information, the index block manages index entries for data records, and the data blocks store actual data records and implement bad block isolation and garbage collection through block status information. The formation method includes initializing the storage area, writing data, reading data, and garbage collection steps, ensuring power-loss safety and data consistency through multi-level verification and sequential write mechanisms. This application is applicable to IoT devices, industrial control, and consumer electronics, achieving low-power, high-reliability persistent data storage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to a high-reliability embedded storage structure, its formation method, electronic device, and storage medium, belonging to the field of embedded storage technology. Background Technology

[0002] With the rapid development of fields such as the Internet of Things, industrial control, and consumer electronics, embedded systems are increasingly demanding higher reliability and stability in data storage. Embedded storage systems typically use FLASH memory as the primary non-volatile storage medium and need to achieve efficient data management, bad block handling, and power-loss protection within limited hardware resources. Traditional embedded storage solutions often suffer from insufficient reliability and poor scalability when facing complex application scenarios.

[0003] In the prior art, several embedded storage solutions have been proposed. Chinese patent CN106776106A discloses a data storage method based on NandFlash, dividing the NandFlash into a data storage area, a bad block area, and a spare data area, and establishing a corresponding mapping table for bad block replacement. Chinese patent CN120353386B proposes an embedded data storage method that improves data storage efficiency and reliability by dividing the storage space into different functional areas and setting a backup index area. Chinese patent CN111400248B describes a method for writing and restoring data, ensuring the integrity of data in the file system through status information management. Chinese patent CN108228479B provides an embedded FLASH data storage method, employing a storage approach where the index area and data area extend from both ends towards the middle, maximizing the utilization of FLASH space. Chinese patent CN104504349B discloses a secure video recording data storage device, including a dedicated partition table module, an index block module, and a data block module, improving storage security through data block header backup.

[0004] However, existing technologies still suffer from the following technical problems: First, there is a lack of block-level state management. Current solutions typically treat the data area as a contiguous space, failing to effectively identify and isolate bad blocks. A write failure at any point affects the normal storage of all subsequent data. Second, garbage collection is inefficient. Collection requires scanning the entire data area, which is time-consuming and power-intensive, making it unsuitable for battery-powered embedded devices. Third, power-loss security is weak. Index and data updates lack atomicity guarantees. If a power outage occurs before updating the index, it will lead to the serious problem of data existing but the index being lost, affecting data integrity and consistency. Finally, system scalability is poor. The number of index entries is usually fixed, unable to dynamically adapt to changes in the number of keys required for different application scenarios. Furthermore, the lack of reserved fields to support future functional expansion limits the system's flexibility and maintainability. Summary of the Invention

[0005] To address the technical problems of existing embedded storage technologies, such as lack of block-level state management, low garbage collection efficiency, weak power-down security, and poor scalability, and to achieve the technical effects of high-reliability data storage and extended device lifespan, this application provides a high-reliability embedded storage structure, its formation method, electronic device, and storage medium.

[0006] The technical problem this application aims to solve is to address the shortcomings of existing embedded storage technologies: existing technologies treat the data area as a continuous space, making it impossible to identify bad blocks, and once a write fails at a certain point, it affects all subsequent data; garbage collection requires scanning the entire data area, which is time-consuming and power-consuming, making it unsuitable for battery-powered devices; there is no atomicity guarantee between index and data updates, and if power is lost before updating the index, the data will exist but the index will be lost; the number of index entries is fixed, making it impossible to dynamically adapt to different key count scenarios, and there are no reserved fields to support future functional expansion.

[0007] The technical solution adopted by this application to solve its technical problem is: In a first aspect, this application provides a high-reliability embedded storage structure, including: Configuration block, index block, and multiple data blocks; The configuration block stores global system parameters and verification information, the index block manages index entries for data records, and the data block stores actual data records. Bad block isolation and garbage collection are achieved through block status information.

[0008] Furthermore, the configuration block includes an active block identifier field, a garbage collection threshold field, an initialization flag field, an encryption enable field, and a configuration verification field; The active block identifier field indicates the number of the currently active data block, and the initialization flag field is used to identify the initialization status of the storage area.

[0009] Furthermore, the index block includes multiple index entries, each index entry including a key value field, a block number field, an offset field, a length field, and a status field; The status field is used to identify the validity of the index item and supports dynamic index management.

[0010] Furthermore, each of the data blocks includes a record storage area and a block status area; The record storage area is used to store multiple data records, each data record including a key field, a data length field, a data body field, and a record verification field; The block status area includes block status bytes and block check bytes, which are used to identify the usage status and integrity of the data block.

[0011] Secondly, this application also provides a method for forming a high-reliability embedded memory structure, comprising the following steps: Initialize the storage area, write data to the storage area, read data from the storage area, and perform garbage collection on the storage area; The method ensures power-loss safety and data consistency through multi-level verification and sequential write mechanisms.

[0012] Furthermore, the initialization of the storage area includes: When the system powers on, it checks the cyclic redundancy check value of the configuration area and the index area. If the check fails, it performs the initial initialization, erases and resets the storage area parameters; if the check succeeds, it traverses the data blocks, verifies the block integrity and marks the abnormal blocks. Preferably, the initial initialization includes: Set default configuration parameters, clear all index entries, mark all data blocks as idle, and calculate and store the cyclic redundancy check value for the configuration area and the index area.

[0013] Furthermore, the step of writing data to the storage area includes: After the application layer initiates a write request, it constructs a data record structure, writes the record to the currently active data block, updates the index area to reflect the position and status of the new record, and updates the verification information of the data block, index area and configuration area in sequence to ensure atomic operation. Preferably, if the current active data block space is insufficient, the next free block is searched as the new active block, or garbage collection is triggered to free up space, ensuring the continuity of write operations.

[0014] Furthermore, the step of reading data from the storage area includes: After the application layer initiates a read request, it traverses the index area to match valid index entries, locates the data record based on the index entry, verifies the length and verification information of the record, and returns the data body; if the verification fails, the index entry is marked as invalid.

[0015] Furthermore, the step of recycling waste from the storage area includes: When the number of idle data blocks is lower than the threshold, the data block with the fewest valid records is selected as the recycling target, the valid records are migrated to the current active block, the original target block is erased and its state is reset, thereby optimizing storage space and extending device life. Preferably, when migrating valid records, the index entries are updated synchronously to point to the new location, and the original index entries are marked as invalid, thereby maintaining the consistency between the index and the data.

[0016] Furthermore, the method also includes a power-off recovery mechanism; If a power outage occurs during the write process, the system will automatically rebuild a valid index after power is restored by verifying the consistency between the data records and index entries.

[0017] Thirdly, this application also provides an electronic device, including a highly reliable embedded storage structure as described in any one of the first aspects above; The electronic device is a microcontroller or embedded system, suitable for IoT devices, industrial control or consumer electronics, and achieves low-power, high-reliability persistent data storage through the storage structure.

[0018] Fourthly, this application also provides a computer-readable storage medium storing program instructions that, when executed by a processor, implement a method for forming a high-reliability embedded storage structure as described in any one of the second aspects above.

[0019] The beneficial effects that this application can produce include: This application employs a three-level verification mechanism (cyclic redundancy check in the configuration area, cyclic redundancy check in the index area, data block verification, and record verification), achieving a data corruption detection rate of over 99.99%. Automatic isolation of bad blocks prevents the entire storage area from failing due to a single point of failure. Garbage collection operates on individual data blocks instead of a full disk scan, significantly reducing the number of erase / write cycles and extending device lifespan. The write order—data block → index area → configuration area—ensures power-loss safety, resolving the problem of data existence but index loss in existing technologies. Reserved fields in the configuration area support functional extensions such as encryption switches and version numbers. Compared to the fixed number of index items in existing technologies, this application offers better adaptability and scalability. Attached Figure Description

[0020] Figure 1 This is an overall structural block diagram of a high-reliability embedded storage structure provided in one embodiment of this application; Figure 2 This is a flowchart illustrating a method for forming a high-reliability embedded storage structure according to one embodiment of this application. Detailed Implementation

[0021] The present application is described in detail below with reference to the embodiments, but the present application is not limited to these embodiments.

[0022] Example 1 In this embodiment, please refer to Figure 1 This application provides a highly reliable embedded storage structure that rationally divides the storage space into three functional areas: a configuration block, an index block, and multiple data blocks. The configuration block occupies 128 bytes of space, the index block occupies 388 bytes of space, and the remaining space is divided into 56 data blocks, each with a capacity of 64 bytes.

[0023] As an example, the configuration block is responsible for storing global system parameters and verification information. Its internal structure includes five key fields: active block identifier, garbage collection threshold, initialization flag, encryption enable, and configuration verification. The active block identifier indicates the currently active data block number, initially set to active_block=0 in this embodiment. The garbage collection threshold is set to gc_threshold=10, controlling the triggering condition of the garbage collection mechanism. The initialization flag indicates the storage area's initialization status, set to init_flag=0x01 after initialization. The encryption enable field controls the enabling state of data encryption. The configuration verification field stores the CRC checksum of the configuration area (config_crc), ensuring the integrity and reliability of the configuration information.

[0024] As an example, an index block manages the index entries for data records and contains a structure of 64 index entries. Each index entry consists of a key field, a block number field, an offset field, a length field, and a status field. The key field stores a unique identifier for the data record, the block number field indicates the data block number where the data record resides, the offset field indicates the starting position of the data record within the data block, and the length field records the actual length of the data content. The status field is used to identify the validity of the index entry, supporting dynamic index management; a valid index entry is set to 0x01, and an invalid or idle index entry is set to 0x00. The index block ends with an index_crc checksum to ensure the data integrity of the index information.

[0025] As an example, a data block serves as the storage medium for actual data records. Each data block is internally divided into two functional areas: a record storage area and a block status area. The record storage area occupies 62 bytes and stores multiple data records. Each data record includes four parts: a key field, a data length field, a data body field, and a record checksum field. The key field uses 2 bytes to store a unique identifier for the data record. The data length field uses 1 byte to record the actual length of the data body. The data body field stores the specific data content. The record checksum field uses a 2-byte CRC checksum to ensure the data integrity of a single record. The block status area occupies 2 bytes and contains a block status byte and a block checksum byte. The block status byte indicates the usage status of the data block: 0x00 for idle, 0x01 for in use, and 0x02 for pending reclamation. The block checksum byte stores the CRC checksum of the entire data block, used to verify the integrity of the data block.

[0026] It should be noted that upon system power-on, the first step is to verify the configuration area `config_crc` and the index area `index_crc`. If verification fails, it indicates either the system is powering on for the first time or the storage area is corrupted. In this case, the initial initialization process is executed: the configuration and index areas are erased, `active_block=0`, `gc_threshold=10`, and `init_flag=0x01` are set, the Status of all 64 index entries is set to 0x00, the 56 data blocks are traversed, and each block's BlockStatus is set to 0x00 and BlockCRC is set to 0. After initialization, the values ​​are calculated and written to the configuration area `config_crc` and the index area `index_crc`. If verification succeeds, the system directly proceeds to the data block verification stage to ensure that all data blocks can be correctly identified and accessed in the initial state.

[0027] Furthermore, the data write operation is illustrated using Key=0x1234 and Data=ABC as an example. First, a Record structure is constructed with a total length of 8 bytes. Key=0x1234 occupies 2 bytes, Length=0x03 occupies 1 byte, Data=ABC occupies 3 bytes, and the CRC checksum occupies 2 bytes. After checking the index area to confirm that there is no valid index entry for this key, the available offset of the currently active block 0 is read to confirm that the remaining space in the 62-byte Record storage area of ​​block 0 can accommodate 8 bytes of Record. The constructed Record is written to block 0, and the available offset of block 0 is updated to 8 after the write is complete. Then, the block status information at the end of block 0 is updated, the BlockCRC is calculated and written, and the BlockStatus is updated from 0x00 to 0x01. Next, a free index slot is allocated in the index area, filled with Key=0x1234, BlockID=0, Offset=0, Length=3, and Status=0x01, and the index_crc is recalculated and updated. The entire writing process strictly follows the writing order of data block → index area → configuration area to ensure that the data already written can be correctly processed by the subsequent recovery mechanism in the event of a power outage.

[0028] The garbage collection mechanism uses block status information to isolate bad blocks and perform garbage collection. When the system counts that the number of free blocks is less than or equal to 10, the `gc_threshold` threshold is triggered, initiating the garbage collection process. First, it iterates through 56 inactive data blocks, counting the number of valid records for each block, and selects the block with the fewest valid records as the target for collection. The records within the target block are read, and their keys are verified against the index to ensure a valid index entry exists. Records deemed invalid do not need to be migrated. After confirming no valid data, the target block's `BlockStatus` is set to 0x02, marking it as awaiting collection. Then, the entire block's data is erased, `BlockStatus` is reset to 0x00, `BlockCRC` to 0, and it is reinstated into the free block pool. After collection is complete, the system resource statistics are updated.

[0029] This system possesses a robust power-loss safety protection mechanism. In a forced power-off scenario simulating writing to a Record but before updating the index, upon power-up, the system first performs CRC checks on the configuration and index areas. Then, it iterates through all data blocks, checking the BlockCRC, parsing each Record within a data block and verifying its internal CRC. If a Record is found to be complete but lacks a corresponding valid index entry in the index area, the system marks it as pending confirmation. During normal operation, when garbage collection is triggered, the system verifies that the Record's Key lacks a valid index entry, deeming it invalid data and not migrating it. The data block is then erased and reset to a free block. Through the synergistic effect of data block verification and garbage collection mechanisms, the system ensures storage consistency, avoiding data inconsistencies caused by missing indexes, and maintaining high reliability of the storage structure even during power outages in the intermediate stages.

[0030] Example 2 In this embodiment, please refer to Figure 2 This application also provides a method for forming a high-reliability embedded storage structure, based on a 4KB storage medium, which is divided into one configuration block (128 bytes), one index block (388 bytes), and 56 data blocks (64 bytes each). This method ensures power-loss safety and data consistency through a multi-level verification and sequential write mechanism, and includes the following steps: Step 1: Initialize the storage area After the system powers on, it first verifies the cyclic redundancy check (CRC) values ​​of the configuration area (config_crc) and the index area (index_crc). If the verification fails, it performs initial initialization, erasing and resetting storage parameters. If the verification succeeds, it traverses data blocks, verifies block integrity, and marks abnormal blocks. Initial initialization includes: erasing data in the configuration and index areas, setting default configuration parameters such as active_block=0, gc_threshold=10, and init_flag=0x01, clearing all index entries, setting the Status of all 64 index entries to 0x00, marking all data blocks as idle, traversing 56 data blocks, setting the BlockStatus of each block to 0x00 and the BlockCRC to 0, and calculating and storing the CRC values ​​of the configuration and index areas. If the verification succeeds, it directly enters the data block verification phase to ensure that all data blocks can be correctly identified and accessed in the initial state.

[0031] Step 2: Write data to storage area After the application layer initiates a write request, it constructs a data record structure, writes the record to the currently active data block, updates the index area to reflect the position and status of the new record, and updates the verification information of the data block, index area, and configuration area in sequence to ensure atomic operation. When writing Key=0x1234 and Data=ABC, a Record structure is first constructed with a total length of 8 bytes: Key=0x1234 occupies 2 bytes, Length=0x03 occupies 1 byte, Data=ABC occupies 3 bytes, and CRC occupies 2 bytes. The index area is checked and no valid entry for the Key is found. The available offset of the currently active block 0 is read, confirming that the remaining space in the 62-byte Record storage area of ​​block 0 can accommodate 8 bytes of Record. The Record is then written to block 0, and the available offset of block 0 is updated to 8. Subsequently, the tail information of block 0 is updated: the BlockCRC is calculated and written, and the BlockStatus is set from 0x00 to 0x01. Next, a free index slot is allocated in the index area, and Key=0x1234, BlockID=0, Offset=0, Length=3, Status=0x01 is filled in. The index_crc is then recalculated and updated. The entire process strictly follows the write order of data block → index area → configuration area. If the space of the currently active data block is insufficient, the next free block is searched as the new active block, or garbage collection is triggered to release space, ensuring the continuity of write operations.

[0032] Step 3: Read data from storage area After the application layer initiates a read request, it traverses the index area to match valid index entries, locates the data record based on the index entry, verifies the record's length and checksum, and returns the data body. The system searches for the corresponding valid index entry in the index area based on the key value, obtains the BlockID, Offset, and Length information, locates the specified offset position of the specific data block, reads the corresponding length of Record data, verifies the CRC checksum value inside the Record, and after confirming data integrity, extracts the data body and returns it to the application layer. If the verification fails, the index entry is marked as invalid to prevent subsequent access from corrupting the data.

[0033] Step 4: Recycle waste from the storage area. When the number of free data blocks falls below a threshold, the data block with the fewest valid records is selected as the recycling target. Valid records are migrated to the current active block, the original target block is erased, and its state is reset, thereby optimizing storage space and extending device lifespan. Garbage collection is initiated when the system counts ≤10 free blocks (triggered by `gc_threshold`). First, 56 inactive data blocks are traversed, and the number of valid records in each block is counted. The data block with the fewest valid records is selected as the recycling target. Records within the target block are read, and their validity is verified through the index area. For valid records, they are migrated to the available space of the current active block. During the migration of valid records, the index entries are synchronously updated to point to the new location, and the original index entries are marked as invalid, thus maintaining the consistency between the index and the data. After confirming there is no valid data, the target block's BlockStatus is set to 0x02, the entire block is erased, BlockStatus is reset to 0x00, BlockCRC is set to 0, and the block is added to the free block pool.

[0034] As an example, this method also includes a power-loss recovery mechanism. If a power outage occurs during the write process, the system automatically rebuilds a valid index after power-on by verifying the consistency of data records and index entries. In a forced power-off scenario simulating writing to a Record but updating the index, after power-on, the system first performs CRC checks between the configuration area and the index area. Then, it traverses all data blocks, checks the BlockCRC of each data block, parses each Record within a block and verifies its internal CRC. However, if the index area does not contain a valid entry corresponding to the RecordKey, the system marks the Record as pending confirmation. After normal operation, when garbage collection is triggered, the relevant data blocks are traversed. If the RecordKey has no valid index entry in the index area, it is determined to be invalid data. It is not migrated, but directly erased and reset to a free block. Ultimately, there is no residual invalid data in the storage area, the index and data are completely matched, the system state is restored to consistency, verifying power-loss safety and avoiding the problem of data existing but index lost.

[0035] Example 3 This embodiment also provides an electronic device, including the high-reliability embedded storage structure as described in Embodiment 1. This electronic device is a microcontroller or embedded system, suitable for IoT devices, industrial control, or consumer electronics.

[0036] The core storage architecture of this electronic device adopts a three-tier storage structure described in Embodiment 1, consisting of configuration blocks, index blocks, and multiple data blocks. The configuration block manages global system parameters and includes fields for active block identifier, garbage collection threshold, initialization flag, encryption enable, and configuration verification. The index block manages the index of data records; each index entry includes a key field, block number field, offset field, length field, and status field. The data block, as the actual data carrier, is internally divided into a record storage area and a block status area. The record storage area stores data records containing key fields, data length fields, data body fields, and record verification fields. The block status area manages block status and verifies integrity through block status bytes and block verification bytes.

[0037] This electronic device achieves low-power operation through a highly reliable embedded storage structure. In IoT device applications, devices are in a dormant state for extended periods, only briefly waking up for data acquisition or communication. The low-power characteristic of the storage structure is reflected in the high efficiency of write operations, avoiding frequent full-area scans through block state management and reducing unnecessary memory accesses. The garbage collection mechanism adopts an on-demand triggering approach, initiating the collection process only when the number of free blocks drops to a threshold, avoiding continuous background operation overhead.

[0038] In industrial control applications, this electronic device faces harsh operating environments and frequent power outages. The high reliability of the storage structure is ensured through a multi-layered verification mechanism to guarantee data integrity. The configuration area, index area, and data blocks are all equipped with CRC checks to ensure timely detection of data corruption. The power-loss safety protection mechanism, through strict write order and status marking, guarantees the recoverability of data written during intermediate power outages, avoiding data inconsistency issues.

[0039] In consumer electronics applications, this electronic device needs to handle frequent read and write operations on large amounts of user data. The storage structure improves data access efficiency through dynamic index management, and the status field of the index entries supports rapid validity checks, avoiding the repeated processing of invalid data. A bad block isolation mechanism automatically identifies and isolates damaged storage blocks through block status information, ensuring that the system can continue to operate normally even when part of the storage medium fails.

[0040] The persistent data storage function of this electronic device is implemented through global parameter management of configuration blocks. The active block identifier field dynamically points to the currently writable data block, and automatically switches to the next free block when the active block space is insufficient. The garbage collection threshold field controls the timing of storage space reclamation, balancing storage efficiency and system performance. The encryption enable field supports encrypted data storage, meeting the needs of application scenarios with high security requirements.

[0041] The entire electronic device achieves low-power, high-efficiency persistent data storage through the collaborative work of a highly reliable embedded storage structure, ensuring data security and integrity while meeting the application needs of various fields such as IoT devices, industrial control, and consumer electronics.

[0042] Example 4 In this embodiment, a computer-readable storage medium is also provided, which stores program instructions. When the program instructions are executed by a processor, the method for forming a high-reliability embedded storage structure as described in Embodiment 2 is implemented.

[0043] The computer-readable storage medium can be a non-volatile storage medium, such as flash memory, EEPROM, ROM, hard disk drive, solid-state drive, optical disk, or magnetic disk. The program instructions stored in the storage medium contain complete method implementation code, covering core functional modules such as initializing the storage area, writing data to the storage area, reading data from the storage area, and performing garbage collection on the storage area.

[0044] When the processor loads and executes these program instructions, it first executes the instruction code for initializing the memory area, which implements the function of verifying the cyclic redundancy check value of the configuration area and the index area when the system is powered on. If the verification fails, the initial initialization process is executed, which includes a sequence of instructions that set default configuration parameters such as active_block=0, gc_threshold=10, and init_flag=0x01.

[0045] The write data module in the program instructions contains the code logic for constructing the data record structure. It can write records sequentially to the currently active data block and update the index area to reflect the position and status of the new records. This module strictly updates the verification information in the order of "data block → index area → configuration area" to ensure the implementation of atomic operations. When the active data block space is insufficient, the program instructions can automatically search for the next free block or trigger the garbage collection mechanism.

[0046] The program instructions for reading data implement an algorithm that traverses the index area to match valid index entries. It locates the data record based on the index entry and verifies the record's length and verification information. If the verification fails, the index entry is automatically marked as invalid.

[0047] The garbage collection module's program instructions include logic for monitoring the number of free data blocks. When the number of free blocks falls below a threshold, the collection process is automatically triggered, selecting the data block with the fewest valid records as the collection target, thus realizing a complete process of valid record migration and index item synchronization updates.

[0048] The program instructions also include the implementation code for a power-off recovery mechanism. After the system is powered on again, it can automatically rebuild a valid index by verifying the consistency of data records and index entries, thus ensuring the reliability of the storage system and the integrity of the data.

[0049] This computer-readable storage medium implements a program by storing a complete method, enabling any computing device with the corresponding processing capabilities to execute the method for forming a highly reliable embedded storage structure, implementing a multi-level verification and sequential write mechanism to ensure power-loss safety and data consistency.

[0050] The above description is merely a few embodiments of this application and is not intended to limit this application in any way. Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any changes or modifications made by those skilled in the art without departing from the scope of the technical solution of this application using the disclosed technical content are equivalent to equivalent implementation cases and fall within the scope of the technical solution.

Claims

1. A high-reliability embedded storage structure, characterized in that, include: Configuration block, index block, and multiple data blocks; The configuration block stores global system parameters and verification information, the index block manages index entries for data records, and the data block stores actual data records. Bad block isolation and garbage collection are achieved through block status information.

2. The high-reliability embedded storage structure according to claim 1, characterized in that, The configuration block includes an active block identifier field, a garbage collection threshold field, an initialization flag field, an encryption enable field, and a configuration verification field; The active block identifier field indicates the number of the currently active data block, and the initialization flag field is used to identify the initialization status of the storage area.

3. The high-reliability embedded storage structure according to claim 1, characterized in that, The index block includes multiple index entries, each index entry including a key value field, a block number field, an offset field, a length field, and a status field; The status field is used to identify the validity of the index item and supports dynamic index management.

4. The high-reliability embedded storage structure according to claim 1, characterized in that, Each data block includes a record storage area and a block status area; The record storage area is used to store multiple data records, each data record including a key field, a data length field, a data body field, and a record verification field; The block status area includes block status bytes and block check bytes, which are used to identify the usage status and integrity of the data block.

5. A method for forming a high-reliability embedded memory structure, characterized in that, Includes the following steps: Initialize the storage area, write data to the storage area, read data from the storage area, and perform garbage collection on the storage area; The method ensures power-loss safety and data consistency through multi-level verification and sequential write mechanisms.

6. The forming method according to claim 5, characterized in that, The initialization of the storage area includes: When the system powers on, it checks the cyclic redundancy check value of the configuration area and the index area. If the check fails, it performs the initial initialization, erases and resets the storage area parameters; if the check succeeds, it traverses the data blocks, verifies the block integrity and marks the abnormal blocks. Preferably, the initial initialization includes: Set default configuration parameters, clear all index entries, mark all data blocks as idle, and calculate and store the cyclic redundancy check value for the configuration area and the index area.

7. The forming method according to claim 5, characterized in that, The step of writing data to the storage area includes: After the application layer initiates a write request, it constructs a data record structure, writes the record to the currently active data block, updates the index area to reflect the position and status of the new record, and updates the verification information of the data block, index area and configuration area in sequence to ensure atomic operation. Preferably, if the current active data block space is insufficient, the next free block is searched as the new active block, or garbage collection is triggered to free up space, ensuring the continuity of write operations; Preferably, the step of reading data from the storage area includes: After the application layer initiates a read request, it traverses the index area to match valid index entries, locates the data record based on the index entry, verifies the length and verification information of the record, and returns the data body; if the verification fails, the index entry is marked as invalid. Preferably, the step of recycling waste from the storage area includes: When the number of idle data blocks is lower than the threshold, the data block with the fewest valid records is selected as the recycling target, the valid records are migrated to the current active block, the original target block is erased and its state is reset, thereby optimizing storage space and extending device life. Preferably, when migrating valid records, the index entries are updated synchronously to point to the new location, and the original index entries are marked as invalid, thereby maintaining the consistency between the index and the data.

8. The forming method according to claim 5, characterized in that, The method also includes a power failure recovery mechanism; If a power outage occurs during the write process, the system will automatically rebuild a valid index after power is restored by verifying the consistency between the data records and index entries.

9. An electronic device, characterized in that, Includes a high-reliability embedded storage structure as described in any one of claims 1-4; The electronic device is a microcontroller or embedded system, suitable for IoT devices, industrial control or consumer electronics, and achieves low-power, high-reliability persistent data storage through the storage structure.

10. A computer-readable storage medium, characterized in that, The system stores program instructions that, when executed by a processor, implement a method for forming a high-reliability embedded storage structure as described in any one of claims 5-8.