Page changing method and system for simulating EEPROM
By pre-configuring the maximum page swapping time value and erasing the next cluster in stages, the problem of balancing page swapping time and the amount of stored information in FLASH simulating EEPROM is solved, realizing fast page swapping and data recycling, thus meeting user needs.
Patent Information
- Application Number
- CN202410612707.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-16
- Publication Date
- 2025-11-18
AI Technical Summary
When using FLASH to simulate EEPROM, existing technologies cannot effectively balance page switching time and the amount of stored information, causing users to need to reduce the amount of block information that a cluster can store, which brings unnecessary trouble to secondary development.
By pre-configuring the maximum page swapping time, the number of pages that can be erased at one time is calculated based on the FLASH single-page erase time, and the next cluster is erased in stages, generating interrupt status information, allowing other operations to be performed during the erasure process, until the entire cluster is erased and new data is written, thus realizing the cyclic use of clusters.
This achieves the goal of meeting page switching time requirements without affecting the amount of stored data, avoiding prolonged resource occupation that could impact other operations, and ensuring that the FLASH has sufficient space to write new data.
Smart Images

Figure CN120973290A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage, in particular to a page replacement method and system for simulating EEPROM. BACKGROUND
[0002] EEPROM (Electrically Erasable Programmable ROM) is a kind of non-volatile memory, and is also a kind of user-modifiable read-only memory (ROM), which can be erased and reprogrammed (rewritten) by a voltage higher than the normal voltage. EEPROM can be modified directly without erasing before writing, and can modify a single byte, so EEPROM generally stores some easily changed data, and therefore EEPROM is used to store non-volatile data that needs to be saved in many product scenarios.
[0003] However, at present, mainstream microprocessors (such as MCU, etc.) have a large FLASH space, and do not have EEPROM, because if an EEPROM device is additionally added, the cost of the product will be significantly increased. Therefore, many applications will use FLASH to simulate the general functions and standard requirements of EEPROM to achieve the purpose of saving data during system operation, so as to meet the product requirements. FLASH is also a kind of non-volatile memory, which also has the performance of electronic erasable programmable, and the data of the memory will not be lost due to power failure. Each time the data in FLASH is modified, it needs to be erased and then written. The erasing of FLASH includes block erasing and chip erasing. Block erasing is to erase the contents of a certain erasing block, and chip erasing is to erase the contents of the entire FLASH, and the erasing area is large.
[0004] When FLASH is used to simulate EEPROM, the developer will usually design different storage data structures of the storage block Block according to the standard requirements, and further use the cluster Cluster (i.e. a set of multiple Blocks corresponding to EEPROM) of FLASH to manage the storage block Block. Although this method facilitates the management of the storage block Block, it also brings the demand for page replacement of the cluster Cluster. Specifically, the user writes data into the cluster Cluster of FLASH in sequence in units of storage blocks Block, and when a cluster Cluster does not have enough space to save the Block information that needs to be written, the next cluster Cluster of FLASH needs to be switched through page replacement processing.
[0005] When developers use FLASH to simulate EEPROM, they inevitably need to consider the trade-off between page swapping time and the amount of block information that a cluster can store. Current technologies typically address this by allowing users to configure the size and number of storage blocks, as well as the size and number of clusters. However, when users have strict requirements for page swapping time, this approach actually forces them to reduce the amount of block information that a cluster can store, creating unnecessary complications for secondary development. Summary of the Invention
[0006] The purpose of this invention is to provide a page switching method and system that simulates EEPROM, which can accurately measure page switching time to meet the user's requirements for page switching time, without affecting the amount of information the user needs to store, and avoids unnecessary trouble for the user's secondary development.
[0007] To achieve the above objectives, the present invention provides a page-switching method for a simulated EEPROM. The simulated EEPROM is implemented based on a dedicated storage area of FLASH memory. This dedicated storage area is divided into at least two clusters of equal capacity. Each cluster consists of multiple FLASH pages and is used to store data from multiple storage blocks of the simulated EEPROM. The page-switching method includes:
[0008] A maximum page-over time value is pre-configured to determine the number of FLASH pages that can be erased at one time, based on the maximum page-over time value and the FLASH single-page erase time.
[0009] If it is determined that a page-over operation needs to be triggered to switch to the next cluster, the next cluster is erased in stages according to the number of FLASH pages that can be erased at one time, until the entire next cluster is erased. Then, the new data that triggered the page-over operation is written into the erased next cluster.
[0010] In the process of erasing the next cluster in stages according to the number of erasable FLASH pages, a first operation status information that allows erasure interruption is generated after each erasure is completed. Then, as needed, after the corresponding erasure is completed, the simulated EEPROM enters an erasure interrupt, and performs other operations other than page switching on the simulated EEPROM. After the other operations are completed, the next erasure is performed on the next cluster again according to the first operation status information generated when the corresponding erasure is completed. This process is repeated until the entire next cluster is erased.
[0011] Optionally, when writing the new data into the analog EEPROM, it is determined whether the storage space of the current cluster is sufficient; if the storage space of the current cluster is sufficient, the new data is directly written into the current cluster; if the storage space of the current cluster is not sufficient, the page replacement operation is triggered.
[0012] Optionally, the data structure of each cluster comprises cluster header, cluster valid flag, block header and block data.
[0013] Optionally, the capacity of each cluster is at least a basic capacity, which is just enough to completely save the cluster header and cluster valid flag of the cluster and the data and block header of all blocks of the analog EEPROM at one time; after the erasing of the entire next cluster is completed, the new data is written into the next cluster through a data recycling operation and all valid data in the current cluster is moved to the next cluster, and after the moving is completed, the current cluster is set to be invalid, so as to realize the recycling of all clusters.
[0014] Optionally, assuming that the current cluster is Cluster n and the next cluster is Cluster n+1 and is invalid, after the erasing of the entire next cluster is completed, the steps of the data recycling operation comprise:
[0015] reading the cluster header of Cluster n to obtain the Cluster ID value of Cluster n, and updating the Cluster ID value of Cluster n+1 according to the Cluster ID value of Cluster n;
[0016] reading the block header in Cluster n in address order to obtain a block address mapping table (Blockindex);
[0017] reading and writing the data and block header in the valid blocks in Cluster n except the block address triggering the data recycling operation into Cluster n+1 according to the block address mapping table, wherein the block address triggering the data recycling operation corresponds to the block address needing to write the new data, and after the moving is completed, Cluster n is set to be invalid by writing the cluster valid flag of Cluster n;
[0018] writing the new data and the corresponding block header into Cluster n+1;
[0019] updating the cluster head information of the Cluster n+1 and writing the cluster valid flag of the Cluster n+1 to set the Cluster n+1 as valid;
[0020] reading the storage block head information of the Cluster n+1 to update the storage block address mapping table.
[0021] Optionally, the capacity of each cluster is at least a basic capacity, the basic capacity being at least one minimum erasing unit, which can store at least the cluster head information, the cluster valid flag, and the data and the storage block head information of a maximum storage block of the simulated EEPROM; after completing the erasing of the entire next cluster, the new data is written into the next cluster through a data recycling operation and all valid data in the further next cluster is moved to the next cluster, and after the moving is completed, the further next cluster is set as invalid.
[0022] Optionally, assuming that the current cluster is Cluster n, and the next cluster is Cluster n+1 and is invalid, after completing the erasing of the entire next cluster, the data recycling operation includes the following steps:
[0023] reading the cluster head information of the Cluster n to obtain the Cluster ID value of the Cluster n, and updating the Cluster ID value of the Cluster n+1 according to the Cluster ID value of the Cluster n;
[0024] reading the cluster head information of the Cluster n+2 to determine whether the Cluster n+2 is valid;
[0025] if the Cluster n+2 is valid, reading the storage block head information in the Cluster n+2 in address order to obtain the storage block address mapping table (Block index), and according to the storage block address mapping table, reading and writing the data and the storage block head information in the valid storage blocks in the Cluster n+2 except the storage block address triggering the data recycling operation into the Cluster n+1, wherein the storage block address triggering the data recycling operation corresponds to the storage block address in which the new data needs to be written, and after the moving is completed, setting the Cluster n+2 as invalid by writing the cluster valid flag of the Cluster n+2;
[0026] if the Cluster n+2 is invalid, no moving is needed for the data in the Cluster n+2;
[0027] writing the new data and the corresponding storage block head information into the Cluster n+1;
[0028] updating the cluster head information of the Cluster n+1 and writing the cluster valid flag of the Cluster n+1 to set the Cluster n+1 as valid;
[0029] reading the storage block head information of the Cluster n+1 to update the storage block address mapping table.
[0030] Optionally, when performing the write data operation in the data recycling operation, the corresponding to-be-written data is written in batches according to a one-time programmable word number or in units of the storage blocks of the simulated EEPROM, and the one-time programmable word number is obtained according to the maximum page switching time value and the single-word programming time of the FLASH.
[0031] Optionally, the length of each storage block of the simulated EEPROM is not fixed.
[0032] Optionally, the number of one-time erasable FLASH pages is obtained by taking an integer of a result of dividing the maximum page switching time value by the single-page erasing time of the FLASH; and / or, the one-time programmable word number is obtained by taking an integer of a result of dividing the maximum page switching time value by the single-word programming time of the FLASH.
[0033] Optionally, a second operation state information allowing a write interruption is generated after each write is completed, so as to make the simulated EEPROM enter a write interruption after the current write is completed according to needs, to perform other operations of the simulated EEPROM except the page switching operation, and continue the next write according to the corresponding second operation state information after the other operations are completed, and repeat the above operations until the writing of the to-be-written data is completed.
[0034] Based on the same inventive concept, the present application also provides a system having a FLASH, a configuration module and a function module, the FLASH has a special storage area for implementing a simulated EEPROM, the configuration module is used for configuring parameters of the simulated EEPROM, the parameters include a maximum page switching time value, and the function module performs the page switching method of the simulated EEPROM as described in the present application.
[0035] Optionally, the system further comprises a state machine and at least one application module; the state machine is configured to generate first operation state information and / or second operation state information during a page replacement process of the analog EEPROM, the first operation state information is used to indicate that erasing of a corresponding page of a corresponding cluster of the analog EEPROM in the page replacement process has been completed, and is further used as a basis for interrupting or continuing an erasing operation of the corresponding cluster in the page replacement process; the second operation state information is used to indicate that writing of a corresponding page of a corresponding cluster of the analog EEPROM in the page replacement process has been completed, and is further used as a basis for interrupting or continuing a writing data operation of the corresponding cluster in the page replacement process; the application module is configured to cause the analog EEPROM to enter an interrupt according to the first operation state information or the second operation state information, and to perform other operations in addition to the page replacement operation of the analog EEPROM.
[0036] Optionally, the analog EEPROM, the functional module and the application module all comply with the AUTOSAR standard, and the length of each of the storage blocks is not fixed.
[0037] Compared with the prior art, the technical scheme of the present application has at least one of the following beneficial effects:
[0038] 1. A maximum page replacement time is pre-configured, and the number of FLASH pages that can be erased at one time is obtained according to the maximum page replacement time value and the FLASH single-page erasing time, so that when it is determined to trigger a page replacement operation in an actual situation (for example, a situation in which new data needs to be written into the analog EEPROM but the remaining storage space of the current cluster is insufficient), the next cluster (i.e., an invalid cluster, in which all the data stored is invalid data) can be erased (i.e., the "erasing" of the page replacement operation) in multiple times according to the number of the FLASH pages that can be erased at one time, a first operation state information that allows erasing interruption (i.e., a kind of interruption of the page replacement operation) is generated every time an erasing is completed, and then the analog EEPROM can be caused to enter an erasing interruption (which is a kind of interruption of the page replacement operation of the analog EEPROM) to perform other operations in addition to the page replacement operation of the analog EEPROM according to actual needs after the corresponding erasing is completed, and the next erasing of the next cluster is continued according to the first operation state information generated when the corresponding erasing is completed after the other operations are performed, and the process is repeated until the erasing of the entire next cluster is completed (i.e., the "erasing" of the page replacement operation is completed), and then the new data that triggers the page replacement operation is written into the next cluster after the erasing (i.e., the "writing" of the page replacement operation is completed). This page replacement method can not only accurately determine the page replacement time of the analog EEPROM to meet the requirements of users on the page replacement time of the analog EEPROM, but also can meet the data amount requirement of the users, and will not force the users to reduce the amount of data to be stored.
[0039] 2、the erasing (even the writing of data) of the next cluster in the page replacement method is done in stages, allowing the simulated EEPROM to enter an interrupt (i.e. enter a page replacement operation interrupt), and allowing other operations of the simulated EEPROM other than the page replacement operation to be executed during the page replacement operation interrupt of the simulated EEPROM, so that the page replacement operation of the simulated EEPROM can be prevented from occupying resources for a long time and affecting the execution of these other operations (such as the communication operation between the application modules of the vehicle).
[0040] 3、the new data can be written into the next cluster by the data recycling operation, and the valid data in the current cluster or the next cluster can be read out and written into the erased next cluster, so that the next cluster or the next cluster can be set to be invalid by the data recycling operation, so that the page replacement operation can be directly erased for page replacement when triggered again, and thus all clusters of the simulated EEPROM can be recycled, ensuring that there is enough space in the FLASH to write new data without having to erase old data first, reducing the blocking time of the user accessing the simulated EEPROM. BRIEF DESCRIPTION OF DRAWINGS
[0041] Those skilled in the art will understand that the provided drawings are for better understanding of the present application, and do not constitute any limitation on the scope of the present application. Among them:
[0042] Figure 1 is a flowchart of the page replacement method of the simulated EEPROM of an embodiment of the present application.
[0043] Figure 2 is a data structure diagram of a cluster in the page replacement method of the simulated EEPROM of an embodiment of the present application.
[0044] Figure 3 is a flowchart of the simulated EEPROM in the page replacement method of the simulated EEPROM of an embodiment of the present application.
[0045] Figure 4 is a schematic diagram of the architecture of the system of an embodiment of the present application. DETAILED DESCRIPTION
[0046] In the following description, numerous specific details are set forth to provide a more thorough understanding of the present application. However, it will be apparent to one of skill in the art upon reading this disclosure that the present application can be practiced without one or more of these specific details. In other instances, well-known features have not been described in order to avoid obscuring the present application. It should be understood that the present application can be practiced with departure from these specific details, and that specific details can be implemented only in some embodiments. There are many
[0047] The technical solutions of the present application are further described in detail below in combination with the accompanying drawings and specific embodiments. The advantages and features of the present application will be more apparent according to the following description. It should be noted that the accompanying drawings are very simplified and use non-precise proportions, only for the purpose of facilitating and clearly assisting the description of the embodiments of the present application.
[0048] Please refer to Figure 1 An embodiment of the present application provides a page replacement method for simulating EEPROM, which is realized based on a special storage area of FLASH, the special storage area of FLASH is divided into at least two clusters with equal capacity, each cluster is composed of multiple FLASH pages and is used for storing data of multiple blocks of the simulated EEPROM. The page replacement method of the embodiment includes:
[0049] S11, a maximum page replacement time value is pre-configured, and the number of FLASH pages that can be erased at a time is obtained according to the maximum page replacement time value and the FLASH single page erase time;
[0050] S12, judging whether the page change operation needs to be triggered according to actual needs, if yes, triggering the page change operation to switch to the next cluster, for example, when new data is written into the analog EEPROM, judging whether the storage space of the current cluster is enough, if yes, the page change operation does not need to be triggered, and the new data is directly written into the current cluster, if not, triggering the page change operation to switch to the next cluster;
[0051] S13, if it is judged that the page change operation needs to be triggered, the next cluster is erased in several times according to the number of the pages of the one-time erasable FLASH (i.e. the "erase" of the page change operation, for example, the page change operation needs to be erased k times), and during the several-time erasing of the page change operation, a first operation state information allowing erasing interruption is generated after each time of erasing is completed, and then the following steps can be inserted: S21, according to actual needs, after the corresponding time of erasing (for example, the i-th time of erasing, 1≤i
[0052] S14, after the erasing of the whole next cluster (i.e. the "erase" of the page change operation) is completed, the new data triggering the page change operation is written into the next cluster after erasing (i.e. the "write" of the page change operation) by a data recycling operation or any suitable method.
[0053] It should be understood that the scheme of the embodiment is suitable for some chips such as MCU which has only FLASH but no EEPROM in physics, and it can use any suitable analog method in the art to use the special storage area (i.e. part of the storage space) of the FLASH to simulate the EEPROM, i.e. the initialization, reading, writing, setting invalid Block of the EEPROM, data recycling and other functional operations are actually converted into the initialization, reading, writing, setting invalid page (or sector) of the special storage area of the FLASH, data recycling and other functional operations, so that the special storage area of the FLASH is equivalent to an analog EEPROM, and the data structure of the analog EEPROM based on the special storage area of the FLASH depends on the analog method used, and the specific form of the data structure is not limited in the application, but it essentially needs to contain the following structure, as shown in Figure 2
[0054] (1) FLASH Page: the minimum erase unit of FLASH.
[0055] (2) Block: the basic unit of simulated EEPROM, the capacity of each Block can be set to any suitable size as needed (for example, the corresponding configuration engineering input is obtained according to the AUTOSAR specification), and the entire simulated EEPROM is composed of multiple Blocks with different lengths.
[0056] In some examples, data can be written to the simulated EEPROM in Block units, and a Block can be set as an invalid Block, and data at any position in a Block can be read in byte units.
[0057] (3) Cluster: the special storage area of FLASH (i.e., the storage space used to implement the simulated EEPROM) is divided into j (j≥2 and is an integer) Clusters with equal capacity; each Cluster is physically composed of multiple discontinuous FLASH pages, and is composed of multiple Blocks in the simulated EEPROM.
[0058] In some examples, the capacity of 1 Cluster is at least a basic capacity, the basic capacity is at least one minimum erase unit, the minimum erase unit can be the number of erasable FLASH pages Qpage in a page operation, and the basic capacity needs to be able to store Cluster header information ClusterHeader, cluster validity flag, and data Block data and Block header information BlockHeader of a maximum Block of the simulated EEPROM, so that each time new data is written to the simulated EEPROM, the new data can be written to the same Cluster together with some valid old data. In this case, only one Cluster can be allowed to be valid at a time.
[0059] In other examples, the capacity of 1 Cluster is less than the basic capacity, and each time new data is written to the simulated EEPROM, the new data can be written to several consecutive Clusters, in which case multiple Clusters need to be valid at the same time.
[0060] (4) Cluster header information ClusterHeader: contains Cluster ID (i.e., cluster identifier), which is used to save the programming index of the Cluster, to determine the switched Cluster in the page switching operation and the two Clusters involved in data transfer.
[0061] In some examples, please refer to Figure 2 , the Cluster ID value includes a first identifier value Cluster ID i and a second identifier value ~ (Cluster ID i) for verifying whether the first identifier value Cluster ID i is correct, the second identifier value can also be called the check code of the first identifier value, the first identifier value Cluster ID i of each Cluster is different, the value of the first identifier value Cluster ID i is increased by 1 after using a Cluster, thus, the Cluster with the largest first identifier value Cluster ID i represents the currently used Cluster. For example, if the dedicated storage area (i.e. the storage space for implementing the analog EEPROM) of the FLASH is divided into j (j≥2 and is an integer) Clusters with equal capacity, and Cluster n (0≤n≤j-1) is the currently used Cluster (referred to as "current Cluster" for short), the first identifier value Cluster ID n of Cluster n is the largest among the j Clusters.
[0062] In another example, the ClusterHeader can further include the start address (or offset address) and size (size) of the Cluster and the like information (not shown in Figure 2 ).
[0063] (5) Cluster valid flag: used to represent whether the Cluster is valid, which can be updated after performing the corresponding function operation of the analog EEPROM.
[0064] In some examples, please refer to Figure 2 , the value of the Cluster valid flag has a first flag value Cluster valid flag and a second flag value ~ (Cluster valid flag) for verifying whether the first flag value is correct, the first flag value and the second flag value can be complementary and written together, for example, when the first flag value is a hexadecimal number 0xAAAAAAAA, the second flag value is a hexadecimal number 0x55555555, the Cluster is valid, when the first flag value is 0x55555555, the second flag value is 0xAAAAAAAA, the Cluster is invalid, when the first flag value is 0xFFFFFFFF, the Cluster is empty.
[0065] (6) BlockHeader: includes a Block identifier Block index (also referred to as Block ID), which is used to save the programming index of the Block.
[0066] In some examples, please refer to Figure 2 , the Block index value includes a first value Block index i (e.g. Block index b~x) and a second value ~(Block index i) (e.g. ~(Block index b~x)) for verifying whether the first value Block index i is correct, which can also be referred to as the check code of the first value.
[0067] In some examples, please refer to Figure 2 , the BlockHeader further includes a starting address (or offset address) of the Block, Data address, which includes a third value Data address i (e.g. Data address b~x) and a fourth value ~(Data address i) (e.g. ~(Data address b~x)) for verifying whether the third value Data address i is correct, which can also be referred to as the check code of the third value, and the third value of each Block is different. Further, the third value can be set to a specified value (e.g. 0xFFFF) or a specified address (e.g. the address where two Block data are connected) in the address range of the BlockData corresponding to the third value to indicate that the Block is invalid, and vice versa, which means that the Block is valid, so that it is not necessary to add a space (or double byte, etc.) in the BlockHeader for each Block to indicate the validity of the Block, thereby saving storage space. In addition, if there are two Block index values that are the same and in the same Cluster, and the Blockdata is written from the last Cluster to the front, it means that the new and old data of the same Block are stored in the Cluster, and the Data address corresponding to the high address is valid, i.e. the data of the Block stored in the high address range is the latest.
[0068] In other examples, if the address offset between each BlockHeader and BlockData is fixed, the BlockHeader can not include the Data address, but the BlockHeader needs to include the Block valid flag or Block invalid flag Block valid flag (not shown in the figure) in addition. Figure 2Block validity flag or Block invalidity flag (in the BlockHeader, for example) is used to indicate whether the Block is valid or not, so that the new and old Block or valid or invalid data in the Block can be distinguished. The Block validity flag or Block invalidity flag can be updated after the corresponding function operation of the simulated EEPROM is performed.
[0069] In addition, in some other examples, the write data operation of the simulated EEPROM is actually simulated by writing the FLASH sector (FLS, sector), and the speed of writing the FLASH sector is slower. Considering that unexpected power failure may occur during the writing of the Block, after power-on, the Block data being written last time can be identified as invalid data, and the corresponding check code (not shown in the data structure) is also included in the BlockHeader to identify the data error caused by unexpected power failure. Figure 2
[0070] (7) Block data Blockdata: used to include the data written into the simulated EEPROM. In some examples, please refer to Figure 2 , the Blockdata can be written from the last Cluster to the front; in some other examples, the Blockdata can be written from the front to the back in the Cluster; in some other examples, the BlockHeader can be written in some specified space of the Cluster, and the BlockData can be written in another specified space, and the BlockHeader and the BlockData are written from the front to the back or from the back to the front, respectively; in some other examples, the BlockHeader of the Block is written immediately after the next address of the BlockData written from the back to the front in each Cluster, or the BlockHeader of the Block is written immediately after the next address of the BlockData written from the front to the back, and so on, without being limited to Figure 2 the data structure examples shown in the figure.
[0071] In addition, it is worth noting that in the present application, the erase operation of the simulated EEPROM occurs in the page replacement process, and the erase operation needs to be performed in the Cluster unit. The erase operation is essentially completed by triggering the multiple page erasure of the FLASH. The write data operation of the simulated EEPROM, which is written in the Block of the simulated EEPROM from the user's perspective, is essentially completed by triggering the multiple reading and multiple word programming of the FLASH.
[0072] In step S11, the maximum page change time value Tmaxmay be configured when the user first uses the system, and compared with the single page erase time Tpageof the FLASH (i.e. the time for erasing one physical page of the FLASH, which is an electrical characteristic value of the hardware FLASH). If the configured Tmax< Tpage, an error is reported, and the user needs to change Tmaxuntil Tmax / Tpage> 1, otherwise it is feasible, and the integral result of Tmax / Tpageis obtained, i.e. the number of pages Qpageof the FLASH that can be erased at a time is obtained. The Qpageis the minimum erase unit in the page change operation of the embodiment, and the minimum capacity mentioned in the embodiment is the capacity of one Qpage.
[0073] The configuration of the maximum page change time value Tmaxmay be implemented by any suitable manner as follows: (1) the user inputs the required maximum page change time value Tmaxthrough the corresponding system configuration item on the user interface, and the integral result of Tmax / Tpageis automatically calculated by the system program to obtain the number of pages Qpageof the FLASH that can be erased at a time, and then the corresponding Cluster can be erased in batches when writing new data into the simulated EEPROM; (2) the user configures the maximum page change time value Tmaxwith the help of the tool provided by the tool vendor, and further calculates the integral result of Tmax / Tpage, and converts the integer of Tmax / Tpageinto the corresponding code, and then the corresponding Cluster can be erased in batches when writing new data into the simulated EEPROM; (3) in an open source environment, the user writes the corresponding application program to configure the maximum page change time value Tmax, and further obtains the integral result of Tmax / Tpage, and converts the integral result of Tmax / Tpageinto the corresponding code, and then the corresponding Cluster can be erased in batches when writing new data into the simulated EEPROM.
[0074] In one example, in step S12, the FLASH write function can be called to write new data into the simulated EEPROM (i.e. the dedicated storage area of the FLASH), and it is judged whether the storage space of the current cluster (i.e. the currently used cluster) Cluster n is sufficient. If the current cluster Cluster n has sufficient storage space to save the new data to be written, the page change operation of the simulated EEPROM does not need to be triggered, and the new data is directly written into the current cluster Cluster in batches until the writing of the new data is completed.
[0075] In one example, please refer to Figure 3In step S12, a FLASH write function can be called to write the new data into the current cluster Cluster n in Block units, and each time a Block is written, it is considered as one write, thus the new data is written into the current cluster Cluster n for m times.
[0076] In another example, in step Sll, the integer result of Tmax / Tword is also obtained, i.e., the number of programmable words Qword is obtained, thus please refer to Figure 3 In step S12, a FLASH write function can be called to write the new data into the current cluster Cluster n in Block units, and each time a Block is written, it is considered as one write, thus the new data is written into the current cluster Cluster n for m times.
[0077] If the current cluster Cluster n used in step S12 does not have enough storage space to save the new data to be written, a page switching operation of the analog EEPROM is triggered to switch to the next cluster Cluster n+1, and then step S13 is executed to call a FLASH erase function to perform multiple erasures on the next cluster Cluster n+1 according to the integer result of Tmax / Tpage, thus when the page switching operation is implemented, the page switching is performed in steps, and each time only part of the next cluster Cluster n+1 is erased, and the entire next cluster Cluster n+1 is erased through k times of erasure. Wherein, when the current cluster Cluster n is valid, the next cluster Cluster n+1 is invalid before the new data is written, thus the entire next cluster Cluster n+1 can be erased before the new data is written into the next cluster Cluster n+1, thus all clusters can be used in cycles, and it is ensured that the FLASH has enough space to write new data without the need to erase old data first.
[0078] It should be understood that in some examples, if each cluster has a large enough capacity to store all the block data of the simulated EEPROM, then switching and erasing the next cluster (Cluster n+1) in this step is to clear Cluster n+1 so that in subsequent step S14, the new data and other valid data from other clusters (such as the current cluster n or the next cluster n+2) can be written to Cluster n+1 through a data reclamation operation. In other examples, if each cluster has a small capacity and multiple consecutive clusters are needed for distributed storage to store all the block data of the simulated EEPROM, then switching and erasing the next cluster (Cluster n+1) in this step is to clear Cluster n+1 so that in subsequent step S14, after writing some of the new data to the current cluster n, the remaining data can be written to Cluster n+1 through a data reclamation operation, thereby storing the new data in multiple consecutive clusters.
[0079] Optionally, please combine Figure 3 When writing new data to the current cluster n, after each write operation, the state machine Fee_MainFunction generates and saves a second operation state information that allows write interruption. For example, it sets the corresponding second state flag to a specified value to indicate that the current write task to the current cluster n has been completed. Therefore, other operations can be added between two writes to the current cluster n as needed. Specifically, after the current (e.g., the h-th) write to the current cluster n is completed, and before... Before the next (h+1th) write operation, step S31 is executed to cause the simulated EEPROM to enter a write interrupt (this write interrupt is actually an interrupt of the simulated EEPROM write operation, which is different from the write interrupt that causes the page swapping operation interruption in the following text). Then, other operations other than the page swapping operation of the simulated EEPROM are executed (such as communication operations between automotive application modules, read and write operations on other FLASH storage areas, etc.). After the other operations are completed, step S32 is executed. Based on the second operation status information saved before the other operations (i.e., the hth write), the end address of the previous write (i.e., the hth write) or the start address of the next write (i.e., the h+1th write) is located, and the next (i.e., the h+1th write) is continued on the current cluster n. This process is repeated until all the new data is written into the current cluster n.
[0080] If the next cluster Cluster n+1 is erased k times in total, the state machine Fee_MainFunction generates and saves a first operation state information to allow the erasing interruption after each call of the FLASH erasing function to complete one of the k erasing operations, for example, setting the corresponding first state flag to a specified value to indicate that the current erasing task of the next cluster Cluster n+1 has been completed. Thus, the erasing of the next cluster Cluster n+1 in the page switching operation can be temporarily interrupted according to actual needs, and other operations can be added between two adjacent erasing operations of the next cluster Cluster n+1. Specifically, after the current ith erasing operation of the next cluster Cluster n+1 (for example, the current completed is the ith erasing operation) is completed, and before the next erasing operation (i.e., the (i+1)th erasing operation) of the next cluster Cluster n+1 is performed, step S21 is performed to determine whether to enter the erasing interruption. If yes, the simulated EEPROM enters the erasing interruption (which is the "erasing" interruption of the page switching operation of the simulated EEPROM, and at this time, the simulated EEPROM enters a page switching operation interruption), and then performs other operations (for example, communication operations between vehicle application modules, reading and writing operations of other storage areas of the FLASH, etc.) other than the page switching operation of the simulated EEPROM. After the other operations are completed, step S22 is performed to update i=i+1 according to the first operation state information (i.e., the first operation state information generated when the ith erasing operation is completed) saved before the other operations are added, and when i+1≤k is determined, the next erasing operation (i.e., the (i+1)th erasing operation) of the next cluster Cluster n+1 can be continued. In this way, the process is repeated until the last erasing operation (i.e., the kth erasing operation) of the next cluster Cluster n+1 is completed. At this time, i+1>k is determined, and thus the erasing of the entire next cluster Cluster n+1 is completed, and then step S14 is performed.
[0081] As an example, the above-mentioned other operations can be obtained by calling the state service function GetJobResult of the FLASH to obtain the first operation state information.
[0082] As another example, after the last erasing operation (i.e., the kth erasing operation) of the next cluster Cluster n+1 is completed, the state machine Fee_MainFunction also generates and saves a third operation state to indicate that the erasing of the entire next cluster Cluster n+1 has been completed, and then allows the cluster header information ClusterHeader of the next cluster Cluster n+1 to be written.
[0083] In an example, please refer to Figure 3In step S14, a FLASH write function can be invoked to write the data to be written (including new data triggering the page replacement operation, and also including valid data of the current cluster Cluster n or valid data of the next cluster Cluster n+2) into the next cluster Cluster n+1 in m times in units of Block, and each time a Block is written, it is considered as one time of writing, and m is an integer greater than or equal to 1.
[0084] In another example, please refer to Figure 3 In step S14, a FLASH write function can be invoked to write the data to be written (including new data triggering the page replacement operation, and also including valid data of the current cluster Cluster n or valid data of the next cluster Cluster n+2) into the next cluster Cluster n+1 in m times in units of Qword, and in the last time (i.e., the mth time) of writing the data, if the amount of data to be written left is less than Qword, the data to be written left is written, and m is an integer greater than or equal to 1.
[0085] Optionally, please refer to Figure 3, when writing the to-be-written data including the new data triggering the page replacement operation to the next cluster Cluster n+1 for m times, the state machine Fee_MainFunction generates and saves a second operation state information allowing the write interruption after each write, for example, sets the corresponding second state flag to a specified value to indicate that the task of the current write to the next cluster Cluster n+1 has been completed, so that other operations can be added between the two writes to the next cluster Cluster n+1 according to actual needs. Specifically, after the current write (i.e., the hth write, 1≤h
[0086] In this case, through the configuration of the maximum page replacement time, the erasing and writing of Cluster n+1 are completed in multiple times (or steps), and after each erasing or writing, the corresponding operation state information is generated, so that other application operations can be added between each call of the state machine Fee_MainFunction by the upper application module without affecting the operation execution of each application module in the hardware abstraction layer (MCAL).
[0087] In an example, the capacity of each cluster Cluster configured in step S11 is at least a basic capacity, which is at least one minimum erase unit, which needs to be able to store the cluster head ClusterHeader, cluster valid flag, and data BlockData and storage block header information BlockHeader of a maximum storage block Block of the simulated EEPROM, so that in the page replacement operation in step S13, after completing the erasing of the entire next cluster Cluster n+1, the new data can be written into the next cluster through the data recycling operation, and all valid data in the current cluster Cluster n is moved to the next cluster Cluster n+1, and the current cluster Cluster n is set to invalid after the moving is completed, so that when the subsequent data is written to the simulated EEPROM and the previous cluster Cluster n-1 is used as the current cluster, the Cluster n can be used as the Cluster switched when the space of the previous cluster Cluster n-1 is insufficient to implement the page replacement.
[0088] In this example, it is assumed that the current cluster is Cluster n, the next cluster of Cluster n is Cluster n+1, and Cluster n+1 does not contain valid Block, that is, Cluster n+1 does not contain valid data. Please refer to Figure 1 and Figure 2 , the specific process of the page replacement operation of this example is as follows:
[0089] 1.1, erase Cluster n+1: call the FLASH erasing function, and perform the erasing of Cluster n+1 in Qpage (i.e., the number of pages of a FLASH page that can be erased at a time) units until the erasing of the entire Cluster n+1 is completed. The specific process can refer to the step S13 described above.
[0090] 1.2, read the Cluster ID value in the ClusterHeader of Cluster n, and write the Cluster ID+1 value to the ClusterHeader of Cluster n+1.
[0091] 1.3, read the BlockHeader in Cluster n in order from the low address to the high address.
[0092] 1.4, get the Block index from the BlockHeader of the read Cluster n, to get the Block address mapping table, if the Data address corresponding to the Block index in the Block address mapping table is equal to the FLASH physical address corresponding to the Block index, it means that the Block identified by the Block index is valid (i.e. the Block data corresponding to it is valid), read the Block data corresponding to the Block index from Cluster n and write it into Cluster n+1, and further write the BlockHeader corresponding to the Block in Cluster n+1. If the Block index in the Block address mapping table is equal to the Block index triggering data recycling (i.e. the Data address corresponding to the Block index in the Block address mapping table is not equal to the FLASH physical address corresponding to the Block index), it means that the Block identified by the Block index is invalid (i.e. the Block data corresponding to it is invalid), and there is no need to move the Block data and BlockHeader of the Block in Cluster n to Cluster n+1.
[0093] 1.5, write the new data and BlockHeader corresponding to the Block index triggering data recycling into Cluster n+1. If there is no need to write new data, only write the BlockHeader.
[0094] 1.6, update CurClusterID in Cluster n+1 to CurClusterID+1.
[0095] 1.7, read the BlockHeader of Cluster n+1 in turn, and update the corresponding Data address in the Block address mapping table according to the Block index of Cluster n+1.
[0096] 1.8, update other corresponding information in the ClusterHeader of Cluster n+1, and write Cluster Valid Flag of Cluster n+1 as 0xAAAAAAAA, and ~ (Cluster Valid Flag) as 0x55555555.
[0097] 1.9, after all the valid data in Cluster n is moved, write ClusterValid Flag of Cluster n as 0x55555555, ~ (Cluster Valid Flag) as 0xAAAAAAAA, to set Cluster n as invalid.
[0098] In another example, the capacity of each Cluster configured in step S11 is less than the basic capacity which needs to store Cluster Header, Cluster Valid Flag, and data BlockData and BlockHeader of a maximum storage Block of simulated EEPROM, and thus in the page replacement operation in step S13, after the erasing of the whole next Cluster n+1 is completed, the new data can be written into the next Cluster through data recycling operation and all the valid data in the next Cluster n+2 is moved to the next Cluster n+1, and after the moving is completed, the current Cluster n+2 is set as invalid, so that the next Cluster n+2 can be used as the Cluster for page replacement when the next Cluster n+1 is insufficient in space.
[0099] In this example, assuming that the current Cluster is Cluster n, the next Cluster is Cluster n+1, the next next Cluster is Cluster n+2, and Cluster n+1 does not contain valid Block, i.e. Cluster n+1 does not contain valid data, please refer to Figure 1 and Figure 2 , the specific process of the page replacement operation of this example is as follows:
[0100] 2.1, erase Cluster n+1: call FLASH erase function, with Qpage (i.e. the number of pages of FLASH that can be erased at a time) as the minimum erasing unit under the page replacement operation, to perform the erasing of Cluster n+1 until the erasing of the whole Cluster n+1 is completed, the specific process can refer to step S13 above.
[0101] 2.2, read the Cluster ID value in ClusterHeader of Cluster n, and write Cluster ID+1 value to ClusterHeader of Cluster n+1.
[0102] 2.3, read BlockHeader in Cluster n+2 in order from low address to high address.
[0103] 2.4, get Block index from BlockHeader in Cluster n+2, to get Block address mapping table, if Data address corresponding to Block index in the Block address mapping table is equal to FLASH physical address corresponding to the Block index, it means that the Block identified by the Block index is valid (i.e. its corresponding Block data is valid), read the Block data corresponding to the Block index from Cluster n+2 and write it into Cluster n+1, and further write BlockHeader corresponding to the Block in Cluster n+1. If Block index in the Block address mapping table is equal to the Block index triggering data recycling (i.e. Data address corresponding to Block index in the Block address mapping table is not equal to FLASH physical address corresponding to the Block index), it means that the Block identified by the Block index is invalid (i.e. its corresponding Block data is invalid), and there is no need to move BlockData and BlockHeader of the Block in Cluster n+2 to Cluster n+1.
[0104] 2.5, write new data and BlockHeader corresponding to the Block index triggering data recycling into Cluster n+1. If there is no need to write new data, only write BlockHeader.
[0105] 2.6, update CurClusterID in Cluster n+1 = CurClusterID + 1.
[0106] 2.7, read BlockHeader of Cluster n+1 in order, and update corresponding Data address in Block address mapping table according to Block index of Cluster n+1.
[0107] 2.8, update other corresponding information in ClusterHeader of Cluster n+1, and write Cluster Valid Flag of Cluster n+1 as 0xAAAAAAAA, and ~ (Cluster Valid Flag) as 0x55555555.
[0108] 2.9, after all the valid data in Cluster n+2 is moved, write Cluster Valid Flag of Cluster n+2 as 0x55555555, ~ (Cluster Valid Flag) as 0xAAAAAAAA, to set Cluster n+2 as invalid.
[0109] In summary, the page replacement scheme of the simulated EEPROM in the embodiment, by configuring the maximum page replacement time, can divide the erasing (or erasing and writing) of the Cluster (i.e. the next cluster after the current cluster and is an invalid cluster, all the data stored on the cluster is invalid data) in the page replacement operation of the simulated EEPROM into several times, thereby allowing the simulated EEPROM to enter erasing interruption or writing interruption in the page replacement operation according to actual needs, to perform other operations in addition to the page replacement operation of the simulated EEPROM, and after the execution of the other operations ends, continue to erase the Cluster according to the first operation state information generated before the erasing interruption or continue to write data to the Cluster according to the second operation state information generated before the writing interruption, so as to repeat until the erasing and data writing of the entire Cluster is completed. This method can not only accurately the page replacement time of the simulated EEPROM to meet the user's requirements for the page replacement time of the simulated EEPROM, but also can meet the user's demand for the amount of data to be stored, without forcing the user to reduce the amount of data to be stored. Moreover, it can also avoid the page replacement operation of the simulated EEPROM occupying resources for a long time and affecting the execution of related operations of other application modules (such as communication operations between application modules of a vehicle). In addition, the data recycling operation in the page replacement process can make all the Clusters corresponding to the simulated EEPROM be recycled, ensuring that there is enough space in the FLASH to write new data without the need to erase old data first, reducing the blocking time of the user accessing the simulated EEPROM. The technical solution of the embodiment can be applied to any suitable FLASH simulated EEPROM scenario, such as the page replacement of the AUTOSAR FEE module under the AUTOSAR standard.
[0110] Based on the same inventive concept, please refer to Figure 4The embodiment of the present application also provides a system, which comprises a FLASH 1, a configuration module 2 and a function module 3, the FLASH 1 has a special storage area 11 for implementing the simulated EEPROM and other storage areas 12 except the special storage area, the other storage areas 12 can be used for storing data, codes and the like except the EEPROM, the configuration module 2 is used for configuring parameters of the simulated EEPROM, the parameters include a maximum page replacement time value Tmax, and the function module 3 performs the page replacement method of the simulated EEPROM as described in the present application, and can realize the page replacement operation of the simulated EEPROM.
[0111] Optionally, the system further comprises a state machine (Fee_MainFunction) 4 and at least one application module 5, the state machine 4 is used for generating first operation state information and / or second operation state information generated in the page replacement process of the simulated EEPROM, each first operation state information is used for indicating that a corresponding sub-erasing of the cluster n+1 (i.e. "erasing" of the simulated EEPROM page replacement operation) in the page replacement process of the simulated EEPROM has been completed, and is further used as a basis for interrupting or resuming the erasing operation of the cluster n+1 (i.e. resuming "erasing" of the simulated EEPROM page replacement operation), each second operation state information is used for indicating that a corresponding sub-writing of the cluster n+1 (i.e. "writing" of the simulated EEPROM page replacement operation) in the page replacement process of the simulated EEPROM has been completed, and is further used as a basis for interrupting or resuming the writing data operation of the cluster n+1 (i.e. resuming "writing" of the simulated EEPROM page replacement operation); and each application module 5 is used for making the simulated EEPROM enter interruption according to the first operation state information or the second operation state information, performing other operations except the page replacement operation of the simulated EEPROM, and resuming the page replacement operation of the simulated EEPROM according to the first operation state information or the second operation state information before interruption after completing the other operations, so as to continue "erasing" or "writing" of the page replacement operation of the simulated EEPROM.
[0112] It should be understood that the FLASH 1, the configuration module 2, the function module 3 and the state machine 4 and each application module 5 in the system of the embodiment can be combined in one device; or any one of the FLASH 1, the configuration module 2, the function module 3 and the state machine 4 and each application module 5 can be split into multiple devices or modules; or at least part of the functions of one of the FLASH 1, the configuration module 2, the function module 3 and the state machine 4 and each application module 5 can be combined with at least part of the functions of another module, and realized in one device or module.
[0113] The FLASH 1, the configuration module 2, the function module 3 and the state machine 4 in the system according to the embodiments of the present application and at least one of the application modules 5 and the like can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on substrate, a system on package, an application specific integrated circuit (ASIC), or any other reasonable manner of integrating or packaging a circuit, and the like, or implemented in a hardware or firmware, or implemented in a proper combination of software, hardware and firmware.
[0114] Alternatively, at least one of the FLASH 1, the configuration module 2, the function module 3 and the state machine 4 and the application modules 5 and the like can be at least partially implemented as a computer program module, which can perform the functions of the corresponding module when the program is run by a computer, and can be upgraded in software.
[0115] As an example, the analog EEPROM, the function module 3 and the application modules 5 all conform to the AUTOSAR (Automotive Open System Architecture) standard, and the length of each of the storage blocks of the analog EEPROM is not fixed. Each of the application modules 5 includes a hardware abstraction layer MCAL (Microcontroller Abstraction Layer) module under the AUTOSAR standard, which is responsible for processing operations related to the hardware of the MCU chip, including at least one of an I / O (input / output) port or I / O module, an interrupt controller, a timer, a watchdog, a DMA (Direct Memory Access) module, an analog-to-digital converter ADC, a pulse width modulation module PWM, an external input signal capture module and the like. Other operations implemented by each of the application modules 5 include communication operations between modules and the like.
[0116] The system of the embodiment, by configuring the maximum page replacement time Tmax, the erasing of the next cluster Cluster n+1 (i.e. the invalid cluster, the data stored on which is all invalid data) in the page replacement process of the simulated EEPROM is completed in several times (even the new data triggering the page replacement operation is written into the erased next cluster Cluster n in several times), and after each erasing or writing, the corresponding operation state information is generated, thus between each time the upper application module 5 calls the state machine (Fee_MainFunction) 4, the page replacement operation interruption (including erasing interruption or writing interruption) can be performed to add other application operations, and the operation execution of each application module in the hardware abstraction layer (MCAL) is not affected, the long time occupation of resources by the page replacement operation of the simulated EEPROM can be avoided, and the execution of the corresponding operations (such as the communication operation between modules) of these MCAL modules is not affected.
[0117] The above description is only a description of the preferred embodiments of the present application, and does not limit the scope of the present application in any way, and any modification or change made by a person of ordinary skill in the art according to the above disclosure is within the protection scope of the technical solution of the present application.
Claims
1. A method for simulating a page swap of an EEPROM, characterized by, The analog EEPROM is based on a special storage area analog implementation of FLASH, the special storage area is divided into at least two equal capacity clusters, each of the clusters is composed of multiple FLASH pages and is used to save data of multiple storage blocks of the analog EEPROM, the page replacement method comprises: A maximum page replacement time value is pre-configured to obtain the number of erasable FLASH pages according to the maximum page replacement time value and a FLASH single page erase time; If it is judged that a page replacement operation needs to be triggered to switch to a next cluster, the next cluster is erased in batches according to the number of erasable FLASH pages, until the entire next cluster is erased, and then new data triggering the page replacement operation is written into the erased next cluster; In the process of erasing the next cluster in batches according to the number of erasable FLASH pages, a first operation state information allowing an erase interruption is generated after each completion of erasing, and then the analog EEPROM is put into an erase interruption after the corresponding batch erasing is completed according to actual needs, and other operations of the analog EEPROM except the page replacement operation are performed, and after the other operations are executed, the next erasing of the next cluster is continued according to the first operation state information generated when the corresponding batch erasing is completed, and the process is repeated until the entire next cluster is erased.
2. The page replacement method emulating an EEPROM of claim 1, wherein, When the new data is written into the analog EEPROM, it is judged whether the storage space of the current cluster is sufficient; If the storage space of the current cluster is sufficient, the new data is directly written into the current cluster; If the storage space of the current cluster is not sufficient, the page replacement operation is triggered.
3. The page replacement method emulating an EEPROM of claim 1, wherein, The data structure of each of the clusters comprises cluster header information, cluster validity flag, storage block header information and storage block data.
4. The page replacement method emulating an EEPROM of claim 3, wherein, The capacity of each of the clusters is at least a basic capacity, and the basic capacity is just enough to completely save the cluster header information and the cluster validity flag of the cluster and the data and the storage block header information of all storage blocks of the analog EEPROM at a time; after the entire next cluster is erased, the new data is written into the next cluster through a data recycling operation, all valid data in the current cluster is moved to the next cluster, and after the moving is completed, the current cluster is set to be invalid.
5. The page replacement method emulating an EEPROM of claim 4, wherein, Supposing that the current cluster is Cluster n, the next cluster is Cluster n+1 and is invalid, after the entire next cluster is erased, the steps of the data recycling operation comprise: Reading the cluster header information of Cluster n to obtain the Cluster ID value of Cluster n, and updating the Cluster ID value of Cluster n+1 according to the Cluster ID value of Cluster n; Reading the storage block header information in Cluster n in address order to obtain a storage block address mapping table (Blockindex); According to the storage block address mapping table, reading and writing the data and storage block header information in the valid storage blocks in Cluster n except the storage block address triggering the data recycling operation, which corresponds to the storage block address needing to write the new data, into Cluster n+1, and setting Cluster n as invalid by writing the cluster valid flag of Cluster n after the moving is completed; writing the new data and the corresponding storage block header information into Cluster n+1; updating the cluster header information of Cluster n+1 and setting Cluster n+1 as valid by writing the cluster valid flag of Cluster n+1; reading the storage block header information of Cluster n+1 to update the storage block address mapping table.
6. The page replacement method emulating an EEPROM of claim 3, wherein, The capacity of each cluster is at least a basic capacity, which is at least one minimum erase unit and can store the cluster header information, the cluster valid flag and the data and storage block header information of one maximum storage block of the analog EEPROM; after the erasing of the whole next cluster is completed, the new data is written into the next cluster by the data recycling operation and all the valid data in the further next cluster is moved into the next cluster, and the further next cluster is set as invalid after the moving is completed.
7. The page replacement method emulating an EEPROM of claim 6, wherein, Supposing the current cluster is Cluster n, the next cluster is Cluster n+1 and is invalid, after the erasing of the whole next cluster is completed, the steps of the data recycling operation include: reading the cluster header information of Cluster n to obtain the Cluster ID value of Cluster n and updating the Cluster ID value of Cluster n+1 according to the Cluster ID value of Cluster n; reading the cluster header information of Cluster n+2 to determine whether Cluster n+2 is valid; if Cluster n+2 is valid, reading the storage block header information in Cluster n+2 in address order to obtain the storage block address mapping table, and reading and writing the data and storage block header information in the valid storage blocks in Cluster n+2 except the storage block address triggering the data recycling operation into Cluster n+1 according to the storage block address mapping table, wherein the storage block address triggering the data recycling operation corresponds to the storage block address needing to write the new data, and setting Cluster n+2 as invalid by writing the cluster valid flag of Cluster n+2 after the moving is completed; if Cluster n+2 is invalid, no moving is needed for the data in Cluster n+2; writing the new data and the corresponding storage block header information into Cluster n+1; writing the new data and the corresponding storage block header information into Cluster n+1; updating the cluster head information of the Cluster n+1 and writing the cluster valid flag of the Cluster n+1 to set the Cluster n+1 as valid; reading the storage block head information of the Cluster n+1 to update the storage block address mapping table.
8. The page simulating method of EEPROM according to any one of claims 1 or 4 to 7, wherein, In the write data operation of writing the corresponding to-be-written data into the corresponding cluster in the data recycling operation, the corresponding to-be-written data is written in batches according to the number of one-time programmable words, or is written in batches in units of the storage blocks of the simulated EEPROM, the number of one-time programmable words being obtained according to the maximum page switching time value and the single-word programming time of the FLASH.
9. The page replacement method emulating an EEPROM of claim 8, wherein, The length of each storage block of the simulated EEPROM is not fixed.
10. The page replacement method emulating an EEPROM of claim 8, wherein, The number of one-time erasable FLASH pages is obtained by rounding off the result of dividing the maximum page switching time value by the FLASH single-page erasing time; and / or, the number of one-time programmable words is obtained by rounding off the result of dividing the maximum page switching time value by the single-word programming time of the FLASH.
11. The page simulation method of claim 8, wherein the page is simulated by the controller by performing the steps of: A second operation state information allowing write interruption is generated after each write is completed, so as to make the simulated EEPROM enter write interruption after the current write is completed according to needs, and then perform other operations of the simulated EEPROM except the page switching operation of the simulated EEPROM, and continue the next write according to the corresponding second operation state information after the other operations are performed, and repeat the above operations until the writing of the to-be-written data is completed. 12. A system, characterized by The system further comprises a state machine and at least one application module; the state machine is used to generate the first operation state information and / or the second operation state information in the page switching process of the simulated EEPROM, the first operation state information is used to indicate that the erasing of the corresponding cluster of the simulated EEPROM in the page switching process has been completed, and is further used as a basis for interrupting or continuing the erasing of the corresponding cluster in the page switching process, the second operation state information is used to indicate that the writing of the corresponding cluster of the simulated EEPROM in the page switching process has been completed, and is further used as a basis for interrupting or continuing the writing data of the corresponding cluster in the page switching process; the application module is used to make the simulated EEPROM enter interruption according to the first operation state information or the second operation state information, and perform other operations of the simulated EEPROM except the page switching operation of the simulated EEPROM.
13. The system of claim 12, wherein, The simulated EEPROM, the functional module and the application module all conform to the AUTOSAR standard, and the length of each storage block is not fixed.
14. The system of claim 13, wherein, The simulated EEPROM, the functional module and the application module all conform to the AUTOSAR standard, and the length of each storage block is not fixed.