Soc parameter power-down nonvolatile storage method, device and computer equipment
By constructing block header and data header data structures for storage blocks and establishing state transition and data writing mechanisms, the problems of slow storage operation and blocking in SOC parameter power-loss non-volatile storage are solved, and efficient data writing control is achieved.
Patent Information
- Application Number
- CN202211626706.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-17
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-12-17
AI Technical Summary
In existing technologies, non-volatile storage solutions based on SOC parameters result in slow storage operation and are prone to causing blockages.
Construct a block header data structure for at least two storage blocks, establish a state transition mechanism, and set one storage block to be in an active state and the other storage block to be in a standby state based on the block header data structure; construct a data header data structure, establish a data writing mechanism, and after power-on initialization, obtain the storage address of the active storage block from the cache table, and write the data to be written to the storage address based on the state transition mechanism and the data writing mechanism.
By strictly controlling the write order, storage operating efficiency is improved, blocking is reduced, and no additional CRC check is required, thus increasing the operating speed of the storage system.
Smart Images

Figure CN116225985B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and in particular to a method, apparatus, and computer device for storing SOC parameters that are non-volatile when power is lost. Background Technology
[0002] In automotive battery management systems (BMS), the State of Charge (SOC) parameter of the vehicle battery needs to be updated and stored in real time as the battery is charged and discharged, and it must be non-volatile when power is lost. Currently, the used solution for storing non-volatile SOC parameters directly uses the Flash memory in the MCU for read and write operations, and uses an additional CRC check to determine the correctness of the written data. Because SOC parameter updates are frequent, the CRC check computation is large, resulting in slow storage operation and potential blockage.
[0003] There is currently no effective solution to the problem of slow storage operation and easy blockage in related technologies. Summary of the Invention
[0004] This embodiment provides a method, apparatus, and computer device for storing SOC parameters that are non-volatile when power is lost, in order to solve the problem of slow storage operation and easy blockage in related technologies.
[0005] Firstly, this embodiment provides a method for storing SOC parameters that are non-volatile when powered down, applicable to storage systems where SOC parameters are non-volatile when powered down; the system includes random access memory and Flash memory; the random access memory has a cache table; the Flash memory has at least two storage blocks; the method includes:
[0006] Construct a block header data structure for at least two storage blocks, establish a state transition mechanism based on the block header data structure, and set one of the storage blocks to be in an active state and the other storage block to be in a standby state based on the block header data structure.
[0007] Construct a data header data structure and establish a data writing mechanism based on the data header data structure;
[0008] After power-on initialization, the storage address of the active storage block is obtained from the cache table;
[0009] Based on the state transition mechanism and data writing mechanism, the data to be written is written to the storage address.
[0010] In some embodiments, the block header data structure of the storage block includes: erase / write count, null check flag, currently in use flag, and page-swapping flag.
[0011] In some embodiments, setting one of the storage blocks to be active and the other to be in standby state based on the block header data structure includes:
[0012] The current usage flag in the block header data structure is set to a valid state, indicating that the corresponding storage block is in an active state.
[0013] The current use flag in the block header data structure being set to invalid indicates that the corresponding storage block is in an active state.
[0014] In some embodiments, the header data structure includes ID, Len, IDLenValid, DataValid, and Data.
[0015] In some embodiments, the method further includes:
[0016] During power-on initialization, a power-on data recovery operation is performed based on the block header data structure and the flag bits in the data header data structure.
[0017] In some embodiments, the method further includes:
[0018] During idle checks, periodic maintenance operations are performed based on the block header data structure and the flag bits in the data header data structure.
[0019] In some embodiments, the method further includes:
[0020] Before retrieving the storage address of the active storage block from the cache table, the storage address of the active storage block is found by indexing from low address to high address, and the storage address is stored in the cache table.
[0021] Secondly, this embodiment provides a non-volatile storage device for SOC parameters that is not volatile when powered down, suitable for a storage system for SOC parameters that is not volatile when powered down; the system includes a random access memory and a Flash memory; the random access memory is provided with a cache table; the Flash memory is provided with at least two storage blocks; the device includes: a first processing module, a second processing module, an acquisition module, and a writing module;
[0022] The first processing module is used to construct a block header data structure for at least two storage blocks, establish a state transition mechanism based on the block header data structure, and set one of the storage blocks to be in an active state and the other storage block to be in a standby state based on the block header data structure.
[0023] The second processing module is used to construct a data header data structure and establish a data writing mechanism based on the data header data structure;
[0024] The acquisition module is used to obtain the storage address of the storage block that is in an active state from the cache table after power-on initialization;
[0025] The writing module is used to write the data to be written to the storage address based on the state transition mechanism and the data writing mechanism.
[0026] Thirdly, this embodiment provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the power-down non-volatile storage method for SOC parameters described in the first aspect above.
[0027] Fourthly, this embodiment provides a storage medium on which a computer program is stored, which, when executed by a processor, implements the power-loss non-volatile storage method for SOC parameters described in the first aspect above.
[0028] Compared with related technologies, the SOC parameter power-loss non-volatile storage method, apparatus, and computer device provided in this embodiment, by constructing a block header data structure for at least two storage blocks, establishing a state transition mechanism based on the block header data structure, setting one storage block to be in an active state and the other to be in a standby state based on the block header data structure, constructing a data header data structure, and establishing a data writing mechanism based on the data header data structure, after power-on initialization, obtaining the storage address of the active storage block from the cache table, and writing the data to be written to the storage address based on the state transition mechanism and the data writing mechanism, solves the problem of slow storage operation and easy blocking in related technologies. It strictly controls the writing order based on the state transition mechanism and the data writing mechanism without the need for additional CRC check judgment, thereby improving the operating efficiency of storage and reducing the occurrence of blocking.
[0029] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description
[0030] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0031] Figure 1 This is a hardware structure block diagram of a terminal device for a power-loss non-volatile storage method for SOC parameters provided in an embodiment of this application;
[0032] Figure 2 This is a flowchart of a method for storing SOC parameters in a power-down non-volatile manner according to an embodiment of this application;
[0033] Figure 3 This is a schematic diagram of the first initialization process provided in an embodiment of this application;
[0034] Figure 4 This is a schematic diagram of the second initialization process provided in an embodiment of this application;
[0035] Figure 5 This is a schematic diagram of the periodic maintenance process provided in one embodiment of this application;
[0036] Figure 6 This is a structural block diagram of a non-volatile storage device with SOC parameters provided in an embodiment of this application.
[0037] In the diagram: 102, processor; 104, memory; 106, transmission device; 108, input / output device; 210, first processing module; 220, second processing module; 230, acquisition module; 240, writing module. Detailed Implementation
[0038] To better understand the purpose, technical solution, and advantages of this application, the application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0039] Unless otherwise defined, the technical or scientific terms used in this application shall have the general meaning as understood by one of ordinary skill in the art to which this application pertains. Words such as “a,” “an,” “an,” “the,” “the,” and “these,” used in this application, do not indicate quantitative limitation and may be singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or modules (units) is not limited to the listed steps or modules (units) but may include steps or modules (units) not listed, or may include other steps or modules (units) inherent to such processes, methods, products, or devices. The terms “connected,” “linked,” and “coupled,” used in this application, are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. The term “multiple” used in this application refers to two or more. The "and / or" operator describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: A alone, A and B simultaneously, and B alone. Typically, the character " / " indicates that the objects before and after it are in an "or" relationship. The terms "first," "second," and "third," etc., used in this application are merely for distinguishing similar objects and do not represent a specific ordering of the objects.
[0040] The method embodiments provided in this example can be executed on a terminal, computer, or similar computing device. For example, it can run on a terminal. Figure 1 This is a hardware structure block diagram of the terminal for the SOC parameter non-volatile storage method of this embodiment. For example... Figure 1 As shown, a terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 and a memory 104 for storing data are also included. The processor 102 may be, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.
[0041] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the SOC parameter power-off non-volatile storage method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thus implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0042] The transmission device 106 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 can be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0043] This embodiment provides a method for storing SOC parameters in a non-volatile manner after power loss. Figure 2 This is a flowchart of the power-down non-volatile storage method for SOC parameters in this embodiment, as shown below. Figure 2 As shown, the process includes the following steps:
[0044] Step S210: Construct block header data structures for at least two storage blocks, establish a state transition mechanism based on the block header data structures, and set one storage block to be in an active state and the other storage block to be in a standby state based on the block header data structures.
[0045] Step S220: Construct the data header data structure and establish a data writing mechanism based on the data header data structure;
[0046] Step S230: After power-on initialization, obtain the storage address of the active storage block from the cache table;
[0047] Step S240: Based on the state transition mechanism and data writing mechanism, the data to be written is written to the storage address.
[0048] Specifically, the above-described method for storing SOC parameters as non-volatile when powered down is applicable to storage systems where SOC parameters are non-volatile when powered down; it includes random access memory (RAM) and flash memory; the RAM contains a cache table; and the flash memory contains at least two memory blocks. The SOC parameter non-volatile storage system can be an MCU, with the flash memory connected to the RAM, and the flash memory blocks can be divided into memory block A and memory block B. In other embodiments, the flash memory can be external, and this is not a limitation.
[0049] Based on a pre-defined structure, at least two storage blocks are constructed with their own header data structures. Each storage block has the same header data structure, including: erase / write count, null checksum flag, current usage flag, and paging flag. The header data structures allow storage blocks to be set to active or standby states. For example, storage block A can be set to active, and storage block B to standby. These states can be interchanged. A state transition mechanism is established by associating the relationships between the header data structures to control the cooperative operation of the two storage blocks. Based on the pre-defined structure, a data header structure for the data to be written is constructed, including ID, Len, IDLenValid, DataValid, and Data. A data writing mechanism is then established based on the relationships between these header data structures to control the writing of the data to be written, without requiring additional CRC checks.
[0050] In a power-on initialization process that ensures the SOC parameters are non-volatile, all components in the memory system are in an ideal state. For example, one memory block is active, while another is in a standby state; the cache table stores the latest valid memory address of the active memory block. When data needs to be written, the memory address of the active memory block is retrieved from the cache table. Based on the state transition mechanism and data writing mechanism, the data is written to the memory address to complete the write operation.
[0051] In existing related technologies, read and write operations are directly performed using the Flash memory in the MCU, and an additional CRC check is used to determine whether the written data is correct. Because SOC parameters are frequently updated, the CRC check computation is large, leading to slow storage operation and potential blocking. Compared to related technologies, the Flash memory in this embodiment can be either built-in or external, allowing for flexible configuration and applicability to various scenarios. Furthermore, through the above steps, a state transition mechanism and a data writing mechanism are used to strictly control the writing order, ensuring that data is written correctly without the need for additional CRC checks, thereby improving storage efficiency and reducing the occurrence of blocking; thus solving the problems of slow storage operation and potential blocking in related technologies.
[0052] In some embodiments, the block header data structure of the constructed storage block is as shown in Table 1, and the block header data structure is the same for each storage block. Block management data is written to the header of the storage block to enable the management and use of at least two storage blocks.
[0053] Table 1
[0054]
[0055] Table 1 shows the block header data structure of a storage block, which includes: CycleTimes, Verified null flag, Active flag, and Swapping flag. CycleTimes records the current number of erases / writes to the block, using Uint32 format. The count is updated after each erase / write operation. If the number of erases / writes exceeds a preset value for a given lifespan, it can be reported for early warning. Verified null flag indicates that the block has completed its null check; a valid flag is 0xAAAA0001U. Before writing data, the flash memory ensures that the storage address to be written to the block is empty. Data is erased first. The block's null check confirms that the data on the block has been erased, making the null flag valid. Active flag indicates that the block is currently in use; a valid flag is 0xAAAA0002U. Swapping flag: Used to indicate that the block is currently being swapped; valid flag 0xAAAA0003U. Various states of the storage block can be set through the above block header data structure.
[0056] In some embodiments, step S210, which sets one storage block to an active state and the other storage block to a standby state based on the block header data structure, includes the following steps:
[0057] The current use flag in the block header data structure is set to valid, indicating that the corresponding storage block is in an active state.
[0058] Setting the current use flag in the block header data structure to invalid indicates that the corresponding storage block is in an active state.
[0059] Specifically, setting the valid flag to 0xAAAA0001U indicates that the memory block is in an active state. Setting the valid flag to 0xAAAA0011U indicates that the memory block is in a standby state. Other settings are also possible, but will not be repeated here. The same principle applies to setting the erase / write count, current usage flag, and the status, mode, or operation corresponding to the paging flag. For example, setting the current usage flag to 0xAAAA0002U indicates that the memory block is currently in use. Setting the current usage flag to 0xAAAA0012U indicates that the memory block is in an unused state.
[0060] In some of these embodiments, a state transition mechanism is established based on the block header data structure, as shown in Table 2.
[0061] Table 2
[0062]
[0063]
[0064] In Table 2 above, the state transition mechanism has five stages (AE), each with its own corresponding state transition mechanism. The valid flag for ABlock is set to 0xAAAA0001U. To ensure that stored parameter data in the Flash memory is not lost during any power-down operation, an abnormal power-down protection strategy is implemented. This strategy is as follows: Stage C initiates blocking Swapping (page swapping) after power-on; Stage D initiates Erase (erasure) after power-on; Stage E initiates Erase after power-on, performs a null check after re-erasure. Stages A and B do not involve this abnormal power-down protection strategy.
[0065] In some embodiments, the constructed header data structure is shown in Table 3. The header data structure in Table 3 includes ID, Len, IDLenValid, DataValid, and Data. Wherein, ID: logical ID used for data indexing; Len: used to indicate data length; IDLenValid: used to indicate successful writing of the IDLen field, valid flag 0x55550004U; DataValid: used to indicate successful writing of the Data field, valid flag 0x55550005U; Data: used to represent the data field. By changing the writing length, the data length can be allocated according to the SOC parameter length (data header Len parameter configuration), making full use of Flash resources.
[0066] Table 3
[0067]
[0068] In some embodiments, the data writing mechanism based on the header data structure is shown in Table 4. In stages A and B: If power fails before IDLenValid completes writing, the initial index skips one header length address and rewrites the data. The data management strategy is to store data from low to high addresses within a Block, indexing the next header address based on the header length and data length. Specifically: the Block header occupies 32 bytes, and the header data structure shows that the data header occupies 24 bytes. The Len address in the header represents the space occupied by the Data header. Based on this information, an address that has not been written to can be found (indexed) within the Block. For example: the search proceeds from low to high addresses using 32 + (24 + Len) + (24 + Len) + ... until an address where IDLen has not been written is found; this is an address that has not been written to. In stages C and D: If power fails after IDLenValid completes writing but before DataValid completes writing, the initial index skips one header length and Len length address and rewrites the data.
[0069] Table 4
[0070] Stage Operation A Write IDLen B Write the IDLenValid flag C Write Data D Write the DataValid tag
[0071] In some embodiments, the method for storing SOC parameters in a non-volatile manner after power loss further includes the following steps:
[0072] Before retrieving the storage address of an active storage block from the cache table, the system indexes from low to high addresses to find the storage address of the active storage block and stores the storage address in the cache table.
[0073] Specifically, the cache table resides in the MCU's RAM. The cache table stores the offset of the latest valid data corresponding to each ID number within the block. After each power-on initialization, the offset of the latest valid data is saved. If the data does not exist, 0xffffffff is written to the cache table, recording that the IDCache address is invalid. In other embodiments, the storage address can be directly stored in the cache table; there is no restriction on this. In this embodiment, after initialization, reading and writing data does not require searching from low to high addresses in the storage block; instead, the cache table directly provides the valid storage address, improving addressing speed.
[0074] In this embodiment, the cache table strategy is as follows: after power-on, when the cache table reads valid data from the storage block for the first time, it needs to start from the low address of the storage block and work its way up to the high address. Based on the data header length and data length, it indexes the next data header address and takes the last data with the corresponding ID number and valid data field as the latest valid value. If it does not exist, then there is no valid data with the corresponding ID number in the Flash.
[0075] By using the index of the aforementioned storage address, the storage address can be changed; that is, the actual storage address in the flash memory will change. If the storage method with fixed addresses is used in the current technology, frequent updates of certain data will affect the overall lifespan of the flash memory.
[0076] In some embodiments, the method for storing SOC parameters in a non-volatile manner after power loss further includes the following steps:
[0077] During power-on initialization, power-on data recovery operations are performed based on the flag bits in the block header data structure and the data header data structure.
[0078] Specifically, power-on initialization includes two processes:
[0079] like Figure 3 As shown, the first initialization process is as follows:
[0080] Read the storage block configuration and initialize the cache table; verify the storage block configuration; if the storage block configuration verification fails, the storage block configuration is incorrect; if the storage block configuration verification passes, check if the space addresses overlap; if the space address verification fails, the storage block configuration is incorrect; if the space address verification passes, check if the control space length meets the minimum write unit requirement; if it does not meet the requirement, the storage block configuration is incorrect; if it meets the requirement, the verification passes and the storage block configuration is saved.
[0081] like Figure 4 As shown, the second initialization process is as follows:
[0082] Read the block header data structure information of two storage blocks (block A is in an active state, and block B is in a standby state); determine if block A is active and not swapping; if block A is active and not swapping, then determine if block B is in a standby state; if block B is in a standby state, then determine if iterating through the storage blocks and updating the cache table was successful; if successful, initialization is successful. If it fails, reset the storage blocks and initialize successfully.
[0083] If storage block A is not active and not swapping, then it is determined that storage block A is active and swapping. If storage block A is not active and is swapping, then the storage block is reset and initialized successfully. If storage block A is active and swapping, then the swapping of storage block B is blocked and erased; then the erase flag is set to wait for maintenance.
[0084] If storage block B is not in a standby state, mark the erase flag to wait for maintenance.
[0085] In this embodiment, the above-mentioned storage block A and storage block B can be interchanged. During power-on initialization, a power-on data recovery operation is performed according to the flag bits in the block header data structure and the data header data structure to restore the latest and valid data in the storage block.
[0086] In some embodiments, the method for storing SOC parameters in a non-volatile manner after power loss further includes the following steps:
[0087] During idle checks, periodic maintenance operations are performed based on the flags in the block header data structure and the data header data structure.
[0088] Specifically, periodic maintenance can be a pre-defined periodic maintenance program.
[0089] like Figure 5 As shown, the execution process can be as follows: execute the cycle maintenance program to determine whether the initialization was successful; if not, continue to re-initialize within the maximum number of repeated initializations; if the number of repeated initializations exceeds the maximum number, an initialization error occurs.
[0090] If so, check if Erase flag 1 is valid. If valid, perform Erase operation. If invalid or after performing Erase operation, check if Swap flag 1 is valid. If valid, perform Swap operation. If invalid or after performing Swap operation, check if the idle time meets the automatic maintenance time. If not, end.
[0091] If yes, then check if the other block is not verified. If yes, set the Erase flag to 1. If no, then check if the early Swap condition is met. If yes, set the Swap flag to 1. If no, then end.
[0092] In this embodiment, periodic maintenance operations are used for maintenance, and saving by calling SOC parameters will not block the operation. During idle periods, it checks whether early page swapping is needed; during idle periods, it checks whether erasure work needs to be performed for another block, and erases are blocked when page swapping is not required.
[0093] It should be noted that the steps shown in the above process or in the flowchart of the accompanying figures can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0094] This embodiment also provides a non-volatile storage device for SOC parameters, which is used to implement the above embodiments and preferred embodiments. Details already described will not be repeated. The terms "module," "unit," "subunit," etc., used below can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0095] Figure 6 This is a structural block diagram of the SOC parameter non-volatile storage device of this embodiment, as shown below. Figure 6 As shown, the device includes: a first processing module 210, a second processing module 220, an acquisition module 230, and a writing module 240;
[0096] The first processing module 210 is used to construct the block header data structure of at least two storage blocks, establish a state transition mechanism based on the block header data structure, and set one of the storage blocks to be in an active state and the other storage block to be in a standby state based on the block header data structure.
[0097] The second processing module 220 is used to construct the data header data structure and establish a data writing mechanism based on the data header data structure.
[0098] The acquisition module 230 is used to obtain the storage address of the active storage block from the cache table after power-on initialization;
[0099] The write module 240 is used to write the data to be written to the storage address based on the state transition mechanism and the data writing mechanism.
[0100] The aforementioned device solves the problems of slow storage operation and easy blockage in related technologies. It strictly controls the writing order based on the state transition mechanism and data writing mechanism without the need for additional CRC check judgment, thereby improving the operating efficiency of storage and reducing the occurrence of blockage.
[0101] In some embodiments, the block header data structure of the storage block includes: erase / write count, null check flag, currently in use flag, and page-over flag.
[0102] In some embodiments, the first processing module 210 is further configured to set the corresponding storage block to be in an active state when the current use flag in the block header data structure is in a valid state;
[0103] Setting the current use flag in the block header data structure to invalid indicates that the corresponding storage block is in an active state.
[0104] In some of these embodiments, the header data structure includes ID, Len, IDLenValid, DataValid, and Data.
[0105] In some embodiments, the SOC parameter non-volatile storage device further includes a power-on recovery data operation module; the power-on recovery data operation module is used to perform power-on recovery data operation according to the flag bits in the block header data structure and the data header data structure during power-on initialization.
[0106] In some embodiments, the SOC parameter non-volatile storage device also includes a periodic maintenance module;
[0107] The periodic maintenance module is used to perform periodic maintenance operations based on the flag bits in the block header data structure and the data header data structure during idle checks.
[0108] In some embodiments, the SOC parameter non-volatile storage device further includes a storage module; the storage module is used to index from low address to high address to find the storage address of the active storage block before obtaining the storage address of the active storage block from the cache table, and store the storage address in the cache table.
[0109] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.
[0110] This embodiment also provides a computer device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0111] Optionally, the computer device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0112] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0113] S1. Construct block header data structures for at least two storage blocks, establish a state transition mechanism based on the block header data structures, and set one storage block to be in an active state and the other storage block to be in a standby state based on the block header data structures.
[0114] S2, construct the data header data structure, and establish a data writing mechanism based on the data header data structure;
[0115] S3, after power-on initialization, retrieves the storage address of the active storage block from the cache table;
[0116] S4, based on the state transition mechanism and data writing mechanism, writes the data to be written to the storage address.
[0117] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated in this embodiment.
[0118] Furthermore, in conjunction with the power-down non-volatile storage method for SOC parameters provided in the above embodiments, this embodiment can also provide a storage medium for implementation. This storage medium stores a computer program; when executed by a processor, the computer program implements any of the power-down non-volatile storage methods for SOC parameters in the above embodiments.
[0119] It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. All other embodiments derived by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.
[0120] Obviously, the accompanying drawings are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar situations based on these drawings without any creative effort. Furthermore, it is understood that although the work done in this development process may be complex and lengthy, for those skilled in the art, certain design, manufacturing, or production modifications made based on the technical content disclosed in this application are merely conventional technical means and should not be considered as insufficient disclosure of this application.
[0121] The term "embodiment" in this application refers to a specific feature, structure, or characteristic described in connection with an embodiment that may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily imply the same embodiment, nor does it imply that it is mutually exclusive with or independent of other embodiments. It will be clearly or implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0122] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the appended claims.
Claims
1. A method for storing SOC parameters in a non-volatile manner after power loss, characterized in that, Suitable for non-volatile storage systems with SOC parameters that fail to operate under power loss; The system includes random access memory and Flash memory; the random access memory contains a cache table; the Flash memory contains at least two storage blocks; the method includes: Construct a block header data structure for at least two storage blocks, establish a state transition mechanism based on the block header data structure, and set one of the storage blocks to be in an active state and the other storage block to be in a standby state based on the block header data structure. Construct a header data structure and establish a data writing mechanism based on the header data structure; wherein, the header data structure includes ID, Len, IDLenValid, DataValid, and Data; IDLenValid is used to indicate that the IDLen field has been written successfully; DataValid is used to indicate that the Data field has been written successfully; the data writing mechanism includes: writing IDLen, IDLenValid, Data, and DataValid sequentially; if a power failure occurs before IDLenValid is written, the index is initialized to skip the length address of one header and rewrite the data; if a power failure occurs after IDLenValid is written but before DataValid is written, the index is initialized to skip the length address of one header and the length address of Len and rewrite the data. After power-on initialization, the storage address of the active storage block is obtained from the cache table; Based on the state transition mechanism and data writing mechanism, the data to be written is written to the storage address.
2. The method for storing SOC parameters in a non-volatile manner after power loss according to claim 1, characterized in that, The block header data structure of the storage block includes: erase / write count, null check flag, currently in use flag, and page swapping flag.
3. The method for storing SOC parameters in a non-volatile manner after power loss according to claim 2, characterized in that, The setting of one of the storage blocks in an active state and the other storage block in a standby state based on the block header data structure includes: The current usage flag in the block header data structure is set to a valid state, indicating that the corresponding storage block is in an active state. The current use flag in the block header data structure being set to invalid indicates that the corresponding storage block is in an active state.
4. The method for storing SOC parameters in a non-volatile manner after power loss according to any one of claims 1 to 3, characterized in that, The method further includes: During power-on initialization, a power-on data recovery operation is performed based on the block header data structure and the flag bits in the data header data structure.
5. The method for storing SOC parameters in a non-volatile manner after power loss according to claim 1, characterized in that, The method further includes: During idle checks, periodic maintenance operations are performed based on the block header data structure and the flag bits in the data header data structure.
6. The method for storing SOC parameters in a non-volatile manner after power loss according to claim 1, characterized in that, The method further includes: Before retrieving the storage address of the active storage block from the cache table, the storage address of the active storage block is found by indexing from low address to high address, and the storage address is stored in the cache table.
7. A storage device with non-volatile SOC parameters after power loss, characterized in that, Suitable for non-volatile storage systems with SOC parameters that fail to operate under power loss; The system includes a random access memory (RAM) and a flash memory; the RAM is configured with a cache table; the flash memory is configured with at least two storage blocks; the device includes: a first processing module, a second processing module, an acquisition module, and a writing module; The first processing module is used to construct a block header data structure for at least two storage blocks, establish a state transition mechanism based on the block header data structure, and set one of the storage blocks to be in an active state and the other storage block to be in a standby state based on the block header data structure. The second processing module is used to construct a data header data structure and establish a data writing mechanism based on the data header data structure; wherein, the data header data structure includes ID, Len, IDLenValid, DataValid, and Data; IDLenValid is used to indicate that the IDLen field has been written successfully; DataValid is used to indicate that the Data field has been written successfully; The acquisition module is used to obtain the storage address of the storage block that is in an active state from the cache table after power-on initialization; The writing module is used to write the data to be written to the storage address based on the state transition mechanism and the data writing mechanism.
8. A computer device, comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the steps of the power-down non-volatile storage method for SOC parameters as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the power-down non-volatile storage method for SOC parameters as described in any one of claims 1 to 6.
