Data storage method and system, vehicle and electronic equipment
By sequentially retrieving and managing the flag status of the data storage area in the automotive controller, the problems of low data storage efficiency and limited life in the prior art are solved, and more efficient data storage and longer life of the storage area are achieved.
Patent Information
- Application Number
- CN202411213578.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-17
AI Technical Summary
The existing automotive controller data storage solutions have large computing volume, high cost, low storage efficiency when storing data frequently, and are limited in storage life, which cannot meet the needs of the product design life cycle.
By receiving the data writing instruction of the vehicle controller, the flag bit status of the multiple data storage areas is sequentially retrieved. If all flag bits are the first state, the erase update is performed to the second state; if the second state exists, the reserved state Current status, reduce the frequency of rewritten and increase the number of storage and life.
The frequency of elimination of flag bits is reduced, the number of data storage times and the elimination life of the memory area is improved, and the efficiency and reliability of data storage are improved.
Smart Images

Figure CN119148934A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and in particular to a data storage method, system, vehicle and electronic device. Background Art
[0002] The current data storage solutions for automotive controllers are generally divided into two categories. The first solution is to use the AUTOSAR NVM (Non-Volatile Memory) module provided by various AUTOSAR (Automotive Open System Architecture) suppliers at home and abroad. By dividing the memory into multiple storage areas, one or more storage areas are used to manage all storage areas, and the actual storage requirements are abstracted into a limited number of categories, the abstracted requirements are implemented. For the need to store data frequently, multiple storage areas are usually used to store the target data, and the management storage area points to the storage area storing the latest data. Each time the storage is performed, the storage area storing the "oldest" data is overwritten, and the management storage area is updated. The second solution is to spend a few bytes at the beginning or end of the storage data block to store data management information, such as the first run flag, data check value, etc. For the need to store data frequently, multiple data blocks are usually used to store the target data, and an offset address stored in a fixed address points to the latest data block. Each time the storage is performed, the "oldest" data block is overwritten, and the offset address is updated.
[0003] However, the first type of solution has a large amount of computation, high cost, and low storage efficiency. The maximum number of storage times supported by the second type of solution is limited by the life of the FLASH memory that stores the offset address. For frequent storage needs, it may not meet the product design life cycle.
[0004] Therefore, a new data storage method is urgently needed to meet the needs of frequent data storage. Summary of the invention
[0005] In view of the above problems, embodiments of the present application provide a data storage method, system, vehicle, and electronic device to overcome the above problems or at least partially solve the above problems.
[0006] In a first aspect of an embodiment of the present application, a data storage method is provided, the method comprising:
[0007] Receive a data writing instruction sent by a vehicle controller;
[0008] In response to the data write instruction, sequentially retrieve flag bit statuses of a plurality of data storage areas in a preset data storage block;
[0009] According to the search result, determining whether the flag bit states corresponding to the respective data storage areas in the preset data storage data block are all the first flag bit states;
[0010] If the flag bit states corresponding to the respective data storage areas are all in the first flag bit state, the flag bit states corresponding to the respective data storage areas are erased and written so that the flag bit states corresponding to the respective data storage areas are all updated to the second flag bit state;
[0011] If the flag bit states corresponding to the respective data storage areas have a second flag bit state, the current flag bit states corresponding to the respective data storage areas are retained.
[0012] Optionally, the method further comprises:
[0013] Determine the target data storage area corresponding to the data write instruction based on the flag bit states corresponding to the respective data storage areas;
[0014] Based on the target data storage area, data is written into the target data storage area, and after the data is written, the flag bit state of the target data storage area is updated from the second flag bit state to the first flag bit state.
[0015] Optionally, in response to the data write instruction, sequentially retrieving flag bit states of multiple data storage areas in a preset data storage block includes:
[0016] Obtaining a start bit and an end bit predefined for the preset data storage block;
[0017] Searching the plurality of data storage areas in the preset data storage block in sequence in a direction from the start bit to the end bit;
[0018] Based on each of the retrieved data storage areas, reading a corresponding flag bit status thereof;
[0019] The determining, based on the flag bit states corresponding to the respective data storage areas, the target data storage area corresponding to the data write instruction comprises:
[0020] If the flag bit state read is the first flag bit state, continue to search for the next data storage area until the second flag bit state is read, and then determine the data storage area corresponding to the second flag bit state as the target data storage area.
[0021] Optionally, the method further comprises:
[0022] Receiving a data reading instruction sent by a vehicle controller;
[0023] In response to the data read instruction, sequentially retrieve flag bit statuses of a plurality of data storage areas in a preset data storage block;
[0024] Determine the target data storage area according to the search results;
[0025] Based on the target data storage area, data is read in the target data storage area.
[0026] Optionally, in response to the data read instruction, sequentially retrieving flag bit states of a plurality of data storage areas in a preset data storage block includes:
[0027] Obtaining a start bit and an end bit predefined for the preset data storage block;
[0028] Sequentially searching for flag bit states of a plurality of data storage areas in the preset data storage block in a direction from the start bit to the end bit;
[0029] Determining the target data storage area according to the search result includes:
[0030] Based on each of the retrieved data storage areas, reading a corresponding flag bit status thereof;
[0031] If the flag bit state read is the first flag bit state, continue to search the next data storage area until the flag bit state read is the second flag bit state, and then determine the previous data storage area of the data storage area corresponding to the second flag bit state as the target data storage area;
[0032] If the read flag bit states are all the first flag bit states, the last retrieved data storage area is determined as the target data storage area.
[0033] Optionally, the step of pre-configuring a flag bit for the preset data storage block includes:
[0034] Dividing the preset data storage block into a plurality of the data storage areas according to the preset storage space;
[0035] A plurality of bits in the flag bit are mapped one-to-one with the plurality of data storage areas to obtain a configuration relationship between the flag bit and the preset data storage block, wherein each bit is associated with a flag bit state.
[0036] Optionally, the storage space of the flag bit is determined in bytes, and the steps include:
[0037] Determining the number of the bits to be configured in the flag bit according to the number of the data storage areas;
[0038] The number of bytes required to be configured for the storage space of the flag bit is determined according to the number of bits.
[0039] In a second aspect of an embodiment of the present application, a data storage system is provided, the system comprising:
[0040] A receiving module, used for receiving a data writing instruction sent by a vehicle controller;
[0041] A retrieval module, configured to sequentially retrieve flag bit states of a plurality of data storage areas in a preset data storage block in response to the data write instruction;
[0042] A judging module, used for judging, according to the search result, whether the flag bit states corresponding to the respective data storage areas in the preset data storage data block are all the first flag bit states;
[0043] If the flag bit states corresponding to the respective data storage areas are all in the first flag bit state, the flag bit states corresponding to the respective data storage areas are erased and written so that the flag bit states corresponding to the respective data storage areas are all updated to the second flag bit state;
[0044] If the flag bit states corresponding to the respective data storage areas have a second flag bit state, the current flag bit states corresponding to the respective data storage areas are retained.
[0045] Optionally, the system further comprises:
[0046] A first determination submodule, configured to determine a target data storage area corresponding to the data write instruction based on the flag bit states corresponding to the respective data storage areas;
[0047] The data writing submodule is used to write data in the target data storage area based on the target data storage area, and after the data is written, update the flag bit state of the target data storage area from the second flag bit state to the first flag bit state.
[0048] Optionally, in response to the data write instruction, the flag bit status of multiple data storage areas in the preset data storage block are sequentially searched, and the search module includes:
[0049] An acquisition submodule, used for acquiring a start bit and an end bit predefined for the preset data storage block;
[0050] A first retrieval submodule, configured to sequentially search a plurality of data storage areas in the preset data storage block in a direction from the start position to the end position;
[0051] A first reading submodule, configured to read a flag bit status corresponding to each of the data storage areas retrieved;
[0052] The determining of the target data storage area corresponding to the data write instruction based on the flag bit states corresponding to the respective data storage areas, the first determining submodule comprises:
[0053] The first search subunit is used to continue searching the next data storage area if the read flag state is the first flag state, until the second flag state is read, and then determine the data storage area corresponding to the second flag state as the target data storage area.
[0054] Optionally, the system further comprises:
[0055] A receiving submodule, used for receiving a data reading instruction sent by a vehicle controller;
[0056] A second retrieval submodule is used to sequentially retrieve flag bit states of a plurality of data storage areas in a preset data storage block in response to the data reading instruction;
[0057] A second determination submodule is used to determine the target data storage area according to the search result;
[0058] The second reading submodule is used to read data in the target data storage area based on the target data storage area.
[0059] Optionally, in response to the data reading instruction, the flag bit status of multiple data storage areas in the preset data storage block are sequentially retrieved, and the second retrieval submodule includes:
[0060] An acquisition subunit, used for acquiring a start bit and an end bit predefined for the preset data storage block;
[0061] A second retrieval subunit is used to sequentially retrieve flag bit states of a plurality of data storage areas in the preset data storage block in a direction from the start bit to the end bit;
[0062] The target data storage area is determined according to the search result, and the second determination submodule includes:
[0063] A reading subunit, used for reading a corresponding flag bit state of each data storage area based on the retrieval;
[0064] a third retrieval subunit, configured to continue searching the next data storage area if the flag bit state read is the first flag bit state, until the flag bit state read is the second flag bit state, and then determine the previous data storage area of the data storage area corresponding to the second flag bit state as the target data storage area;
[0065] The determination subunit is used to determine the last retrieved data storage area as the target data storage area if all the flag bit states read are the first flag bit states.
[0066] Optionally, a flag bit is pre-configured for the preset data storage block, and the system further includes:
[0067] A division submodule, used for dividing the preset data storage block into a plurality of the data storage areas according to a preset storage space;
[0068] The mapping submodule is used to map multiple bits in the flag bit with multiple data storage areas one by one to obtain a configuration relationship between the flag bit and the preset data storage block, wherein each bit is associated with a flag bit state.
[0069] Optionally, the storage space of the flag bit is determined in bytes, and the system further includes:
[0070] A third determining submodule, used to determine the number of bits to be configured in the flag bit according to the number of the data storage areas;
[0071] The fourth determination submodule is used to determine the number of bytes required to be configured in the storage space of the flag bit according to the number of the bits.
[0072] According to a third aspect of an embodiment of the present application, a vehicle is provided, wherein the vehicle comprises the data storage system as described in the second aspect of the present application, and / or is used to execute the data storage method as described in the first aspect of the present application.
[0073] In a fourth aspect of an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the data storage method as described in the first aspect of the present application.
[0074] Beneficial effects of this application:
[0075] The present application provides a data storage method, the method comprising: receiving a data write instruction sent by a vehicle controller; responding to the data write instruction, sequentially retrieving the flag bit status of multiple data storage areas in a preset data storage block; judging whether the flag bit status corresponding to each data storage area in the preset data storage block is all the first flag bit status according to the retrieval result; if the flag bit status corresponding to each data storage area is all the first flag bit status, then erasing the flag bit status corresponding to each data storage area so that the flag bit status corresponding to each data storage area is all updated to the second flag bit status; if the flag bit status corresponding to each data storage area has the second flag bit status, then retaining the current flag bit status corresponding to each data storage area. After receiving the data write instruction, the present application sequentially retrieves the flag bit status of multiple data storage areas. If all flag bits are in the first flag bit status, then performing an erase operation to update all flag bit status to the second flag bit status; if there is a flag bit status in the second flag bit status, then retaining the flag bit status corresponding to each data storage area, thereby reducing the erasing frequency of the flag bit and improving the number of data storage and the erasing life of the data storage area. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0077] Figure 1 This is a schematic diagram of the steps of a data storage method provided by an embodiment of the present application;
[0078] Figure 2 This is a schematic diagram of the comparison relationship between a data storage area and a flag bit provided in an embodiment of the present application;
[0079] Figure 3 This is a flowchart of a process of writing target data into a data storage area provided by an embodiment of the present application;
[0080] Figure 4 This is a flowchart of a target data reading process provided by an embodiment of the present application;
[0081] Figure 5 is a schematic diagram of a data storage system provided in an embodiment of the present application;
[0082] Figure 6 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0083] The exemplary embodiments of the present application will be described in more detail below in conjunction with the accompanying drawings in the embodiments of the present application. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to enable the scope of the present application to be fully communicated to those skilled in the art.
[0084] Based on the above problems, the first aspect of the embodiments of the present application provides a data storage method. Figure 1 include:
[0085] Step S101, receiving a data writing instruction sent by a vehicle controller;
[0086] Specifically, in this step, it is necessary to first receive the data write instruction initiated by the vehicle controller. In the vehicle control system, the storage management module is usually responsible for processing the data write and read operations. It will receive the data write instruction issued by the vehicle controller and then perform the corresponding data write operation according to the storage strategy.
[0087] Step S102, in response to the data write instruction, sequentially searching for flag bit states of a plurality of data storage areas in a preset data storage block;
[0088] Specifically, in this embodiment, after the storage management module receives a write instruction from the vehicle controller, it executes a data write operation related to the instruction. In actual applications, the main purpose of this data write instruction is to write new data into a data storage area and ensure the correctness of the data and the update of the data storage area.
[0089] The preset data storage block is a predefined set of storage spaces for storing target data. In this step, the preset data storage block is divided into multiple independent data storage areas, each of which can be used to write and read data independently. In addition, each data storage area has a corresponding flag bit state to indicate the current state of the data storage area.
[0090] In this step, before executing the write operation, the storage management module sequentially checks the flag bit status of each data storage area to determine which storage areas have been used and which storage areas can be used to write new data. The storage management module starts from the preset first data storage area and retrieves the flag bit status of each data storage area one by one until a suitable data storage area is found for the data write operation.
[0091] Step S103, judging, according to the search result, whether the flag bit states corresponding to the respective data storage areas in the preset data storage data block are all in the first flag bit state;
[0092] If the flag bit states corresponding to the respective data storage areas are all in the first flag bit state, the flag bit states corresponding to the respective data storage areas are erased and written so that the flag bit states corresponding to the respective data storage areas are all updated to the second flag bit state;
[0093] If the flag bit states corresponding to the respective data storage areas have a second flag bit state, the current flag bit states corresponding to the respective data storage areas are retained.
[0094] Specifically, in this step, the storage management module retrieves the flag bit status of each data storage area, and determines whether the flag bits of all data storage areas are in the first flag bit status according to the retrieved result.
[0095] If the flag bit states corresponding to each data storage area are all the first flag bit state, in actual application, the first flag bit state is 0, which means that each data storage area has been written with data. Therefore, it is necessary to erase the flag bit states of all data storage areas so that the flag bit states corresponding to each data storage area are updated from the first flag bit state to the second flag bit state;
[0096] If the flag bit states corresponding to the respective data storage areas have a second flag bit state, it means that there are data storage areas without data written in these data storage areas. Therefore, the current flag bit states corresponding to these data storage areas are retained without erasing the flag bit states.
[0097] After receiving the data write instruction, the present application sequentially retrieves the flag bit states of multiple data storage areas. If all flag bits are in the first flag bit state, an erase operation is performed to update all flag bit states to the second flag bit state; if there is a flag bit state in the second flag bit state, the flag bit state corresponding to each data storage area is retained, thereby reducing the erase and write frequency of the flag bit and increasing the number of data storage times and the erase and write life of the data storage area.
[0098] In a preferred embodiment, the method further comprises:
[0099] Determine the target data storage area corresponding to the data write instruction based on the flag bit states corresponding to the respective data storage areas;
[0100] Based on the target data storage area, data is written into the target data storage area, and after the data is written, the flag bit state of the target data storage area is updated from the second flag bit state to the first flag bit state.
[0101] Specifically, in this embodiment, the data storage area to which the new data is written is determined according to the flag bit state corresponding to each data storage area. If the flag bit of a data storage area is in the second flag bit state, indicating that the storage area is available, the data storage area corresponding to the second flag bit state will be selected as the target data storage area for data writing.
[0102] Further, after determining the target data storage area, the target data is written into the target data storage area, and after the target data is successfully written into the target data storage area, the flag bit state of the target data storage area is updated from the second flag bit state to the first flag bit state.
[0103] In a preferred embodiment, in response to the data write instruction, sequentially retrieving the flag bit status of multiple data storage areas in the preset data storage block includes:
[0104] Obtaining a start bit and an end bit predefined for the preset data storage block;
[0105] Searching the plurality of data storage areas in the preset data storage block in sequence in a direction from the start bit to the end bit;
[0106] Based on each of the retrieved data storage areas, reading a corresponding flag bit status thereof;
[0107] The determining, based on the flag bit states corresponding to the respective data storage areas, the target data storage area corresponding to the data write instruction comprises:
[0108] If the flag bit state read is the first flag bit state, continue to search for the next data storage area until the second flag bit state is read, and then determine the data storage area corresponding to the second flag bit state as the target data storage area.
[0109] Specifically, in this embodiment, before performing the flag bit status search, the start bit and the end bit predefined for the preset data storage block are first obtained.
[0110] Furthermore, the search operation is performed in the order from the start bit to the end bit. That is, starting from the defined start bit, the flag bit status of each data storage area is searched in sequence until the end bit is reached. When searching each data storage area, the flag bit status corresponding to it is read. Reading the flag bit status is the key to determining whether the data storage area is available.
[0111] If the flag state read is the first flag state, indicating that the data storage area has been written, continue to search the next data storage area until the flag state read is the second flag state, and determine the data storage area as the target data storage area, and stop further searching.
[0112] In this embodiment, by setting the start bit and the end bit, this method ensures the sequentiality and effectiveness of the retrieval operation, so that it can more quickly determine which data storage area should be used for new data writing. In addition, by accurately judging the state of the flag bit, storage resources can be effectively utilized and unnecessary repeated erase and write operations can be avoided, thereby extending the erase and write life of the data storage area.
[0113] In a preferred embodiment, the method further comprises:
[0114] Receiving a data reading instruction sent by a vehicle controller;
[0115] In response to the data read instruction, sequentially retrieve flag bit statuses of a plurality of data storage areas in a preset data storage block;
[0116] Determine the target data storage area according to the search results;
[0117] Based on the target data storage area, data is read in the target data storage area.
[0118] Specifically, in this embodiment, first, a data reading instruction issued by the vehicle controller is received to trigger the subsequent operation process. Then, the preset data storage blocks are retrieved sequentially, and the flag bit status of each data storage area is checked in a predefined order to determine which data storage area contains the data to be read. When the flag bit status indicates that the storage area is the "latest" or "valid" position, the storage area is determined to be the target data storage area. Subsequently, data is read from the target data storage area, and the read data is transmitted back to the vehicle controller. Through this orderly retrieval and reading method, the accuracy and efficiency of data reading can be ensured, and data reading errors or redundant operations can be avoided. This method is particularly suitable for vehicle control systems that need to frequently access and update data, which improves the reliability and operating efficiency of the system.
[0119] In a preferred embodiment, in response to the data read instruction, sequentially retrieving the flag bit status of multiple data storage areas in the preset data storage block includes:
[0120] Obtaining a start bit and an end bit predefined for the preset data storage block;
[0121] Sequentially searching for flag bit states of a plurality of data storage areas in the preset data storage block in a direction from the start bit to the end bit;
[0122] Determining the target data storage area according to the search result includes:
[0123] Based on each of the retrieved data storage areas, reading a corresponding flag bit status thereof;
[0124] If the flag bit state read is the first flag bit state, continue to search the next data storage area until the flag bit state read is the second flag bit state, and then determine the previous data storage area of the data storage area corresponding to the second flag bit state as the target data storage area;
[0125] If the read flag bit states are all the first flag bit states, the last retrieved data storage area is determined as the target data storage area.
[0126] Specifically, in this embodiment, in response to the received data read instruction, the flag bit status of multiple data storage areas in the preset data storage block is retrieved. During the retrieval process, the predefined start bit and end bit are obtained, and each data storage area in the data storage block is retrieved one by one in the order from the start bit to the end bit.
[0127] During the retrieval process of each data storage area, the flag bit state corresponding to the data storage area is read. If the flag bit state read is the first flag bit state, the next data storage area is continuously retrieved until the flag bit state read is the second flag bit state, and the previous data storage area of the data storage area corresponding to the second flag bit state is determined as the target data storage area. If it is found that the flag bit states of all data storage areas are the first flag bit state during the entire retrieval process, it means that data has been written into all data storage areas. In this case, the last retrieved data storage area is determined as the target data storage area, and the target data storage area stores the latest written data.
[0128] In a preferred embodiment, the step of pre-configuring a flag bit for the preset data storage block comprises:
[0129] Dividing the preset data storage block into a plurality of the data storage areas according to the preset storage space;
[0130] A plurality of bits in the flag bit are mapped one-to-one with the plurality of data storage areas to obtain a configuration relationship between the flag bit and the preset data storage block, wherein each bit is associated with a flag bit state.
[0131] Specifically, in this embodiment, refer to Figure 2 The schematic diagram of the comparison relationship between the data storage area and the flag bit shown, first, the preset data storage block is divided into multiple independent data storage areas according to the preset storage space. Each data storage area occupies a part of the storage space of the preset data storage block to manage the data storage process more finely. Then, the multiple bits in the flag bit are mapped one-to-one with the multiple data storage areas divided. Through this mapping relationship, the state of each data storage area can be recorded and managed in the flag bit. Specifically, each bit is associated with a data storage area, and the state of the bit, that is, the first flag bit state and the second flag bit state, in actual application, the first flag bit state is represented by "0" and the second flag bit state is represented by "1".
[0132] In this embodiment, data management can be performed efficiently through the configuration relationship between the flag bit and the data storage area. In the process of reading and writing data, the corresponding data storage area can be determined and operated by retrieving and updating the flag bit status, thereby ensuring the accuracy and stability of the data.
[0133] In a preferred embodiment, the storage space of the flag bit is determined in bytes, and the steps include:
[0134] Determining the number of the bits to be configured in the flag bit according to the number of the data storage areas;
[0135] The number of bytes required to be configured for the storage space of the flag bit is determined according to the number of bits.
[0136] Specifically, in this embodiment, continue to refer to Figure 2 , the number of bits to be configured is determined according to the number of data storage areas. Each bit corresponds to a data storage area and is used to indicate the state of the storage area. Therefore, if there are N data storage areas, N bits are required, where N is an integer greater than or equal to 1.
[0137] After determining the number of bits, the number of bytes required in the flag storage space is calculated based on the determined number of bits. Because the memory is usually operated in bytes, and 1 byte is equal to 8 bits, so:
[0138] If N bits is an exact multiple of 8, then the number of bytes required is N / 8.
[0139] If the number of bits N is not a multiple of 8, then round up to the nearest byte. For example, if there are 9 bits, then 2 bytes are required.
[0140] In a preferred embodiment, the present application provides a flowchart of writing target data into a data storage area, such as Figure 3 As shown:
[0141] Start the data writing process, retrieve the flag bit status of the data storage area in sequence, and determine whether the "0" state of the highest bit is located in the data storage area of the 0th bit. If so, write the target data to the data storage area located at the 1st bit, and update the flag bit status of the data storage area of the 1st bit to the "0" state. If not, continue to search and determine whether the "0" state of the highest bit is located in the data storage area of the 1st bit. If so, write the target data to the data storage area of the 2nd bit, and update the flag bit status of the data storage area of the 2nd bit to the "0" state. If not, continue to search and determine whether the "0" state of the highest bit is located in the data storage area of the 2nd bit. If , then write the target data to the data storage area at the 3rd bit, and update the flag bit state of the data storage area at the 3rd bit to the "0" state..., repeat the above process until the data storage area at the Nth bit is retrieved, and judge whether the "0" state of the highest bit is located in the data storage area at the Nth bit. If so, write the target data to the data storage area at the N+1th bit, and update the flag bit state of the data storage area at the N+1th bit to the "0" state. If not, return to the data storage area at the 0th bit, write the target data to the data storage area at the 0th bit, then erase all flag bits, update the flag bit state of the data storage area at the 0th bit to the "0" state, and end the process.
[0142] In a preferred embodiment, the present application provides a flowchart of target data reading, such as Figure 4 As shown:
[0143] Start the data reading process, retrieve the flag bit status of the data storage area in sequence, judge whether the "0" state of the highest bit is located in the data storage area of the 0th bit, if so, read the target data from the data storage area located at the 0th bit, if not, continue to search, judge whether the "0" state of the highest bit is located in the data storage area of the 1st bit, if so, read the target data from the data storage area located at the 1st bit, if not, continue to search, judge whether the "0" state of the highest bit is located in the data storage area of the 2nd bit, if so, read the target data from the data storage area of the 2nd bit... Repeat the above process until the data storage area of the Nth bit is retrieved, judge whether the "0" state of the highest bit is located in the data storage area of the Nth bit, if so, read the target data from the data storage area of the Nth bit, if not, prompt that the reading fails and end the process.
[0144] In the present application, when reading the target data, the flag state is first retrieved. When reading the data, the data storage area corresponding to the first bit in the "0" state starting from the highest bit of the flag state is read. When writing the target data, the data storage area corresponding to the first bit in the "0" state starting from the highest bit of the flag state is erased and written, and the flag state of the data storage area is set to the "0" state by overwriting. When writing, when all bits of the flag are in the "0" state, the data storage area of the 0th bit is erased. In this scheme, the erasing frequency of the flag is reduced from erasing every time the target data is updated to erasing when all bits of the flag are in the "0" state. Since the number of bits is consistent with the number of data storage areas, the erasing frequency of the flag will be reduced to the same as the erasing frequency of a single data storage area, so that the actual update times of the target data are greatly increased, and the storage times of the target data are no longer limited, and can be increased infinitely if the hardware storage resources allow.
[0145] For example, assuming that there are 10 bytes of target data, 8 data storage areas are used for storage, and the length of the flag bit (storage space) is 1 byte (8 bits). When the logic runs for the first time, the flag bit storage address is erased once, and the flag bit is 0xFF.
[0146] When writing the target data for the first time, it is found that all data storage areas are unused, the data storage area at the 0th position is erased and the target data is written, and then 0xFE is directly written to the flag address without erasing. When reading, the data storage area corresponding to the first "0" bit starting from the highest bit of the flag can be found by searching the flag status, which is the data storage area at the 0th position, so the target data is read from the data storage area at the 0th position.
[0147] When writing data for the second time, by searching the flag bit status, the previous data storage area of the data storage area that is the first "0" state from the highest bit is found, that is, the data storage area at the 1st bit. Therefore, the data storage area at the 1st bit is erased and the target data is written, and then 0xFC is directly written to the flag bit address without erasing. When reading, the data storage area at the 1st bit can be found by searching the flag bit to read the target data.
[0148] …
[0149] When writing data for the ninth time, by searching the status of the flag bit, it is found that all bits of the flag bit are in the "0" state. At this time, the data storage area at the 0th bit is erased and the target data is written, and then the flag bit is erased and 0xFE is written. When reading, the data storage area at the 0th bit can be found by searching the status of the flag bit to read the target data.
[0150] The present application provides a data storage method, the method comprising: receiving a data write instruction sent by a vehicle controller; responding to the data write instruction, sequentially retrieving the flag bit status of multiple data storage areas in a preset data storage block; judging whether the flag bit status corresponding to each data storage area in the preset data storage block is all the first flag bit status according to the retrieval result; if the flag bit status corresponding to each data storage area is all the first flag bit status, then erasing the flag bit status corresponding to each data storage area so that the flag bit status corresponding to each data storage area is all updated to the second flag bit status; if the flag bit status corresponding to each data storage area has the second flag bit status, then retaining the current flag bit status corresponding to each data storage area. After receiving the data write instruction, the present application sequentially retrieves the flag bit status of multiple data storage areas. If all flag bits are in the first flag bit status, then performing an erase operation to update all flag bit status to the second flag bit status; if there is a flag bit status in the second flag bit status, then retaining the flag bit status corresponding to each data storage area, thereby reducing the erasing frequency of the flag bit and improving the number of data storage and the erasing life of the data storage area.
[0151] Based on the same inventive concept, in a second aspect of the embodiment of the present application, a data storage system is provided. Figure 5 As shown, including:
[0152] A receiving module 201 is used to receive a data writing instruction sent by a vehicle controller;
[0153] A retrieval module 202, configured to sequentially retrieve flag bit states of a plurality of data storage areas in a preset data storage block in response to the data write instruction;
[0154] A judgment module 203 is used to judge whether the flag bit states corresponding to the respective data storage areas in the preset data storage data block are all the first flag bit states according to the search result;
[0155] If the flag bit states corresponding to the respective data storage areas are all in the first flag bit state, the flag bit states corresponding to the respective data storage areas are erased and written so that the flag bit states corresponding to the respective data storage areas are all updated to the second flag bit state;
[0156] If the flag bit states corresponding to the respective data storage areas have a second flag bit state, the current flag bit states corresponding to the respective data storage areas are retained.
[0157] Optionally, the system further comprises:
[0158] A first determination submodule, configured to determine a target data storage area corresponding to the data write instruction based on the flag bit states corresponding to the respective data storage areas;
[0159] The data writing submodule is used to write data in the target data storage area based on the target data storage area, and after the data is written, update the flag bit state of the target data storage area from the second flag bit state to the first flag bit state.
[0160] Optionally, in response to the data write instruction, the flag bit status of multiple data storage areas in the preset data storage block is retrieved in sequence, and the retrieval module 202 includes:
[0161] An acquisition submodule, used for acquiring a start bit and an end bit predefined for the preset data storage block;
[0162] A first retrieval submodule, configured to sequentially search a plurality of data storage areas in the preset data storage block in a direction from the start position to the end position;
[0163] A first reading submodule, configured to read a flag bit status corresponding to each of the data storage areas retrieved;
[0164] The determining of the target data storage area corresponding to the data write instruction based on the flag bit states corresponding to the respective data storage areas, the first determining submodule comprises:
[0165] The first search subunit is used to continue searching the next data storage area if the read flag state is the first flag state, until the second flag state is read, and then determine the data storage area corresponding to the second flag state as the target data storage area.
[0166] Optionally, the system further comprises:
[0167] A receiving submodule, used for receiving a data reading instruction sent by a vehicle controller;
[0168] A second retrieval submodule is used to sequentially retrieve flag bit states of a plurality of data storage areas in a preset data storage block in response to the data reading instruction;
[0169] A second determination submodule is used to determine the target data storage area according to the search result;
[0170] The second reading submodule is used to read data in the target data storage area based on the target data storage area.
[0171] Optionally, in response to the data reading instruction, the flag bit status of multiple data storage areas in the preset data storage block are sequentially searched, and the second search submodule includes:
[0172] An acquisition subunit, used for acquiring a start bit and an end bit predefined for the preset data storage block;
[0173] A second retrieval subunit is used to sequentially retrieve flag bit states of a plurality of data storage areas in the preset data storage block in a direction from the start bit to the end bit;
[0174] The target data storage area is determined according to the search result, and the second determination submodule includes:
[0175] A reading subunit, used for reading a corresponding flag bit state of each data storage area based on the retrieval;
[0176] a third retrieval subunit, configured to continue searching the next data storage area if the flag bit state read is the first flag bit state, until the flag bit state read is the second flag bit state, and then determine the previous data storage area of the data storage area corresponding to the second flag bit state as the target data storage area;
[0177] The determination subunit is used to determine the last retrieved data storage area as the target data storage area if all the flag bit states read are the first flag bit states.
[0178] Optionally, a flag bit is pre-configured for the preset data storage block, and the system further includes:
[0179] A division submodule, used for dividing the preset data storage block into a plurality of the data storage areas according to a preset storage space;
[0180] The mapping submodule is used to map multiple bits in the flag bit with multiple data storage areas one by one to obtain a configuration relationship between the flag bit and the preset data storage block, wherein each bit is associated with a flag bit state.
[0181] Optionally, the storage space of the flag bit is determined in bytes, and the system further includes:
[0182] A third determining submodule, used to determine the number of bits to be configured in the flag bit according to the number of the data storage areas;
[0183] The fourth determination submodule is used to determine the number of bytes required to be configured in the storage space of the flag bit according to the number of the bits.
[0184] Based on the same inventive concept, a third aspect of an embodiment of the present application provides a vehicle, the vehicle comprising a data storage system as described in the second aspect of the present application, and / or for executing a data storage method as described in the first aspect of the present application.
[0185] Based on the same inventive concept, in a fourth aspect of the embodiment of the present application, an electronic device 100 is provided, such as Figure 6 As shown, it includes a memory 110, a processor 120 and a computer program stored in the memory 110, and the processor 120 executes the computer program to implement the data storage method as described in the first aspect of the present application.
[0186] Each embodiment in this specification focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referenced to each other.
[0187] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0188] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0189] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0190] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0191] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0192] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0193] The above provides a detailed introduction to a data storage method, system, vehicle and electronic device. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for a person skilled in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data storage method, characterized in that: The method comprises: Receive a data writing instruction sent by a vehicle controller; In response to the data write instruction, sequentially retrieve flag bit statuses of a plurality of data storage areas in a preset data storage block; According to the search result, determining whether the flag bit states corresponding to the respective data storage areas in the preset data storage data block are all the first flag bit states; If the flag bit states corresponding to the respective data storage areas are all in the first flag bit state, the flag bit states corresponding to the respective data storage areas are erased and written so that the flag bit states corresponding to the respective data storage areas are all updated to the second flag bit state; If the flag bit states corresponding to the respective data storage areas have a second flag bit state, the current flag bit states corresponding to the respective data storage areas are retained.
2. A data storage method according to claim 1, characterized in that: The method further comprises: Determine the target data storage area corresponding to the data write instruction based on the flag bit states corresponding to the respective data storage areas; Based on the target data storage area, data is written into the target data storage area, and after the data is written, the flag bit state of the target data storage area is updated from the second flag bit state to the first flag bit state.
3. A data storage method according to claim 2, characterized in that: In response to the data write instruction, sequentially retrieving the flag bit status of multiple data storage areas in the preset data storage block includes: Obtaining a start bit and an end bit predefined for the preset data storage block; Searching the plurality of data storage areas in the preset data storage block in sequence in a direction from the start bit to the end bit; Based on each of the retrieved data storage areas, reading a corresponding flag bit status thereof; The determining, based on the flag bit states corresponding to the respective data storage areas, the target data storage area corresponding to the data write instruction comprises: If the flag bit state read is the first flag bit state, continue to search for the next data storage area until the second flag bit state is read, and then determine the data storage area corresponding to the second flag bit state as the target data storage area.
4. A data storage method according to claim 1, characterized in that: The method further comprises: Receiving a data reading instruction sent by a vehicle controller; In response to the data read instruction, sequentially retrieve flag bit statuses of a plurality of data storage areas in a preset data storage block; Determine the target data storage area according to the search results; Based on the target data storage area, data is read in the target data storage area.
5. A data storage method according to claim 4, characterized in that: In response to the data read instruction, sequentially retrieving the flag bit status of multiple data storage areas in the preset data storage block includes: Obtaining a start bit and an end bit predefined for the preset data storage block; Sequentially searching for flag bit states of a plurality of data storage areas in the preset data storage block in a direction from the start bit to the end bit; Determining the target data storage area according to the search result includes: Based on each of the retrieved data storage areas, reading a corresponding flag bit status thereof; If the flag bit state read is the first flag bit state, continue to search the next data storage area until the flag bit state read is the second flag bit state, and then determine the previous data storage area of the data storage area corresponding to the second flag bit state as the target data storage area; If the read flag bit states are all the first flag bit states, the last retrieved data storage area is determined as the target data storage area.
6. A data storage method according to any one of claims 1 to 5, characterized in that: The step of pre-configuring a flag bit for the preset data storage block comprises: Dividing the preset data storage block into a plurality of the data storage areas according to the preset storage space; A plurality of bits in the flag bit are mapped one-to-one with the plurality of data storage areas to obtain a configuration relationship between the flag bit and the preset data storage block, wherein each bit is associated with a flag bit state.
7. A data storage method according to claim 6, characterized in that: The storage space of the flag bit is determined in bytes, and the steps include: Determining the number of the bits to be configured in the flag bit according to the number of the data storage areas; The number of bytes required to be configured for the storage space of the flag bit is determined according to the number of bits.
8. A data storage system, characterized in that: The system comprises: A receiving module, used for receiving a data writing instruction sent by a vehicle controller; A retrieval module, configured to sequentially retrieve flag bit states of a plurality of data storage areas in a preset data storage block in response to the data write instruction; A judging module, used for judging, according to the search result, whether the flag bit states corresponding to the respective data storage areas in the preset data storage data block are all the first flag bit states; If the flag bit states corresponding to the respective data storage areas are all in the first flag bit state, the flag bit states corresponding to the respective data storage areas are erased and written so that the flag bit states corresponding to the respective data storage areas are all updated to the second flag bit state; If the flag bit states corresponding to the respective data storage areas have a second flag bit state, the current flag bit states corresponding to the respective data storage areas are retained.
9. A vehicle, characterized in that: The vehicle comprises the data storage system according to claim 8, and / or is used to perform the data storage method according to any one of claims 1-7.
10. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the data storage method according to any one of claims 1 to 7.
Citation Information
Cited By
Storage management method, memory, electronic equipment and storage medium
CN120540588A
