Data storage method and system based on block-based Flash emulation EEPROM
Through the block-based Flash simulation EEPROM data storage method, the problems of large SRAM space occupancy, long data update time and uncontrollable page change time in the prior art are solved, efficient data storage and update are realized, SRAM space is saved, and the requirements of different functional safety levels are supported.
Patent Information
- Application Number
- CN202411796828.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-04-01
AI Technical Summary
In the prior art, the data storage method of Flash simulates EEPROM has problems such as large SRAM space occupancy, long data update time, and uncontrollable page change time.
The data storage method of block-based Flash simulates EEPROM is adopted. By initializing multiple storage space sets within Flash, each storage space set includes multiple storage spaces, and the status of each storage space is determined. When the size of the written data is not greater than the remaining space of the storage space in the currently activated state, the data is written to the current storage space; when the data size exceeds the remaining space, the storage space exchange mechanism is triggered, and the next storage space is found and the valid block data is copied into the newly formatted storage space.
This method only configures the corresponding SRAM data structures for blocks, saves a lot of SRAM space, improves the performance of block data reading operations, supports users to customize the configuration of storage space sets, meets the needs of different functional security levels, and realizes data secure access and data isolation.
Smart Images

Figure CN119739331A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a data storage method and system for Flash emulating EEPROM based on blocks. Background Art
[0002] In the field of automotive electronics, a large amount of non-volatile data needs to be saved in real time or when power is off. This data needs to be able to be restored and ensured to be accurate when the power is on next time. With the electrification and intelligent development of new energy vehicles, non-volatile data is gradually becoming more and more diverse. Some data are updated very frequently, while some data are updated very infrequently. Therefore, how to safely and efficiently save and restore non-volatile data becomes particularly important.
[0003] Flash is a common non-volatile memory (NvM) used to store non-volatile data in embedded systems. When rewriting non-volatile data in Flash, it is necessary to first perform an erase operation and then program the data. The erase operation is very time-consuming and needs to be erased in blocks, which makes it impossible to simply update a small amount of data; and the number of erase and write times of Flash is limited by its physical properties, generally 100,000 times. If a static random access memory (SRAM) is combined to implement the update of a small amount of data, this will accelerate the Flash to reach its physical erase and write limit, and it is difficult to meet the current automotive electronics field The requirement for non-volatile data to be updated millions of times.
[0004] Electrically Erasable Programmable Read Only Memory (EEPROM) is a common non-volatile memory. EEPROM can be read and written byte by byte, and updating data does not require erasing in advance. Compared with Flash, EEPROM is more flexible in operation, but the disadvantage of EEPROM is that the storage capacity is small and the cost is higher. Most MCUs only support on-chip Flash. In order to meet the increasing demand for cost reduction and efficiency improvement without adding additional hardware costs, some data storage methods based on Flash emulation EEPROM have emerged, but the existing methods have some problems.
[0005] Patent CN117742588A discloses a data storage method and system using Flash to simulate EEPROM. The method pre-divides two storage spaces, manages the activation status of the two storage spaces, alternately writes data in a specific format to the two storage data areas, and only records the first address of the data header during initialization, thereby solving the problem of low Flash utilization and large occupation of SRAM in the current Flash simulation EEPROM method. However, when the two storage spaces are allocated too large, when one of them is full and needs to be paged, it is very time-consuming to erase the other one, and it is impossible to flexibly configure the total time consumed for erasing.
[0006] Patent CN114756179A discloses a data writing, reading and management method based on simulated EEPROM. When the first storage group is full, the latest valid data in the first storage group needs to be backed up to the second storage group, and then the first storage group is erased. When the second storage group is full, the latest valid data in the second storage group is backed up to the first storage group. The above operations are performed repeatedly, but it takes a long time to find the latest valid data, and it takes a lot of time to back up a large amount of data. If an abnormal situation such as power failure occurs during the backup process, it needs to be backed up again.
[0007] Patent CN116795297A discloses a storage device, storage method and apparatus, which adopts a method of storing small data blocks multiple times in a large data block. When the large data block is full, the small data block to be written is first written using the backup block, and then the full large data block is erased, and then the small data block to be written is written to the large data block after the erasure, and the backup block is erased. This method needs to allocate a sufficiently large SRAM space to simulate EEPROM. The larger the EEPROM to be simulated, the larger the SRAM space required. The occupied SRAM space is too large, which is too restrictive for systems with scarce on-chip resources. And for systems with large data volumes, writing data in a non-aligned manner requires three steps of reading, modifying and writing, and the data update process is cumbersome and time-consuming.
[0008] Therefore, there is an urgent need for a storage method to solve the problems of large SRAM space occupation, time-consuming data update, and uncontrollable page change time. Summary of the invention
[0009] In view of some or all of the problems in the prior art, the present invention provides a data storage method of Flash emulating EEPROM based on blocks, the method comprising:
[0010] Initializing a plurality of storage space sets pre-configured in the Flash, each of the storage space sets including a plurality of storage spaces, and determining a state of each of the storage spaces;
[0011] Searching for a storage space in an activated state with the highest priority among the plurality of storage spaces, searching for data address information of all the latest blocks in a valid state in the storage space, performing verification and checking on the management information of each block, and storing information such as the address of the valid block that passes the check into a data structure of an SRAM corresponding to the block;
[0012] When the size of the written data is not larger than the remaining space of the currently activated storage space, the written data is written to the currently activated storage space; when the size of the written data is larger than the remaining space of the currently activated storage space, the storage space exchange mechanism is triggered, and the mechanism finds out the next storage space of the currently activated storage space set and formats it, and copies the valid block data from the currently activated storage space to the formatted storage space. For block data with the same block number, only the latest block data is copied, and the formatted storage space is activated as the storage space in the current storage space set with the highest priority activation state; a new write operation is performed in the activated storage space, and after the write operation is completed, the data address information of the block is synchronously updated to the corresponding SRAM data structure; and the read operation is performed using the data address information of the block recorded in the SRAM data structure.
[0013] Furthermore, before initialization, it also includes: dividing the Flash structure into multiple storage space sets, the sizes of the multiple storage space sets are the same or different, and each of the storage space sets does not affect each other; each of the storage space sets includes at least two storage spaces.
[0014] Furthermore, each of the storage spaces includes cluster management information, block management information and a block data area; the cluster management information is used to store management information of the storage space, the block management information is used to store management information of the block, and the block data area is used to store block data.
[0015] Furthermore, the initialization also includes:
[0016] Traversing the cluster management information and block management information of each storage space in the storage space set, and updating the corresponding SRAM data structure;
[0017] If each storage space in the storage space set is not activated, the storage space erase operation is performed and the storage space is formatted to create a new activated storage space; if there is an activated storage space in the storage space set, the block data retrieval and recovery process is executed to determine whether the block exists through the blank checkpoint in the block management information.
[0018] Furthermore, during the write operation, the data to be written is divided into block data and block management information, the block management information of the block data is written, the write operation of the block data is executed, the block validity is updated, the SRAM data structure of the block is updated, and the SRAM data structure of the block records the block validity and the actual storage address of the block data.
[0019] Furthermore, the block data area includes multiple block data; the address movement direction of the block management information is from low address to high address, and the address movement direction of the block data is from high address to low address. The distance between the block management information and the block data is used to determine whether the remaining space of the current storage space is sufficient to write new block data to be written. When the remaining space is insufficient, the storage space exchange mechanism is triggered.
[0020] Furthermore, the storage space exchange mechanism is applicable to the storage space exchange of the same storage space set without affecting other storage space sets. The storage space exchange mechanism includes:
[0021] All storage spaces are distributed in a ring structure, and the next storage space of the currently activated storage space set is searched and formatted;
[0022] Copy all valid block data from the currently activated storage space to the formatted storage space. For block data with the same block number, only copy the latest block data.
[0023] Update the formatted storage space to the storage space in the current storage space set in a highly activated state;
[0024] Return to the beginning of the write operation to restart the write operation, and check whether the remaining space of the storage space in the highly activated state meets the size required by the written block data.
[0025] The present invention also provides a data storage system of Flash emulating EEPROM based on blocks, the system comprising:
[0026] An initialization module is configured to initialize a plurality of storage space sets pre-configured in the Flash, each of the storage space sets including a plurality of storage spaces, and determine a state of each of the storage spaces;
[0027] A search module is configured to search for a storage space in an activated state with the highest priority among the plurality of storage spaces, search for data address information of all the latest blocks in a valid state in the storage space, perform verification and check on the management information of each block, and store information such as the address of the valid block that passes the check into a data structure of the SRAM corresponding to the block;
[0028] The read-write module is configured to write the written data into the storage space in the current activated state when the size of the written data is not larger than the remaining space of the storage space in the current activated state; trigger the storage space exchange mechanism when the size of the written data is larger than the remaining space of the storage space in the current activated state, the mechanism finds out the next storage space of the storage space set in the current activated state and formats it, copies the valid block data from the storage space in the current activated state to the formatted storage space, and for the block data with the same block number, only copies the latest block data, activates the formatted storage space as the storage space in the current storage space set with the highest priority in the activation state; performs a new write operation in the storage space in the activated state, and after the write operation is completed, synchronously updates the data address information of the block to the corresponding SRAM data structure; and performs a read operation using the data address information of the block recorded in the SRAM data structure.
[0029] The present invention also provides a computer system, comprising:
[0030] a processor configured to execute machine-readable instructions;
[0031] A graphics card with an artificial intelligence chip configured to train the block-based Flash emulation EEPROM data storage method; and
[0032] The memory is configured to store machine-readable instructions, which, when executed by a processor and / or a graphics card, perform the steps of the data storage method of block-based Flash emulation EEPROM.
[0033] The present invention also provides a computer-readable storage medium on which machine-readable instructions are stored. When the machine-readable instructions are executed by a processor, the steps of the data storage method of the block-based Flash emulation EEPROM are executed.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] 1. The data storage method of Flash emulating EEPROM based on blocks provided by the present invention only configures the corresponding SRAM data structure for the block to store its actual data address, instead of opening up an SRAM space of the same size as the EEPROM, and synchronously updates and stores the actual storage address of the block, thereby improving the performance of the block data read operation and saving a large amount of SRAM space.
[0036] 2. The block-based Flash emulation EEPROM data storage method provided by the present invention supports user-defined configuration of multiple storage space sets. The block data in each storage space set do not affect each other and are independent of each other. It can meet the requirements of different functional safety levels for data management and realize the functions of data security access and data isolation.
[0037] 3. The block-based Flash emulation EEPROM data storage method provided by the present invention supports users to flexibly configure the size of each storage space based on different application requirements. Different storage space sizes determine the duration of storage space exchange (page change) under critical conditions, which can meet the requirements of different application scenarios for the maximum page change time. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] To further illustrate the above and other advantages and features of various embodiments of the present invention, a more specific description of various embodiments of the present invention will be presented with reference to the accompanying drawings. It will be understood that these drawings only depict typical embodiments of the present invention and are therefore not to be considered as limiting the scope thereof. In the accompanying drawings, for clarity, identical or corresponding parts will be represented by identical or similar reference numerals.
[0039] Figure 1 A schematic flow chart of a data storage method of a Flash block-based EEPROM simulation according to an embodiment of the present invention;
[0040] Figure 2 A schematic diagram of dividing a Flash structure into storage space sets according to an embodiment of the present invention;
[0041] Figure 3 A schematic diagram of management information of a storage space according to an embodiment of the present invention;
[0042] Figure 4 A schematic diagram of block management information according to an embodiment of the present invention;
[0043] Figure 5 A schematic diagram of a write operation flow according to an embodiment of the present invention;
[0044] Figure 6 A schematic diagram of data distribution status in a storage space after multiple writing of the same and different block data according to an embodiment of the present invention;
[0045] Figure 7 A schematic diagram of the execution flow of a storage space exchange mechanism according to an embodiment of the present invention;
[0046] Figure 8 A schematic diagram of the effect of implementing a storage space exchange mechanism according to an embodiment of the present invention;
[0047] Fig. 9A schematic diagram of a read operation flow of an embodiment of the present invention;
[0048] Fig.10 A schematic diagram of a recovery process of a storage space set according to an embodiment of the present invention; and
[0049] Fig.11 The diagram is a block-based Flash EEPROM emulation data storage system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In the following description, the present invention is described with reference to various embodiments. However, those skilled in the art will recognize that various embodiments may be implemented without one or more specific details or with other replacement and / or additional methods or components. In other cases, well-known structures or operations are not shown or described in detail to avoid obscuring the inventive point of the present invention. Similarly, for the purpose of explanation, specific numbers and configurations are set forth to provide a comprehensive understanding of embodiments of the present invention. However, the present invention is not limited to these specific details.
[0051] In this specification, reference to "one embodiment" or "the embodiment" means that a particular feature, structure, or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present invention. The phrase "in one embodiment" appearing in various places in this specification does not necessarily all refer to the same embodiment.
[0052] It should be noted that the embodiments of the present invention describe the method steps in a specific order, but this is only for the purpose of illustrating the specific embodiment, rather than limiting the order of the steps. On the contrary, in different embodiments of the present invention, the order of the steps can be adjusted according to actual needs.
[0053] In the present invention, each module of the system according to the present invention can be implemented using software, hardware, firmware or a combination thereof. When the module is implemented using software, the function of the module can be implemented by a computer program flow, for example, the module can be implemented by a code segment (such as a code segment of a language such as C, C++) stored in a storage device (such as a hard disk, a memory, etc.), wherein the corresponding function of the module can be implemented when the code segment is executed by a processor. When the module is implemented using hardware, the function of the module can be implemented by setting a corresponding hardware structure, for example, the function of the module can be implemented by hardware programming a programmable device such as a field programmable gate array (FPGA), or the function of the module can be implemented by designing an application-specific integrated circuit (ASIC) including electronic devices such as a plurality of transistors, resistors and capacitors. When the module is implemented using firmware, the function of the module can be written into a read-only memory such as an EPROM or EEPROM of the device in the form of a program code, and the corresponding function of the module can be implemented when the program code is executed by a processor. In addition, certain functions of the module may need to be implemented by separate hardware or by collaboration with the hardware, for example, the detection function is implemented by corresponding sensors (such as proximity sensors, acceleration sensors, gyroscopes, etc.), the signal transmission function is implemented by corresponding communication devices (such as Bluetooth devices, infrared communication devices, baseband communication devices, Wi-Fi communication devices, etc.), the output function is implemented by corresponding output devices (such as displays, speakers, etc.), and so on.
[0054] In order to solve the problems of large SRAM space occupation, time-consuming data update, and uncontrollable page change time, the present invention provides a block-based Flash emulation EPPROM data storage method and system, which can control the overall time consumption of page change according to the application scenario configuration, and at the same time realize data isolation and access control of block blocks, which can meet the requirements of different functional safety levels.
[0055] The technical solutions in the embodiments of the present invention are described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0056] like Figure 1 As shown, the data storage method of the block-based Flash emulation EEPROM is as follows.
[0057] First, a plurality of storage space sets pre-configured in the Flash are initialized, each of the storage space sets includes a plurality of storage spaces, and the state of each of the storage spaces is determined.
[0058] Before initialization, follow Figure 2 The Flash structure is divided into multiple storage space sets. Figure 2A0 and An represent the 0th and nth storage spaces in the 1st storage space set, B0 and Bn represent the 0th and nth storage spaces in the nth storage space set, and n is an integer not less than 2. The storage space is a cluster. And the size of each storage space is a multiple of Flash Sector, which can be configured arbitrarily but is subject to the total size of Flash. Figure 2 The storage space sets and storage spaces shown in are both n, and the number of storage space sets and storage spaces may be different. The number of storage space sets is an integer not less than 1, and each storage space set includes at least two storage spaces. Each storage space includes cluster management information, block management information, and a block data area.
[0059] In one embodiment of the present invention, the size of each storage space set is configurable, and can be configured to be the same size or different sizes based on user needs. It also supports the expansion of the NOR Flash outside the MCU to achieve a larger storage space, and each storage space set is independent of each other and does not affect each other. The block data in each storage space set do not affect each other and are independent of each other, and can meet the needs of different functional safety levels for data management. This part realizes the function of data security access and data isolation. In addition, the Flash memory does not need to be fully configured for use. If the amount of data to be stored by the user is small, part of the flash memory can be saved for other uses without affecting each other.
[0060] Users can flexibly configure the size of each storage space based on different application requirements. If the user data is small, only part of the flash memory needs to be configured, and the remaining part can be used for other purposes. If the amount of user data is large and the internal flash memory of the MCU is not enough, it can also be expanded through external NOR Flash. Each storage space set and storage space can also be large or small, completely based on user needs. Different storage space sizes determine the duration of storage space exchange under critical conditions, which can meet the requirements of maximum page exchange time in different application scenarios. For example, user data a / b / c is stored in storage space set 1, and its update frequency is 10000; user data d / e / f is stored in storage space set 2, and its update frequency is 10. The block-based Flash emulation EEPROM data storage method provided by the invention manages these 6 groups of data a / b / c / d / e / f. There is no difference at the user level, and there is no need to worry about where the specific data is stored. However, due to the high update frequency of a / b / c, the probability of page switching is also high. The page switching operation is much more time-consuming than conventional read and write operations, which can easily affect the user's maximum tolerable time. This method will manage a / b / c and d / e / f separately according to different storage space sets. The page switching operation in any storage space set will not affect the data storage in another storage space set, and the time spent on copying valid data during the page switching process is saved.
[0061] For each storage space, multiple storage spaces are configured based on demand, so that the consumption time of storage space exchange can be flexibly modified. In the initialization operation, the multiple configured storage spaces are initialized, that is, the management information of the storage space is initialized. The management information is used to find the activated storage space with the highest priority when restoring data at power-on. The management information of the storage space is as follows: Figure 3 As shown. During initialization, the pre-configured storage space set is initialized, and the storage space with the smallest storage space number in the storage space set is selected for formatting. The formatting operation erases all Flash Sectors in the storage space according to the size of the storage space; after the erasing operation is completed, the programming of the storage space management information is started, including the storage space number (cluster number), storage space activation status (cluster activation status), storage space size (cluster size status) and storage space information checksum (cluster information checksum), and finally the storage space is set to be valid (cluster valid).
[0062] In the data storage method of Flash emulating EEPROM based on blocks provided by the present invention, all non-volatile data are divided and managed according to blocks, that is, each block can be configured into data blocks of the size required by the user. For the management of blocks, the following are designed: Figure 4Block management information. Each block is managed based on this management information, and a corresponding data structure in SRAM is allocated to each block to store real-time information of the data address. During a read operation, the block data can be directly read based on the real-time address information without any additional query process for where the latest data is located, thereby improving the performance of the read operation.
[0063] Next, search for the storage space in the activation state with the highest priority among the multiple storage spaces, search for the data address information of all the latest blocks in the valid state in the storage space, verify and check the management information of each block, and store the address and other information of the valid blocks that pass the check in the data structure of the SRAM corresponding to the block.
[0064] Finally, when the size of the written data is not larger than the remaining space of the currently activated storage space, the written data is written to the currently activated storage space; when the size of the written data is larger than the remaining space of the currently activated storage space, the storage space exchange mechanism is triggered. This mechanism finds out the next storage space of the currently activated storage space set and formats it, copies the valid block data from the currently activated storage space to the formatted storage space, and for block data with the same block number, only copies the latest block data, activates the formatted storage space as the storage space in the current storage space set with the highest priority activation state; performs a new write operation in the activated storage space, and after the write operation is completed, synchronously updates the block data address information to the corresponding SRAM data structure; uses the block data address information recorded in the SRAM data structure to perform a read operation.
[0065] During the write operation, the data to be written is divided into block data and block management information, the block management information of the block data is written, the write operation of the block data is performed, the block is updated to be valid, and the SRAM data structure is updated. The process is as follows Figure 5 shown.
[0066] Figure 6 FIG. 1 is a schematic diagram of data distribution in a storage space after multiple writing of the same and different block data according to an embodiment of the present invention. Figure 6 As shown, the block data area includes multiple block data; the address movement direction of the block management information is from low address to high address, and the address movement direction of the block data is from high address to low address. The distance between the block management information and the block data is used to determine whether the remaining space of the current storage space is sufficient to write the written data. When the remaining space is insufficient, the storage space exchange mechanism is triggered. It supports aligned access and unaligned access of address or data size. Multiple data updates do not require the data reading, modifying, and writing process, which improves the overall performance of data updates.
[0067] When the size of the remaining space of the currently activated storage space is larger than the size of the block data to be written, the write operation is directly executed to write to the Flash memory, and the data structure of the block in the corresponding SRAM is updated; when the size of the remaining space of the currently activated storage space is smaller than the size of the block data to be written, it cannot be written directly at this time, and the storage space exchange mechanism needs to be triggered. The main purpose of the storage space exchange mechanism is to achieve wear leveling of the Flash memory by exchanging space for the number of erases, reduce the number of erases of fixed Flash memory addresses, and extend the overall service life of the Flash memory; at the same time, the size of each storage space can be customized before initialization to adjust the total time consumed when the space exchange occurs, which can meet the needs of different application scenarios and is more flexible. When the storage space is exchanged, the valid block data belonging to the current storage space set is copied from the currently activated storage space, which will not affect other storage space sets, greatly reducing the time consumption when the storage space is exchanged, and the block storage space sets can be flexibly divided according to the update frequency of the block data for separate management.
[0068] The storage space exchange mechanism is applicable to the storage space exchange of the same storage space set. Figure 7 FIG. 1 is a schematic diagram of the execution flow of a storage space exchange mechanism according to an embodiment of the present invention. Figure 7 As shown, the execution process of the storage space exchange mechanism includes: distributing all storage spaces according to a ring structure, searching for and formatting the next storage space of the currently activated storage space set; copying all valid block data from the currently activated storage space to the formatted storage space, and for block data with the same block number, only copying the latest block data; updating the formatted storage space to the highly activated storage space in the current storage space set; finally, returning to the start of the write operation to restart the write operation, and checking whether the remaining space of the highly activated storage space meets the size required by the written block data.
[0069] The effects of the storage space exchange mechanism are as follows: Figure 8 As shown, three valid blocks are copied from the current full active storage space 0 (cluster 0) to the newly formatted storage space 1 (cluster 1) with a high activation priority. During the storage space exchange process, only the latest valid block data is exchanged, and the block belongs to the storage space set; access with a low access level cannot access block data in a storage space set with a high level, meeting the requirements of different functional safety levels for data access restrictions, similar to Figure 8 There are barriers with different levels of access permissions between different storage space sets in the . Figure 8In the example, the existence of multiple block 3 management information and block 3 data in cluster 0 indicates that block 3 has been updated three times. Each time the block management information and block data are updated, a new copy will be written as the latest information. During the power-off recovery phase, all the management information of the block will be traversed and indexed to find the latest one to restore the block management information and block data. When the storage space is exchanged, only the latest (i.e. the last updated block 3) block 3 data in cluster 0 will be copied to cluster 1, and any number of previous block 3 data and management information will be discarded.
[0070] The block-based Flash emulation EEPROM data storage method provided by the present invention divides and manages all non-volatile data according to blocks, and the actual data is read according to the block number when the read operation is executed. The read operation is limited to the blocks that have been written, and does not support the blocks that have not been written. Based on the execution process of the above write operation, it can be known that after the write operation is successful, the data structure of the SRAM corresponding to the block will be updated synchronously. The data address information of the actual block is recorded in the data structure. The data of the block can be directly read back using the address information, and there is no need to consume the query of the latest block position. The speed of the read operation is greatly improved. The read operation process is as follows: Fig. 9 shown.
[0071] The most critical part of the data storage method of Flash emulation EEPROM based on blocks provided by the present invention is the recovery of non-volatile data during the power-on process. The algorithm design needs to ensure that the non-volatile data can be accurately recovered. During power-on initialization, all configured storage space sets are traversed, and the storage space with the highest activation priority is found in each storage space set. The storage space stores the latest valid block information, so as to recover the block data. The recovery process for each storage space set is the same. Taking one of the storage space sets as an example, the recovery process is as follows: Fig.10 As shown. Traverse the cluster management information and block management information of each storage space in the storage space set, update the corresponding SRAM data structure, including the activation status number of the storage space (representing its priority, the larger the number, the newer the storage space); if each storage space in the storage space set is not activated, perform the storage space erase operation and format the storage space, create a new activated storage space, and wait for the next write operation; if there is an activated storage space in the storage space set, execute the block data retrieval and recovery process, and determine whether the block exists through the blank checkpoint in the block management information.
[0072] The data storage method of Flash emulating EEPROM based on blocks provided by the present invention only configures the SRAM data structure corresponding to the block to store its actual data address, instead of opening up an SRAM space of the same size as the EEPROM, and synchronously updates and stores the actual storage address of the block, thereby improving the performance of block read operation and saving a large amount of SRAM space at the same time; supports users to customize and configure multiple storage space sets, the block data in each storage space set do not affect each other and are independent of each other, can meet the requirements of different functional safety levels for data management, and realizes the functions of data security access and data isolation; supports users to flexibly configure the size of each storage space based on different application requirements, different storage space sizes determine the duration of storage space exchange under critical conditions, and can meet the requirements of different application scenarios for maximum page change time.
[0073] Fig.11 FIG. 1 is a schematic diagram of a data storage system based on a Flash block emulation EEPROM according to an embodiment of the present invention. Fig.11 As shown, the system includes:
[0074] An initialization module is configured to initialize a plurality of storage space sets pre-configured in the Flash, each of the storage space sets including a plurality of storage spaces, and determine a state of each of the storage spaces;
[0075] A search module is configured to search for a storage space in an activated state with the highest priority among the plurality of storage spaces, search for data address information of all the latest blocks in a valid state in the storage space, perform verification and check on the management information of each block, and store information such as the address of the valid block that passes the check into a data structure of the SRAM corresponding to the block;
[0076] The read-write module is configured to write the written data into the storage space in the current activated state when the size of the written data is not larger than the remaining space of the storage space in the current activated state; trigger the storage space exchange mechanism when the size of the written data is larger than the remaining space of the storage space in the current activated state, the mechanism finds out the next storage space of the storage space set in the current activated state and formats it, copies the valid block data from the storage space in the current activated state to the formatted storage space, and for the block data with the same block number, only copies the latest block data, activates the formatted storage space as the storage space in the current storage space set with the highest priority in the activation state; performs a new write operation in the storage space in the activated state, and after the write operation is completed, synchronously updates the data address information of the block to the corresponding SRAM data structure; and performs a read operation using the data address information of the block recorded in the SRAM data structure.
[0077] In one embodiment of the present invention, the present invention also provides a computer system, which includes a processor, a graphics card with an artificial intelligence chip, and a memory, the memory is configured to store machine-readable instructions, the graphics card is configured to train the data storage method of the block-based Flash emulation EEPROM, and the processor is configured to execute the machine-readable instructions. When the processor and / or the graphics card executes the machine-readable instructions, the following processing steps are implemented: initialize multiple storage space sets pre-configured in the Flash, each of the storage space sets includes multiple storage spaces, and determine the state of each of the storage spaces; search for the storage space in the highest priority activation state among the multiple storage space sets, search for the data address information of all the latest blocks in the valid state in the storage space, and perform verification and inspection on the management information of each block, and store the address information of the valid blocks that pass the inspection into the data structure of the SRAM corresponding to the block; when the size of the data to be written is not greater than the remaining space of the storage space in the currently activated state, write the data to be written into the storage space in the currently activated state; when the size of the data to be written is greater than When the remaining space of the storage space in the currently activated state is large, the storage space exchange mechanism is triggered. The mechanism finds out the next storage space of the storage space set in the currently activated state and formats it, and copies the valid block data from the storage space in the currently activated state to the formatted storage space. For block data with the same block number, only the latest block data is copied, and the formatted storage space is activated as the storage space in the current storage space set with the highest priority activation state; a new write operation is performed in the storage space in the activated state, and after the write operation is completed, the data address information of the block is synchronously updated to the corresponding SRAM data structure; and the read operation is performed using the data address information of the block recorded in the SRAM data structure.
[0078] The graphics card may preferably have a GPU computing power higher than 5.0. Since the amount of data to be trained is large, providing a graphics card configuration can significantly increase the training speed.
[0079] The memory includes: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store machine-readable instructions.
[0080] It can be understood that in addition to the memory and processor mentioned above, the above-mentioned computer system also includes other software and hardware components not listed in this specification. The specific components can be determined according to the model of specific data processing equipment in different application scenarios, and this specification will not list them one by one in detail.
[0081] In one embodiment of the present invention, the present invention further provides a computer-readable storage medium having machine-readable instructions stored thereon, wherein the machine-readable instructions implement the following processing steps when executed by a processor: initializing a plurality of storage space sets pre-configured in the Flash, each of the storage space sets including a plurality of storage spaces, and determining the state of each of the storage spaces; searching for a storage space in an activated state with the highest priority among the plurality of storage space sets, searching for data address information of all the latest blocks in a valid state in the storage space, performing verification and checking on the management information of each block, and storing the address information of the valid blocks that pass the check in the data structure of the SRAM corresponding to the block; when the size of the data to be written is not greater than the remaining space of the storage space in the currently activated state, writing the data to be written into the current storage space; storage space in the previously activated state; when the size of the written data is larger than the remaining space of the currently activated storage space, the storage space exchange mechanism is triggered, the mechanism finds out the next storage space of the currently activated storage space set and formats it, copies the valid block data from the currently activated storage space to the formatted storage space, and for block data with the same block number, only copies the latest block data, activates the formatted storage space as the storage space in the current storage space set with the highest priority activation state; performs a new write operation in the activated storage space, and after the write operation is completed, synchronously updates the data address information of the block to the corresponding SRAM data structure; uses the data address information of the block recorded in the SRAM data structure to perform a read operation.
[0082] The readable storage medium includes: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store machine-readable instructions.
[0083] Although various embodiments of the present invention are described above, it should be understood that they are presented as examples only and not as limitations. It is obvious to those skilled in the relevant art that various combinations, modifications and changes can be made thereto without departing from the spirit and scope of the present invention. Therefore, the breadth and scope of the present invention disclosed herein should not be limited by the exemplary embodiments disclosed above, but should only be defined according to the attached claims and their equivalents.
Claims
1. A data storage method based on block-based Flash emulation EEPROM, characterized in that: include: Initializing a plurality of storage space sets pre-configured in the Flash, each of the storage space sets including a plurality of storage spaces, and determining a state of each of the storage spaces; Searching for a storage space in an activated state with the highest priority among the plurality of storage spaces, searching for data address information of all the latest blocks in a valid state in the storage space, performing verification and checking on the management information of each block, and storing the address information of the valid blocks that pass the check into a data structure of an SRAM corresponding to the block; When the size of the data to be written is not larger than the remaining space of the storage space in the currently activated state, the data to be written is written into the storage space in the currently activated state; When the size of the written data is larger than the remaining space of the currently activated storage space, the storage space exchange mechanism is triggered. The mechanism finds out the next storage space of the currently activated storage space set and formats it, and copies the valid block data from the currently activated storage space to the formatted storage space. For block data with the same block number, only the latest block data is copied, and the formatted storage space is activated as the storage space in the current storage space set with the highest priority activation state; a new write operation is performed in the activated storage space, and after the write operation is completed, the data address information of the block is synchronously updated to the corresponding SRAM data structure; and the read operation is performed using the data address information of the block recorded in the SRAM data structure.
2. The data storage method of Flash emulating EEPROM based on blocks according to claim 1, characterized in that: Before initialization, the method further includes: dividing the Flash structure into a plurality of storage space sets, the sizes of the plurality of storage space sets being the same or different, and each of the storage space sets not affecting each other; and each of the storage space sets including at least two storage spaces.
3. The data storage method of Flash emulating EEPROM based on blocks according to claim 2, characterized in that: Each of the storage spaces includes cluster management information, block management information and a block data area; the cluster management information is used to store management information of the storage space, the block management information is used to store management information of the block, and the block data area is used to store block data.
4. The data storage method of Flash emulating EEPROM based on blocks according to claim 1, characterized in that: Initialization also includes: Traversing the cluster management information and block management information of each storage space in the storage space set, and updating the corresponding SRAM data structure; If each storage space in the storage space set is not activated, the storage space erase operation is performed and the storage space is formatted to create a new activated storage space; if there is an activated storage space in the storage space set, the block data retrieval and recovery process is executed to determine whether the block exists through the blank checkpoint in the block management information.
5. The data storage method of Flash emulating EEPROM based on blocks according to claim 1, characterized in that: During a write operation, the data to be written is divided into block data and block management information, the block management information of the block data is written, the write operation of the block data is performed, the block validity is updated, the SRAM data structure of the block is updated, and the SRAM data structure of the block records the block validity and the actual storage address of the block data.
6. The data storage method of Flash emulating EEPROM based on blocks according to claim 3, characterized in that: The block data area includes multiple block data; the address movement direction of the block management information is from low address to high address, and the address movement direction of the block data is from high address to low address. The distance between the block management information and the block data is used to determine whether the remaining space of the current storage space is sufficient to write new block data to be written. When the remaining space is insufficient, the storage space exchange mechanism is triggered.
7. The data storage method of Flash emulating EEPROM based on blocks according to claim 1, characterized in that: The storage space exchange mechanism is applicable to the storage space exchange of the same storage space set and does not affect other storage space sets. The storage space exchange mechanism includes: All storage spaces are distributed in a ring structure, and the next storage space of the currently activated storage space set is searched and formatted; Copy all valid block data from the currently activated storage space to the formatted storage space. For block data with the same block number, only copy the latest block data. Update the formatted storage space to the storage space in the current storage space set in a highly activated state; Return to the beginning of the write operation to restart the write operation, and check whether the remaining space of the storage space in the highly activated state meets the size required by the written block data.
8. A data storage system based on block-based Flash emulation EEPROM, characterized in that: include: An initialization module is configured to initialize a plurality of storage space sets pre-configured in the Flash, each of the storage space sets including a plurality of storage spaces, and determine a state of each of the storage spaces; A search module is configured to search for a storage space in an activated state with the highest priority among the plurality of storage spaces, search for data address information of all the latest blocks in a valid state in the storage space, perform a checksum check on the management information of each block, and store the address information of the valid block that passes the check into a data structure of the SRAM corresponding to the block; The read / write module is configured to write the data to be written into the storage space in the currently activated state when the size of the data to be written is not larger than the remaining space of the storage space in the currently activated state; When the size of the written data is larger than the remaining space of the currently activated storage space, the storage space exchange mechanism is triggered. The mechanism finds out the next storage space of the currently activated storage space set and formats it, and copies the valid block data from the currently activated storage space to the formatted storage space. For block data with the same block number, only the latest block data is copied, and the formatted storage space is activated as the storage space in the current storage space set with the highest priority activation state; a new write operation is performed in the activated storage space, and after the write operation is completed, the data address information of the block is synchronously updated to the corresponding SRAM data structure; and the read operation is performed using the data address information of the block recorded in the SRAM data structure.
9. A computer system, characterized in that: include: a processor configured to execute machine-readable instructions; A graphics card with an artificial intelligence chip configured to train a block-based Flash emulation EEPROM data storage method; and A memory configured to store machine-readable instructions, wherein the machine-readable instructions, when executed by a processor and / or a graphics card, perform the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Machine-readable instructions are stored thereon, and when the machine-readable instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are performed.
Citation Information
Cited By
Data reading and writing method and device, equipment and medium
CN120508261A
Method and device for simulating memory
CN121148452A