Data storage method, terminal and computer readable storage medium
By backing up and processing the configuration parameters of SPI FLASH in RAM and writing them regularly, the problem of shortened lifespan caused by frequent operations of SPI FLASH is solved, extending the service life and improving product reliability.
Patent Information
- Application Number
- CN202011205046.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-02
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2040-11-02
AI Technical Summary
In the existing technology, frequent operations of SPI FLASH shorten its service life, and cannot effectively solve the erasure writing problem when configuration parameters in smart devices are added, modified, or deleted.
When the terminal is powered on and initialized, the configuration parameters in the SPI FLASH are read into the RAM and backed up to the record array and data array. After the preset operation is performed, the updated configuration parameters are regularly written to the SPI at once. FLASH, reducing frequent erase and write operations.
It extends the service life of SPI FLASH, increases the reliability of the product, reduces the frequent operations of SPI FLASH, and improves the stability of the equipment.
Smart Images

Figure CN114442906B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a data storage method, a terminal and a computer-readable storage medium. Background Art
[0002] With the vigorous development of the Internet of Things in smart logistics, smart manufacturing, smart medical care, smart home and other aspects, MCUs with independent processing and computing capabilities are widely used, mostly ARM (Advanced RISC Machine, microprocessor) Cortex-M series, whose processing capabilities and resources are relatively low (low resources refer to the relatively small memory of ROM flash memory and RAM system operation, generally tens of KByte), generally running RTOS (Real Time Operating System, which means that when external events or data are generated, they can be accepted and processed at a fast enough speed, and the processing results can be used within the specified time to control the production process or respond quickly to the processing system, dispatch all available resources to complete real-time tasks, and control all real-time tasks to run in a coordinated manner). These smart devices need to save user-related configuration data for SPI FLASH (SPI is a communication interface, SPI FLASH refers to a FLASH that uses SPI communication, that is, a FLASH storage device operated through a serial interface) storage, such as user name, password, etc.
[0003] FLASH (flash memory) is a type of memory device. Flash memory is a non-volatile memory that can retain data for a long time even without current supply. Its storage characteristics are equivalent to those of a hard disk. This characteristic is the basis for flash memory to become the storage medium for various portable digital devices.
[0004] At present, the SPI FLASH in the prior art is erased and written by sector (for example, 4KBytes), and has a certain number of erase and write times. When the user needs to add, modify or delete configuration parameters, the entire sector of the SPI FLASH needs to be erased and then written, which will obviously shorten the service life of the SPI FLASH.
[0005] Therefore, the prior art still needs to be improved and developed. Summary of the invention
[0006] The main purpose of the present invention is to provide a data storage method, a terminal and a computer-readable storage medium, aiming to solve the problem in the prior art that frequent operations on SPI FLASH shorten the service life of SPI FLASH.
[0007] To achieve the above object, the present invention provides a data storage method, which comprises the following steps:
[0008] When the terminal is powered on and initialized, all configuration parameters in the SPI FLASH are read and stored in the RAM;
[0009] Backing up the configuration parameters to the record array and data array of the RAM respectively according to the data content;
[0010] When it is necessary to perform a preset operation on the configuration parameter, performing the preset operation in the record array and the data array;
[0011] The configuration parameters updated in the RAM are configured into the SPI FLASH at one time.
[0012] Optionally, the data storage method, wherein the step of backing up the configuration parameters to the record array and the data array of the RAM respectively according to the data content, comprises:
[0013] Read all the configuration parameters and split all the configuration parameters;
[0014] The parameter ID, parameter value length and parameter value address of all the configuration parameters are stored in the record array;
[0015] The specific values of the parameters in all the configuration parameters are stored in the data array.
[0016] Optionally, in the data storage method, the record array is a record array of fixed length.
[0017] Optionally, in the data storage method, the data array is a data array of variable length.
[0018] Optionally, in the data storage method, the configuration parameters refer to parameters that have been saved in the SPI FLASH according to actual needs of the user.
[0019] Optionally, in the data storage method, when a preset operation needs to be performed on the configuration parameter, performing the preset operation in the record array and the data array includes:
[0020] When the configuration parameter needs to be added, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be added are added to the record array, and the specific parameter value corresponding to the parameter to be added is added to the data array; or
[0021] When the configuration parameter needs to be modified, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be modified are modified in the record array, and the specific parameter value corresponding to the parameter to be modified is modified in the data array; or
[0022] When the configuration parameter needs to be deleted, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be deleted are deleted from the record array, and the specific parameter value corresponding to the parameter to be deleted is deleted from the data array.
[0023] Optionally, the data storage method, wherein the step of configuring the configuration parameters updated in the RAM to the SPI FLASH at one time, comprises:
[0024] Detecting whether the configuration parameters in the RAM have changed at every preset period;
[0025] When it is detected that the configuration parameters in the RAM are changed, the data in the record array and the data array are combined and configured into the SPI FLASH at one time.
[0026] Optionally, the data storage method, wherein the combining of the data in the record array and the data array and configuring them into the SPI FLASH at one time, comprises:
[0027] Perform an erase operation on the SPI FLASH;
[0028] The combined data obtained by combining the data in the record array and the data array is written into the SPI FLASH through a write operation.
[0029] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a data storage program stored in the memory and executable on the processor, and when the data storage program is executed by the processor, the steps of the data storage method described above are implemented.
[0030] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a data storage program, and when the data storage program is executed by a processor, the steps of the data storage method described above are implemented.
[0031] In the present invention, when the terminal is powered on and initialized, all configuration parameters in the SPI FLASH are read and stored in the RAM; the configuration parameters are backed up to the record array and the data array of the RAM respectively according to the data content; when the configuration parameters need to be preset, the preset operation is performed in the record array and the data array; the configuration parameters updated in the RAM are configured to the SPI FLASH at one time. The present invention can reduce the frequent operation of the SPI FLASH, extend the service life of the SPI FLASH, and increase the reliability of the product by first performing the update operation of the configuration parameters in the RAM and then writing the updated configuration parameters to the SPI FLASH at one time after a period of time. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 is a flow chart of a preferred embodiment of the data storage method of the present invention;
[0033] Figure 2 is a flow chart of step S20 in a preferred embodiment of the data storage method of the present invention;
[0034] Figure 3 is a flow chart of step S30 in a preferred embodiment of the data storage method of the present invention;
[0035] Figure 4 is a flow chart of step S40 in a preferred embodiment of the data storage method of the present invention;
[0036] Figure 5 It is a flow chart of writing data to SPI FLASH in step S40 in a preferred embodiment of the data storage method of the present invention;
[0037] Figure 6 is a schematic diagram of a storage format of configuration data in a preferred embodiment of the data storage method of the present invention;
[0038] Figure 7 Schematic diagram of the operating environment of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0040] The data storage method described in the preferred embodiment of the present invention is as follows: Figure 1 As shown, the data storage method comprises the following steps:
[0041] Step S10: When the terminal is powered on and initialized, all configuration parameters in the SPI FLASH are read and stored in the RAM.
[0042] Specifically, the terminal in the present invention may refer to various intelligent terminal devices (such as smart phones, smart TVs and other intelligent products), and SPI FLASH refers to a FLASH that uses SPI (Serial Peripheral Interface, which is a serial peripheral device interface and a high-speed, full-duplex, synchronous communication bus) to communicate, that is, a FLASH storage device that operates through a serial interface. When the terminal is powered on and initialized, all configuration parameters in the SPI FLASH are first read, and the read configuration parameters are stored in RAM (equivalent to a temporary buffer).
[0043] Among them, the configuration parameters refer to user storage parameters. The present invention refers to parameters that have been saved in the SPI FLASH according to actual needs of the user, such as the name of the router that the terminal needs to connect to when it is powered on, and the password of the router and other information. These are user configuration parameters or user storage parameters.
[0044] Among them, RAM (Random Access Memory), also called main memory, is an internal memory that directly exchanges data with the CPU. It can be read and written at any time (except when refreshed) and is very fast. It is usually used as a temporary data storage medium for operating systems or other running programs. When RAM is working, information can be written (stored) or read (retrieved) from any specified address at any time.
[0045] Step S20: back up the configuration parameters to the record array and data array of the RAM respectively according to the data content.
[0046] For the specific process, please refer to Figure 2 , which is a flowchart of step S20 in the data storage method provided by the present invention.
[0047] like Figure 2 As shown, the step S20 includes:
[0048] S21, reading all the configuration parameters, and splitting all the configuration parameters;
[0049] S22, storing the parameter ID, parameter value length and parameter value address of all the configuration parameters into the record array;
[0050] S23. Store specific values of all the configuration parameters into the data array.
[0051] Specifically, the RAM is first set to two memory spaces, namely the record array and the data array, and the record array and the data array are respectively independent memory spaces, wherein the record array is a record array of fixed length; and the data array is a data array of variable length.
[0052] Obtain (i.e. read) all the configuration parameters, first split (i.e. strip) all the configuration parameters, that is, divide the specific data in all the configuration parameters into two parts according to type and store them in the record array and the data array, the data in the configuration parameters mainly include parameter ID, parameter value length, parameter value address and parameter specific value; the specific operation is: store the parameter ID (unique identifier of the terminal), parameter value length and parameter value address in the configuration parameters in the record array, and store the parameter specific value in the configuration parameters in the data array.
[0053] The record array is a record array of fixed length. Fixed length means that as long as the number of data records to be saved is determined, for example, if the number of data records is 2, the parameter ID occupies 4 bytes, the parameter value length occupies 4 bytes, and the parameter value address (i.e., address offset) occupies 4 bytes, a total of 12 bytes, multiplied by 2, is a fixed length. However, the length of the actual data can be variable, that is, the data array is a data array of variable length. For example, the name of the SSID: test123 is changed to test1234. This is the specific value of the parameter, which is stored in the data array of variable length.
[0054] Step S30: When it is necessary to perform a preset operation on the configuration parameters, the preset operation is performed in the record array and the data array.
[0055] Specifically, the preset operation includes: one or more of adding, modifying and deleting, that is, the preset operation can represent any one of adding, modifying or deleting, that is, the configuration parameters can be added, modified or deleted to update the configuration parameters.
[0056] For detailed process, please refer to Figure 3 , which is a flowchart of step S30 in the data storage method provided by the present invention.
[0057] like Figure 3 As shown, the step S30 includes:
[0058] S31. When the configuration parameter needs to be added, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be added are added to the record array, and the specific parameter value corresponding to the parameter to be added is added to the data array;
[0059] Or S32, when the configuration parameter needs to be modified, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be modified are modified in the record array, and the specific parameter value corresponding to the parameter to be modified is modified in the data array;
[0060] Or S23, when the configuration parameter needs to be deleted, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be deleted are deleted in the record array, and the parameter specific value corresponding to the parameter to be deleted is deleted in the data array.
[0061] That is to say, the present invention can perform operations of adding, modifying or deleting one or more of the configuration parameters; the operations of adding, modifying or deleting the configuration parameters are all completed on the record array and the data array, rather than being completed directly on the SPI FLASH, so as to avoid frequent erasing and writing operations on the SPI FLASH. When adding, modifying or deleting the configuration parameters, the operations (adding, modifying or deleting) on the parameter ID, parameter value length and parameter value address are all completed on the record array, and the operations (adding, modifying or deleting) on the specific values of the parameters are all completed on the data array, that is, only the content of the data in the RAM is modified, and the SPI FLASH is not erased or written at this time.
[0062] Step S40: configuring the configuration parameters updated in the RAM into the SPI FLASH once.
[0063] For detailed process, please refer to Figure 4 , which is a flowchart of step S40 in the data storage method provided by the present invention.
[0064] like Figure 4 As shown, the step S40 includes:
[0065] S41, detecting whether the configuration parameters in the RAM are changed at every preset period;
[0066] S42: When it is detected that the configuration parameters in the RAM are changed, the data in the record array and the data array are combined and configured into the SPI FLASH at one time.
[0067] Furthermore, if Figure 5 As shown, the step S42 of combining the data in the record array and the data array and configuring them into the SPI FLASH at one time specifically includes:
[0068] S421, performing an erase operation on the SPI FLASH;
[0069] S422: write the combined data obtained by combining the record array and the data in the data array into the SPI FLASH through a write operation.
[0070] Specifically, in the present invention, the changed configuration parameters in the RAM are not written into the SPI FLASH as soon as they are changed, but the changed configuration data are written into the SPI FLASH at a preset period (i.e., at intervals of a certain time, such as 1 minute, or other time, and the specific time value can be set according to actual needs).
[0071] That is to say, the present invention detects whether the configuration parameters in the RAM are changed every preset period (detection can be triggered by setting a timer), that is, whether the configuration parameters in the RAM are added, modified or deleted. If it is detected that the configuration parameters in the RAM (that is, the record array and the data array) are added, modified or deleted, the data in the record array and the data array are combined. Before writing the combined data into the SPI FLASH, it is necessary to perform an erasing operation on the SPI FLASH, and then the combined data obtained by combining the data in the record array and the data array is written into the SPI FLASH through a write operation, so that the operation of writing the updated configuration parameters into the SPI FLASH can be completed.
[0072] The present invention not only satisfies the user's operations of adding, modifying and deleting configuration parameters, but also does not perform an SPI FLASH erasing and writing operation every time an operation is performed. Instead, the configuration parameters are first updated in the RAM, and the SPI FLASH is erased and written periodically, thereby reducing the number of times the SPI FLASH is erased, extending the service life of the SPI FLASH, and increasing the reliability of the product.
[0073] Among them, the data writing or reading of the SPI FLASH is generally written or read at a time with a specific starting address in pages as units, for example, the starting address is BASE_ADDR and the page size is PAGE_SIZE; under the premise of ensuring that the configuration parameters (user storage data) do not exceed the available space, the total number of configuration parameters is recorded in the first byte, followed by the ID of parameter 1, the length LENGTH of the value of parameter 1, the address ADDR_OFFSET of parameter 1, the value VALUE of parameter 1, the ID of parameter 2, the length LENGTH of the value of parameter 2, the address ADDR_OFFSET of parameter 2, the value VALUE of parameter 2, etc., arranged in sequence.
[0074] Among them, parameter 1 value means: generally, storage is in KV (Key-Value, key-value pair, key is the number of the stored value, value is the data to be stored) format, that is, K here represents the parameter ID, such as the state of the switch, and V represents the value of parameter 1, called parameter 1 value, for example, 1 represents on, and 0 represents off.
[0075] When the terminal is powered on and initialized, all configuration parameters are read at once and read into RAM (temporary buffer), and then stored in two memory spaces according to fixed-length record arrays (parameter ID, parameter value length LENGTH, parameter value address ADDR_OFFSET) and variable-length data arrays (VALUE of parameter 1 to parameter N, i.e., specific parameter values). Users can find the corresponding parameter value according to the parameter ID, and do not need to read SPI FLASH again (because the configuration parameters in SPI FLASH are all read into RAM, so when users need to read a certain parameter, they generally read it according to ID. For example, ID is a column array numbered from 0, so as long as it is numbered according to ID, it has an address offset to store the corresponding ID value, and then read the value according to the offset, and do not need to read SPI FLASH again, because RAM is read once during power-on initialization). If the user needs to write a certain parameter ID, he only needs to update it to the memory space (i.e., the record array and the data array) first, and write the two memory spaces to SPI FLASH for the last time, and only need to write SPI FLASH once, which reduces the frequent operation of SPI FLASH and prolongs the service life of SPIFLASH.
[0076] Furthermore, if Figure 6 As shown, the memory space of the RAM can be divided into a record array and a data array. The record array stores the parameter ID of the configuration data (for example Figure 6 Parameter 0 ID - parameter N ID), parameter value length (e.g. Figure 6 Parameter 0 LENGTH - Parameter N LENGTH) and parameter value address (e.g. Figure 6 Parameter 0 ADDR-Parameter N ADDR in the data array stores the specific values of the configuration data parameters (for example Figure 6 That is to say, the specific data of the configuration parameters can be divided into two parts and stored in the record array and data array respectively according to the data type.
[0077] Figure 6 It is the storage format of configuration parameters in SPI FLASH. When the terminal is powered on and SPI FLASH is initialized, all configuration parameters are read into RAM, and then stripped and backed up to two memory spaces 2 (record array) and 3 (data array). When the user needs to read the value of a parameter ID, he only needs to find the starting address in memory 3 (data array) according to the address offset and read the value of the corresponding length. When the user needs to rewrite parameters frequently, he only needs to update 2 (record array) and 3 (data array), and then assemble them into 1 and write them into SPI FLASH again.
[0078] Among them, stripping refers to a segment of data 1 read from SPI FLASH, which is mapped to two RAM segments, namely 2 (record array) and 3 (data array). 2 (record array) stores parameter ID, parameter value length, and parameter value address. The address here is not an absolute address, but a relative address of 2 (record array), that is, the starting address starts from 0, so the address offset refers to the relative address of other parameter values starting from 0. The other segment 3 (data array) stores the specific value of the parameter. For example, to store the name SSID of the home router, the parameter ID can be numbered, such as 1, and the parameter value is TPLINK, 2 (record array), the parameter LENGT is 7, that is, the length of the string TPLINK, and the address of the parameter is also the address offset, such as the starting address is 0.
[0079] For example, taking adding KV1, modifying KV1, and deleting KV1 as an example, power on and read the existing configuration parameters of the SPI FLASH into the RAM, which is the initialization operation. Assuming that you need to add KV1, modify KV1, and delete KV1, the RAM temporarily updates the configuration parameters and modifies the total number of parameters. If you add, add 1; if you delete, subtract 1; if you modify, do not modify. Update 2 (record array), add the address of the parameter ID parameter value length parameter value corresponding to KV1 to RAM, update 3 (data array), add the value of KV1 to RAM, at this time, no SPI FLASH write operation is performed, only the RAM content is modified, and in addition, to modify KV1 or delete KV1, 2 (record array) and 3 (data array) are also updated first; according to the timing mechanism, for example, 1 minute detection update and erasing of SPI FLASH, that is, the configuration parameters are updated to SPI FLASH at a regular time; if the erasing time is reached, 2 (record array) and 3 (data array) are combined into 1, and then the SPI FLASH is erased once, and the SPI FLASH operation is written, so that the user parameter configuration to SPI FLASH is completed, and the present invention can increase the operation reliability of embedded devices with frequent reading and writing of SPI FLASH.
[0080] Furthermore, if Figure 7 As shown, based on the above data storage method, the present invention also provides a terminal, which includes a processor 10, a memory 20 and a display 30. Figure 7 Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0081] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 20 may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed in the terminal, such as the program code of the installation terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a data storage program 40 is stored on the memory 20, and the data storage program 40 can be executed by the processor 10, thereby realizing the data storage method in the present application.
[0082] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, configured to run program codes stored in the memory 20 or process data, such as executing the data storage method.
[0083] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components 10-30 of the terminal communicate with each other via a system bus.
[0084] In one embodiment, when the processor 10 executes the data storage program 40 in the memory 20, the following steps are implemented:
[0085] When the terminal is powered on and initialized, all configuration parameters in the SPI FLASH are read and stored in the RAM;
[0086] Backing up the configuration parameters to the record array and data array of the RAM respectively according to the data content;
[0087] When it is necessary to perform a preset operation on the configuration parameter, performing the preset operation in the record array and the data array;
[0088] The configuration parameters updated in the RAM are configured into the SPI FLASH at one time.
[0089] The step of backing up the configuration parameters to the record array and the data array of the RAM respectively according to the data content includes:
[0090] Read all the configuration parameters and split all the configuration parameters;
[0091] The parameter ID, parameter value length and parameter value address of all the configuration parameters are stored in the record array;
[0092] The specific values of the parameters in all the configuration parameters are stored in the data array.
[0093] Wherein, the record array is a record array of fixed length.
[0094] Wherein, the data array is a data array of variable length.
[0095] The configuration parameters refer to the parameters that have been saved in the SPI FLASH according to actual needs of the user.
[0096] Wherein, when it is necessary to perform a preset operation on the configuration parameter, performing the preset operation in the record array and the data array includes:
[0097] When the configuration parameter needs to be added, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be added are added to the record array, and the specific parameter value corresponding to the parameter to be added is added to the data array; or
[0098] When the configuration parameter needs to be modified, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be modified are modified in the record array, and the specific parameter value corresponding to the parameter to be modified is modified in the data array; or
[0099] When the configuration parameter needs to be deleted, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be deleted are deleted from the record array, and the specific parameter value corresponding to the parameter to be deleted is deleted from the data array.
[0100] The step of configuring the configuration parameters updated in the RAM to the SPI FLASH at one time includes:
[0101] Detecting whether the configuration parameters in the RAM have changed at every preset period;
[0102] When it is detected that the configuration parameters in the RAM are changed, the data in the record array and the data array are combined and configured into the SPI FLASH at one time.
[0103] The combining of the data in the record array and the data array and configuring them into the SPI FLASH at one time comprises:
[0104] Perform an erase operation on the SPI FLASH;
[0105] The combined data obtained by combining the data in the record array and the data array is written into the SPI FLASH through a write operation.
[0106] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a data storage program, and when the data storage program is executed by a processor, the steps of the data storage method described above are implemented.
[0107] In summary, the present invention provides a data storage method, terminal and storage medium, the method comprising: when the terminal is powered on and initialized, all configuration parameters in the SPI FLASH are read and stored in the RAM; the configuration parameters are backed up to the record array and the data array of the RAM according to the data content; when the configuration parameters need to be preset, the preset operation is performed in the record array and the data array; the configuration parameters updated in the RAM are configured to the SPI FLASH at one time. The present invention can reduce the frequent operation of the SPI FLASH, extend the service life of the SPI FLASH, and increase the reliability of the product by first performing the update operation of the configuration parameters in the RAM and then writing the updated configuration parameters to the SPI FLASH at one time after a period of time.
[0108] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium, and the program can include the processes of the above-mentioned method embodiments when executed. The storage medium can be a memory, a disk, an optical disk, etc.
[0109] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A data storage method, characterized in that: The data storage method comprises: When the terminal is powered on and initialized, all configuration parameters in the SPI FLASH are read and stored in the RAM; Backing up the configuration parameters to the record array and data array of the RAM respectively according to the data content, wherein the record array and the data array are respectively independent memory spaces; The step of backing up the configuration parameters to the record array and the data array of the RAM respectively according to the data content comprises: Read all the configuration parameters and split all the configuration parameters; The parameter ID, parameter value length and parameter value address of all the configuration parameters are stored in the record array; Storing specific values of parameters in all the configuration parameters into the data array; The record array is a record array of fixed length; The data array is a data array of variable length; When a preset operation is required for the configuration parameter, the preset operation is performed in the record array and the data array; the preset operation includes: one or more of adding, modifying and deleting; The configuration parameters updated in the RAM are configured into the SPI FLASH at one time.
2. The data storage method according to claim 1, characterized in that: The configuration parameters refer to the parameters that have been saved in the SPI FLASH according to actual needs of the user.
3. The data storage method according to claim 2, characterized in that: When it is necessary to perform a preset operation on the configuration parameter, performing the preset operation in the record array and the data array includes: When the configuration parameter needs to be added, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be added are added to the record array, and the specific parameter value corresponding to the parameter to be added is added to the data array; or When the configuration parameter needs to be modified, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be modified are modified in the record array, and the specific parameter value corresponding to the parameter to be modified is modified in the data array; or When the configuration parameter needs to be deleted, the parameter ID, parameter value length and parameter value address corresponding to the parameter to be deleted are deleted from the record array, and the specific parameter value corresponding to the parameter to be deleted is deleted from the data array.
4. The data storage method according to claim 3, characterized in that: The step of configuring the configuration parameters updated in the RAM into the SPI FLASH at one time includes: Detecting whether the configuration parameters in the RAM have changed at every preset period; When it is detected that the configuration parameters in the RAM are changed, the data in the record array and the data array are combined and configured into the SPI FLASH at one time.
5. The data storage method according to claim 4, characterized in that: The combining the data in the record array and the data array and configuring them into the SPI FLASH at one time comprises: Perform an erase operation on the SPI FLASH; The combined data obtained by combining the data in the record array and the data array is written into the SPI FLASH through a write operation.
6. A terminal, characterized in that: The terminal includes: a memory, a processor, and a data storage program stored in the memory and executable on the processor, wherein the data storage program implements the steps of the data storage method according to any one of claims 1 to 5 when executed by the processor.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a data storage program, and when the data storage program is executed by a processor, the steps of the data storage method according to any one of claims 1 to 5 are implemented.
