Data storage method and device, vehicle, storage medium and computer program product
By synchronizing the data in the second storage space to the first storage space and updating the flag bit when the data storage flag bit of the first storage space is the first flag bit and the operation state is idle, the data disorder caused by multiple tasks is solved in the first storage space, and the accuracy and consistency of the data are achieved.
Patent Information
- Application Number
- CN202411596166.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-02-28
AI Technical Summary
Under the open automotive architecture, the first storage space is operated by multiple tasks at the same time, resulting in data confusion.
By determining the data storage flag bit and operation state of the first storage space, the data in the second storage space is synchronized to the first storage space only when the flag bit is the first flag bit and the operation state is an idle state, and the flag bit is updated to the second flag bit to avoid other task operations.
It effectively avoids data confusion caused by the simultaneous operation of the first storage space by multiple tasks, and ensures the accuracy and consistency of the data.
Smart Images

Figure CN119537257A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a data storage method, device, vehicle, storage medium and computer program product. Background Art
[0002] In the field of on-board controller software of the Automotive Open System Architecture (AUTOSAR), it is necessary to store key data information on the vehicle in a non-volatile storage space in real time.
[0003] For example, under the open architecture of the car, there are a first storage space and a second storage space. After the data in the second storage space is updated, the data in the second storage space needs to be updated and synchronized to the first storage space in real time. However, under this storage solution, the first storage space may be operated by multiple tasks at the same time, resulting in confusion of the data in the first storage space. Summary of the invention
[0004] To overcome the problems existing in the related art, the present disclosure provides a data storage method, device, vehicle, storage medium and computer program product.
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided a data storage method, including:
[0006] Determine the data storage flag and operation status of the first storage space;
[0007] When the data storage flag is the first flag and the operation state is the idle state, the data storage flag is updated to the second flag, and the data in the second storage space is synchronized to the first storage space; the first flag indicates that the data in the first storage space needs to be updated, the second flag indicates that the data in the first storage space does not need to be updated, and the idle state indicates that the first storage space can be operated.
[0008] Optionally, after updating the data storage flag to a second flag and synchronizing the data in the second storage space to the first storage space, the method further includes:
[0009] Determining a write status of the first storage space;
[0010] When the write status is not a success status but is the idle status, the data in the second storage space is resynchronized to the first storage space.
[0011] Optionally, before determining the data storage flag and the operation status of the first storage space, the method further includes:
[0012] Calling the first interface; the first interface is used to synchronize the data in the second storage space to the first storage space after the data in the second storage space is successfully synchronized to the first storage space, and then to perform the synchronization operation of synchronizing the data in the second storage space to the first storage space again.
[0013] Optionally, synchronizing the data in the second storage space to the first storage space includes:
[0014] The data in the second storage space of the second software layer is synchronized to the first storage space of the first software layer.
[0015] Optionally, the method further comprises:
[0016] In a case where the write status is a success status, a synchronization operation of synchronizing the data in the second storage space to the first storage space is terminated.
[0017] Optionally, the method further comprises:
[0018] When the write status is not a success status but an occupied status, the synchronization operation of synchronizing the data in the second storage space to the first storage space is maintained; the occupied status indicates that the second storage space is being operated.
[0019] Optionally, the method further comprises:
[0020] When the data storage flag is the first flag, the data in the second storage space is updated.
[0021] Optionally, determining a data storage flag bit of the first storage space includes:
[0022] The data storage flag bit sent by the second software layer is obtained at preset time intervals; the second storage space is located in the second software layer.
[0023] According to a second aspect of an embodiment of the present disclosure, there is provided a data storage device, including:
[0024] A determination module, configured to determine a data storage flag and an operation state of the first storage space;
[0025] An update module is configured to update the data storage flag to a second flag and synchronize the data in the second storage space to the first storage space when the data storage flag is a first flag and the operation state is an idle state; the first flag indicates that the data in the first storage space needs to be updated, the second flag indicates that the data in the first storage space does not need to be updated, and the idle state indicates that the first storage space can be operated.
[0026] According to a third aspect of an embodiment of the present disclosure, a vehicle is provided, comprising:
[0027] processor;
[0028] a memory for storing processor-executable instructions;
[0029] Wherein, the processor is configured to:
[0030] A flowchart of the steps of executing the data storage method provided in the first aspect of an embodiment of the present disclosure.
[0031] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the program instructions are executed by a processor, the steps of the data storage method provided in the first aspect of the embodiment of the present disclosure are implemented.
[0032] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the steps of the data storage method provided in the first aspect of an embodiment of the present disclosure.
[0033] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0034] When the data storage flag of the first storage space is the first flag and the operation state is the idle state, it means that the data in the first storage space needs to be updated and the first storage space is not operated by other tasks. Therefore, the first storage space can be operated, and the data in the second storage space can be updated to the first storage space, and the flag of the first storage space is modified to the second flag to indicate that the first storage space cannot be operated at present, thereby ensuring that the first storage space is operated by the current task and will not be updated by other tasks, thereby avoiding the data confusion problem caused by multiple tasks operating the first storage space at the same time.
[0035] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0037] Figure 1 The present invention is a flowchart showing a method for storing data according to an exemplary embodiment.
[0038] Figure 2The diagram is a schematic diagram showing data transmission between a second software layer and a first software layer via a runtime environment layer according to an exemplary embodiment.
[0039] Figure 3 The diagram is a schematic diagram showing data transmission between a second software layer and a first software layer via a C function interface according to an exemplary embodiment.
[0040] Figure 4 The diagram is a schematic diagram showing data transmission between a second software layer and a first software layer via a runtime environment layer according to an exemplary embodiment.
[0041] Figure 5 The diagram is a schematic diagram showing data transmission between a second software layer and a first software layer via a C function interface according to an exemplary embodiment.
[0042] Figure 6 The diagram is a schematic diagram showing data transmission between a second storage space and a first storage space through a Ram mirror variable according to an exemplary embodiment.
[0043] Figure 7 The diagram is a schematic diagram showing that a task A and a task B operate a first storage space simultaneously according to an exemplary embodiment.
[0044] Figure 8 The present invention is a flowchart showing a method for storing data according to an exemplary embodiment.
[0045] Fig. 9 The diagram is a logical diagram of a data storage method according to an exemplary embodiment.
[0046] Fig.10 The diagram is a schematic diagram showing multiple stages of a driving cycle of a vehicle according to an exemplary embodiment.
[0047] Fig.11 is a block diagram of a data storage device according to an exemplary embodiment.
[0048] Fig.12 is a block diagram of a vehicle according to an exemplary embodiment.
[0049] Fig.13 is a block diagram of a data storage device according to an exemplary embodiment.
[0050] Fig.14 is a block diagram of a chip system according to an exemplary embodiment. DETAILED DESCRIPTION
[0051] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0052] It should be noted that all actions of acquiring signals, information or data in the present disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the device is located and with the authorization given by the owner of the corresponding device.
[0053] Figure 1 is a flow chart showing a data storage method according to an exemplary embodiment. Figure 1 As shown, the following steps are included.
[0054] In step S10, the data storage flag and the operation status of the first storage space are determined.
[0055] Under the open architecture of the car, there are the first software layer and the second software layer. The first storage space is the storage space under the first software layer, and the second storage space is the storage space under the second software layer. After receiving the key information from the vehicle, the second software layer will first temporarily store the key information in the second storage space, and then read the key information from the second storage space and synchronize it to the first storage space of the first software layer, so as to permanently store it in the first storage space. Of course, after the key information in the second storage space is updated, the updated key information in the second storage space will also be updated and synchronized to the first storage space in a timely manner.
[0056] Among them, see Figure 2 and Figure 3 As shown, the second software layer can be an application software layer (Application Software Layer, ASW) under the automotive open architecture, which includes at least one software, and the automobile manufacturer is committed to the development of software functions on the second software layer. The second storage space can be a Ram area (Ram block) located under the BSW layer for storing non-volatile data, which is used to temporarily store key information on the vehicle.
[0057] The first software layer may be a basic software layer (BSW) under the automotive open architecture, which also includes at least one software, and the supplier is committed to the development of software functions on the first software layer. The first storage space may be an NV area (NV block) for storing non-volatile data under the BSW layer, which is used to permanently store key information on the vehicle.
[0058] See also Figure 2 and Figure 3 As shown, the first software layer and the second software layer can perform data interaction through a runtime environment layer (RTE) or through a C-function interface (C-API).
[0059] In some scenarios, taking the case where the first software layer is the BSW layer, the second software layer is the ASW layer, the first storage space is the NV area under the BSW layer, and the second storage space is the Ram area under the ASW layer, the key information on the vehicle will first be synchronized with the Ram area under the ASW layer, and then the key information in the Ram area under the ASW layer will be synchronized with the NV area under the BSW layer.
[0060] It is understandable that the storage device on the vehicle will be divided into multiple virtual disks, each virtual disk has multiple different segments mounted under it, each segment contains multiple blocks, and the granularity of the storage space represented by the virtual disks, segments and blocks gradually decreases. The first storage space and the second storage space referred to in the embodiment of the present disclosure can be at the granularity of the block, and of course can also be at other granularities, and the present disclosure does not impose any restrictions on this.
[0061] The data storage flag is used to indicate whether the data in the first storage space needs to be updated. When the data storage flag is the first flag, it indicates that the data in the first storage space needs to be updated, and when updating the data in the first storage space, the updated data needs to be synchronized to the second storage space first, and then the data in the second storage space needs to be synchronized to the first storage space, so as to utilize the second storage space with faster reading and writing speed to obtain the updated data faster; when the data storage flag is the second flag, it indicates that the data in the first storage space does not need to be updated.
[0062] The data storage flag sent by the second software layer can be obtained at preset intervals. For example, taking the preset interval as 10ms, the data storage flag sent by the second software layer can be polled at intervals of 10ms, so as to know whether the data in the first storage space needs to be updated through the change of the data flag.
[0063] The first flag indicates that the data in the first storage space needs to be updated, which can also be understood as satisfying the prerequisite for synchronizing the data with the first storage space. The second flag indicates that the data in the first storage space does not need to be updated, which can also be understood as indicating that the prerequisite for synchronizing the data with the first storage space is not satisfied. The prerequisite can be that the remaining power (State Of Charge, SOC) of the vehicle is greater than 1%, or that the vehicle has generated fault information, etc. At this time, the old value in the first storage space needs to be updated to a new value to record the remaining power and fault information of the vehicle in real time, etc. The present disclosure does not impose any restrictions on this.
[0064] For example, in a scenario where the vehicle needs to display the remaining power of the vehicle, when it is monitored that the remaining power of the vehicle is 99%, the remaining power of the vehicle can be temporarily stored in the second storage space. At this time, it can be detected that the data storage flag of the first storage space is the first flag, indicating that the remaining power of 99% in the second storage space needs to be updated to the first storage space. After updating to the first storage space, the vehicle obtains the remaining power of 99% from the first storage space for display; when the remaining power of the vehicle changes by 3%, the remaining power of 99% in the second storage space can be updated to 96%. At this time, it can also be detected that the data storage flag of the first storage space is the first flag, indicating that the updated remaining power of 96% in the second storage space needs to be updated to the first storage space. After the remaining power of 96% in the first storage space is updated accordingly, the vehicle obtains the updated remaining power of 96% from the first storage space for display, so that the user can see the dynamic changes of the remaining power of the vehicle. By updating the remaining power in the first storage space in real time, the user can see the gradual decrease of the remaining power when the vehicle loses power normally, without the situation where the remaining power of the vehicle remains unchanged and then suddenly loses power drastically.
[0065] For another example, when the vehicle abnormally loses power and then recovers, if the remaining power in the first storage space is not updated in time, the remaining power seen by the user is normal, and the user cannot perceive the phenomenon that the vehicle abnormally loses power and then recovers. When the remaining power in the first storage space is updated in real time, the remaining power after the abnormal power loss and then recovery can be dynamically displayed to the user, so that the user can perceive the phenomenon that the vehicle abnormally loses power and then recovers.
[0066] The operation state may be an asynchronous operation state (ErrSts), which indicates the state of the first storage space during operation. The asynchronous operation state includes an idle state and an occupied state. The idle state indicates that the first storage space can be operated by the current task, that is, the first storage space is not operated by other tasks at this time; the occupied state indicates that the first storage space cannot be operated by the current task, that is, the first storage space is occupied by other tasks at this time. The operation refers to performing a read operation or a write operation on the first storage space. The operation state of the first storage space may be continuously polled during the task execution cycle.
[0067] In step S20, when the data storage flag is the first flag and the operation state is the idle state, the data storage flag is updated to the second flag, and the data in the second storage space is synchronized to the first storage space.
[0068] The data in the second storage space and the data in the first storage space are key information related to the vehicle that needs to be stored by the vehicle, and the key information may be the remaining power of the battery pack, the state of health (SOH), historical fault information, etc. The second storage space serves as a temporary storage for the key information, and its ultimate goal is to store the key information in the non-volatile first storage space to permanently store the key information so that the vehicle can subsequently call the key information for data analysis, display or processing.
[0069] When the data storage flag of the first storage space is the first flag and the operation state is the idle state, it means that the data in the first storage space needs to be updated and the first storage space is in an idle state that can be operated. Therefore, the vehicle data can be stored in the second storage space, and then the data in the second storage space can be synchronized to the first storage space to realize data update storage. At the same time, the data storage flag will also be switched from the first flag to the second flag to indicate that the data in the first storage space does not need to be updated, so as to avoid other tasks operating the first storage space to synchronize data to the first storage space.
[0070] The first flag bit and the second flag bit can be any one of 1 and 0. For example, when the first flag bit is 1, the second flag bit is 0.
[0071] The operation status of the first storage space may be determined by calling the second interface (nvm_geterrorstatus).
[0072] The data in the second storage space can be synchronized with the first storage space by calling the third interface (NvM_WriteBlock). During the synchronization process, the data in the second storage space is synchronized to the C-API layer, and then synchronized with the first storage space through the C-API layer.
[0073] Taking the first flag bit as 1 and the second flag bit as an example, the data storage flag bit (TrigFlg) issued by the second software layer can be detected. When the data storage flag bit is 1, it means that the key information in the vehicle needs to be updated to the first storage space. The key information can be updated and temporarily stored in the second storage space (update Ram Block); then determine whether the operation status of the first storage space is pending (operated / occupied). If it is not in the pending state, it means that the first storage space is not operated by other tasks, and the operation status of the first storage space is idle. The key information in the second storage space will be updated to the first storage space, and the data storage flag bit will be set to 0 to prevent other tasks from operating the first storage space.
[0074] In the above example, synchronizing the key information to the first storage space includes: synchronizing and updating the key information that is newly added, deleted or modified in the second storage space to the first storage space.
[0075] It is understandable that there are multiple second storage spaces in the second software layer and multiple first storage spaces in the first software layer. For each of the multiple second storage spaces, data in the second storage space can be synchronized to the corresponding first storage space.
[0076] In the related art, the key information in the second storage space is synchronized to the first storage space by the following two solutions:
[0077] Plan A, see Figure 2 and Figure 4 The second software layer and the first software layer use the RTE layer for data exchange. The second software layer synchronizes the data in the second storage space to the RTE layer through the write process; the RTE then synchronizes the data stored in itself to the first storage space of the first software layer, and vice versa.
[0078] In this process, in order to ensure that the data is not confused, the RTE layer will automatically add a spin lock to the data in the first storage space during operation. The spin lock is used to ensure that the data in the first storage space can only be operated by one task at present, and cannot be operated by multiple tasks, thereby ensuring that the data is not confused. For example, if task A operates the data in the first storage space and changes the data from A to B, and task B also changes the data from A to C at the same time, the data in the first storage space will be relatively confused. After adding the spin lock, it can be ensured that the data in the first storage space can only be operated by the same task at the same stage, and cannot be operated in parallel by multiple tasks, thereby avoiding the above data confusion. However, adding a spin lock will bring two negative effects:
[0079] First, the spin lock ensures that the data in the first storage space can only be operated by one task. Other tasks need to constantly monitor the status of the spin lock so that they are in a waiting state instead of entering a blocking, hanging or sleeping state. This will affect the timeliness of the system response. When the data in the first storage space is large, the first storage space will be locked for a longer time, and other tasks will wait for the first storage space to be released for a longer time, resulting in delayed execution of system functions and worse timeliness of system response.
[0080] Secondly, after adding the spin lock, other tasks will continue to occupy CPU resources to detect the state of the spin lock of the first storage space. During this period, other tasks will not handle other matters, but will occupy redundant CPU resources to continuously monitor the spin lock state, thereby causing a waste of CPU resources.
[0081] Option B, see Figure 3 and Figure 5 The second software layer and the first software layer use the C-API layer for data exchange. The second software layer synchronizes the data in the second storage space to the C-API layer through the write process; the C-API then synchronizes the data stored in itself to the first storage space of the first software layer, and vice versa.
[0082] The C-API layer does not use spin locks, it uses an explicit communication mechanism with NVM (non-volatile memory). For this explicit communication mechanism, see Figure 6 As shown, a new Ram mirror variable will be added, and the data in the second storage space will be temporarily stored in the increased Ram mirror variable; and then synchronized from the increased Ram mirror variable to the first storage space. This solution also has the following two defects:
[0083] First, adding an additional Ram mirror variable will consume the memory of the second storage space, resulting in a waste of part of the space in the second storage space, and synchronizing the data in the second storage space to the Ram mirror variable will also consume a certain amount of CPU dynamic resources, resulting in a waste of CPU dynamic resources.
[0084] Secondly, since the C-API layer does not add a spin lock and there is no critical section protection mechanism, tasks may preempt the first storage space, resulting in data consistency or continuity issues and other data confusion problems.
[0085] For example, see Figure 7As shown, assuming that task A and task B operate on the data in the first storage space at the same time, the data in the first storage space includes the 10 data 11111111111, task A updates the first five values in the second storage space to 01234, and then Array
[10] becomes 0123411111, task A is interrupted, and task B with a higher priority is activated. After being activated, task B takes over the position of task A and synchronizes Array
[10] =0123411111 to the first storage space, and the data in the first storage space is 0123411111; when task B is executed, task A continues to update the last five values, and updates them to 56789. At this time, the updated value of task A should actually be 0123456789, but the data updated to the first storage space by task B is 0123411111, and the data of the two are inconsistent, so that the first five values stored in the first storage space are the new values after the update, and the last five values are the old values before the update, and the continuity of the data is problematic.
[0086] Through the above technical solution, when the data storage flag of the first storage space is the first flag and the operation state is the idle state, it means that the data in the first storage space needs to be updated, and the first storage space is not operated by other tasks. Therefore, the first storage space can be operated, and the data in the second storage space can be updated to the first storage space, and the flag of the first storage space can be modified to the second flag to notify other tasks that the first storage space cannot be operated at present, thereby ensuring that the first storage space is operated by the current task and will not be continued to be operated and updated by other tasks, thereby avoiding the data confusion problem caused by multiple tasks operating the first storage space at the same time.
[0087] Compared with Solution A, Solution A is an active protection method, which ensures that the data in the first storage space is operated by one task at the same time by adding a spin lock, and multiple tasks cannot operate the first storage space in parallel. It adds spin lock protection to the data, forcing other tasks not to operate the first storage space; while the present disclosure provides a passive protection method, which ensures that the data in the first storage space is operated by one task at the same time by adding a flag bit and an operation status, and lets other tasks know that the first storage space cannot be currently operated, so that other tasks do not operate the first storage space. Compared with Solution A, the present disclosure has the following advantages:
[0088] Adding a spin lock will occupy additional CPU resources, causing other tasks to occupy additional CPU resources and be in a busy-waiting state; however, adding a flag bit and an operation status in the present application will not occupy CPU resources. When other tasks determine that the first storage space cannot be operated, they will process other tasks to avoid other tasks being in a busy-waiting state. The present disclosure reduces the occupation of CPU resources while avoiding other tasks being in a busy-waiting state, thereby making the system response more timely and less wasted on CPU resources.
[0089] Compared with Solution B, Solution B is an explicit communication mechanism, which adds an additional Ram mirror variable, temporarily stores the data in the second storage space in the Ram mirror variable, and then synchronizes the data in the Ram mirror variable to the first storage space; while the present disclosure is an implicit communication mechanism, which does not require additional Ram mirror variables, and the data in the second storage space can be directly synchronized to the first storage space through the C-API interface without the need for transfer through the Ram mirror variable. Compared with Solution B, the present disclosure has the following advantages:
[0090] First, since the present disclosure does not set a Ram mirror variable, the waste of CPU resources and the waste of the second storage space caused by adding a Ram mirror variable can be avoided.
[0091] Secondly, the present disclosure further adds a flag bit and an operation status on the basis of Solution B. When the data storage flag bit is the first flag bit and the operation status is the idle status, it indicates that the data in the first storage space needs to be updated and the first storage space has not been operated. Therefore, the data in the second storage space can be synchronized to the first storage space, and the first flag bit is modified to the second flag bit. While the current task operates the first storage space, the second flag bit is used to let other tasks know that the first storage space does not need to update data at present, so that the first storage space is operated by one task at the same time, and will not be operated by multiple tasks, thereby avoiding the data confusion problem caused by multiple tasks operating the first storage space.
[0092] Figure 8 The present invention is an exemplary solution for synchronizing data in the second storage space to the first storage space and updating the data storage flag bit to the second flag bit according to an exemplary embodiment, which includes the following steps:
[0093] In step S30, the writing status of the first storage space is determined.
[0094] The write status may be an asynchronous write status (ErrSts), indicating whether the data in the second storage space is successfully written into the first storage space.
[0095] The write status includes a success status, an idle status, and an occupied status. The write status is a success status indicating that the data in the second storage space is successfully written into the first storage space; the idle status indicates that the first storage space can be operated by other tasks, that is, the write operation of writing the data in the second storage space into the first storage space has been completed, but it is not certain whether the write is successful; the occupied status indicates that the first storage space cannot be operated by other tasks, that is, the task that currently writes the data in the second storage space into the first storage space is operating the first storage space.
[0096] It can be understood that the idle state and the occupied state are two mutually exclusive states.
[0097] In step S40, when the write status is not a success status but is the idle status, the data in the second storage space is resynchronized to the first storage space.
[0098] When the write status is not a success status, it means that the writing of data in the second storage space to the first storage space may fail, or it may be in an occupied state where the data in the second storage space is being written to the first storage space. In order to further determine which of the two situations it is, it can be further determined whether the write status is an idle state. If the write status is an idle state, it means that the first storage space has not been operated, and the situation where the first storage space is in an occupied state can be removed, further indicating that the writing of data in the second storage space to the first storage space has failed, and the data in the second storage space can be resynchronized to the first storage space again.
[0099] Among them, in the case that the data in the second storage space fails to be written to the first storage space, the third interface (NvM_WriteBlock) can be called again to resynchronize the data in the second storage space to the first storage space, and the flag position of the first storage space can be reset to the second flag position to avoid other tasks operating the first storage space at the same time.
[0100] For example, see Fig. 9As shown, after synchronizing the data in the second storage space to the first storage space, the check phase (NvRAM_Write_Check) is entered. At this time, the second interface (nvm_geterrorstatus) can be called to check the write status (ErrSts) of the first storage space to determine whether the write status is a success status (ErrSts=NVM_REQ_OK). If the write status is not a success status, then determine whether the write status of the first storage space is an occupied status (pending). If it is not an occupied status, it means that the write status of the first storage space is an idle status. At this time, the first storage space is not operated by the task. It can be further determined that the data in the second storage space has failed to be written to the first storage space. Then, the third interface can be called again to resynchronize the data in the second storage space to the first storage space, and the flag position of the first storage space is reset to the second flag position 0.
[0101] Optionally, when the write status is a success status, the synchronization operation of synchronizing the data in the second storage space to the first storage space is terminated.
[0102] When the write status is a success status, it means that the current task has successfully synchronized the data in the second storage space to the first storage space, and the write operation to the first storage space has been completed. Therefore, the current synchronization operation of synchronizing the data in the second storage space to the first storage space can be terminated and the write operation of the next task can be started.
[0103] For example, see Fig. 9 As shown, the write status (ErrSts) of the first storage space can be checked to determine whether the write status is a success status (ErrSts=NVM_REQ_OK). If the write status is a success status, the write operation on the first storage space is completed (Write Complish). At this time, the start phase (NvRAM_Write_Start) can be re-entered from the check phase to continue the read and write operations of the next task.
[0104] Optionally, when the write status is an occupied status and not a successful status, the synchronization operation of synchronizing the data in the second storage space to the first storage space is maintained.
[0105] When the write status is not a success status, it means that the writing of data in the second storage space into the first storage space may fail, or it may be in an occupied state where the data in the second storage space is being written into the first storage space. In order to further determine which of the two situations it is, it can be further determined whether the write status is an occupied state. If it is an occupied state, it means that the current task is writing the data in the second storage space into the first storage space. At this time, the synchronization operation of synchronizing the data in the second storage space to the first storage space can be maintained.
[0106] See also Fig. 9 As shown, after synchronizing the data in the second storage space to the first storage space, the check phase (NvRAM_Write_Check) is entered. At this time, the second interface (nvm_geterrorstatus) can be called to check the write status (ErrSts) of the first storage space to determine whether the write status is a success status (ErrSts = NVM_REQ_OK). If the write status is not a success status, then determine whether the write status of the first storage space is an occupied status (pending). If it is an occupied status, it means that a write operation to the first storage space is being executed, then no execution action (Do Nothing) can be performed to maintain the current write operation.
[0107] Among them, a state machine can also be configured in the operation stage of the vehicle driving cycle. The state machine has two stages: a start stage and a check stage. For each task, the start stage of the state machine is entered by default. In the start stage, the operation of writing the data in the second storage space into the first storage space is executed; in the check stage, the operation of checking whether the data in the second storage space is successfully written into the first storage space is executed.
[0108] Through the above technical solution, when the write status of the first storage space is not a success status but an idle status, it means that the current task fails to write the data in the second storage space into the first storage space. Then, the data in the second storage space can be resynchronized to the first storage space to ensure that the expected data can be correctly written into the first storage space, and the expected data refers to correct data without confusion.
[0109] Fig. 9 It is a schematic diagram of calling an interface before determining the data storage flag and operation status of a first storage space according to an exemplary embodiment, which includes: calling a third interface; the third interface is used to perform a synchronization operation of synchronizing the data in the second storage space to the first storage space again after the data in the second storage space is successfully synchronized to the first storage space.
[0110] See also Fig.10As shown, the driving cycle of the vehicle includes an initialization phase (Init), a running phase (Run), a post-running phase (PostRun) and a shutdown phase (Power Off), and these four phases are executed sequentially in a single driving cycle.
[0111] Among them, the first interface (NvM_SetRamBlockStatus) is called in the initialization phase, and the first interface is used to execute data storage (NvM_WriteAll) once in the post-operation phase, which can also be understood as executing non-volatile data storage again.
[0112] For example, during the operation stage, the data in the second storage space is synchronized to the first storage space. There are multiple second storage spaces in the second software layer on the vehicle, and there are multiple first storage spaces in the first software layer. After the data in the multiple second storage spaces are respectively synchronized to the multiple first storage spaces, the data in the multiple first storage spaces can be synchronized again to the multiple first storage spaces in the post-operation stage, that is, before the vehicle is shut down and powered off, so as to increase the robustness of successful data storage.
[0113] During the operation phase, the second interface and the third interface are called, the operation status and the writing status of the first storage space are determined through the second interface, and the data of the current task in the second storage space is synchronized to the first storage space through the third interface.
[0114] See also Fig. 9 As shown, the operation phase includes a start phase and a check phase.
[0115] In the starting stage, the flag bit of the first storage space is first determined. When the flag bit of the first storage space is the first flag bit, it is determined that the data in the first storage space needs to be updated. Therefore, the data in the second storage space needs to be updated first, so that the data in the second storage space can be subsequently synchronized to the first storage space; then the second interface is called to determine the operating status of the first storage space; if the operating status is an idle state, that is, not an occupied state, the third interface is called to synchronize the updated data in the second storage space to the first storage space, and the flag bit of the first storage space is set to the second flag bit. If the operating status is not an idle state, that is, an occupied state, no execution operation is performed.
[0116] During the checking phase, the second interface is called to determine the write status of the first storage space; if the write status is a success status, the write operation is completed; if the write status is not a success status and is an idle status, that is, it is neither a success status nor an occupied status, then the operation phase is returned to, and the third interface is called to resynchronize the updated data in the second storage space to the first storage space, and the flag position of the first storage space is set to the second flag position; if the write status is not a success status and is an occupied status, then the checking phase is maintained without performing any execution operations.
[0117] In the post-operation phase, data storage is completed once, and the data in the second storage space is synchronized with the write operation in the first storage space again through the first interface.
[0118] After the operation phase, it will determine whether to shut down (Shutdown Allow). If shutdown is required, it will enter the post-operation phase; if shutdown is not required, it will re-enter the operation phase.
[0119] During the shutdown phase, the system on the vehicle will be shut down and the hardware devices will be powered off.
[0120] Through the above technical solution, the first interface can be called in the initialization phase first, so that in the post-operation phase, that is, before the electronic control unit (ECU) of the vehicle is shut down, the data in the second storage space can be synchronized to the first storage space to improve the robustness of successful data storage.
[0121] Fig.11 is a block diagram of a data storage device according to an exemplary embodiment. Fig.11 The data storage device 1100 includes: a determination module 1110 and an update module 1120.
[0122] The determination module 1110 is configured to determine a data storage flag and an operation state of the first storage space;
[0123] The update module 1120 is configured to update the data storage flag to a second flag and synchronize the data in the second storage space to the first storage space when the data storage flag is a first flag and the operation state is an idle state; the first flag indicates that the data in the first storage space needs to be updated, the second flag indicates that the data in the first storage space does not need to be updated, and the idle state indicates that the first storage space can be operated.
[0124] Optionally, the data storage device 1100 further includes:
[0125] A checking module, configured to determine a write status of the first storage space;
[0126] The re-update module is configured to resynchronize the data in the second storage space to the first storage space when the write status is not a success status but is in the idle status.
[0127] Optionally, the data storage device 1100 further includes:
[0128] The calling module is configured to call the first interface; the first interface is used to perform a synchronization operation of synchronizing the data in the second storage space to the first storage space again after the data in the second storage space is successfully synchronized to the first storage space.
[0129] Optionally, the update module 1120 is further configured to synchronize data in the second storage space of the second software layer to the first storage space of the first software layer.
[0130] Optionally, the data storage device 1100 further includes:
[0131] The completion module is configured to terminate the synchronization operation of synchronizing the data in the second storage space to the first storage space when the write status is a success status.
[0132] Optionally, the data storage device 1100 further includes:
[0133] The maintaining module is configured to maintain the synchronization operation of synchronizing the data in the second storage space to the first storage space when the write status is an occupied state and not a successful state; the occupied state indicates that the second storage space is being operated.
[0134] Optionally, the data storage device 1100 further includes:
[0135] The second storage space updating module is configured to update the data in the second storage space when the data storage flag is the first flag.
[0136] Optionally, the determination module 1110 is further configured to obtain a data storage flag sent by the second software layer at a preset time interval; the second storage space is located in the second software layer.
[0137] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0138] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, which implement the steps of the data storage method provided by the present disclosure when the program instructions are executed by a processor.
[0139] Fig.12 1 is a block diagram of a vehicle 1200 according to an exemplary embodiment. For example, the vehicle 1200 may be a hybrid vehicle, a non-hybrid vehicle, an electric vehicle, a fuel cell vehicle, or other types of vehicles. The vehicle 1200 may be an autonomous vehicle, a semi-autonomous vehicle, or a non-autonomous vehicle.
[0140] Reference Fig.12 , the vehicle 1200 may include various subsystems, for example, an infotainment system 1210, a perception system 1220, a decision control system 1230, a drive system 1240, and a computing platform 1250. The vehicle 1200 may also include more or fewer subsystems, and each subsystem may include multiple components. In addition, each subsystem and each component of the vehicle 1200 may be interconnected by wire or wireless means.
[0141] In some embodiments, the infotainment system 1210 may include a communication system, an entertainment system, and a navigation system, etc.
[0142] The perception system 1220 may include several sensors for sensing information about the environment around the vehicle 1200. For example, the perception system 1220 may include a global positioning system (the global positioning system may be a GPS system, or a Beidou system or other positioning systems), an inertial measurement unit (IMU), a laser radar, a millimeter wave radar, an ultrasonic radar, and a camera.
[0143] The decision control system 1230 may include a computing system, a vehicle controller, a steering system, a throttle, and a braking system.
[0144] The drive system 1240 may include components that provide powered motion for the vehicle 1200. In one embodiment, the drive system 1240 may include an engine, an energy source, a transmission system, and wheels. The engine may be one or a combination of an internal combustion engine, an electric motor, and an air compression engine. The engine is capable of converting energy provided by the energy source into mechanical energy.
[0145] Some or all functions of the vehicle 1200 are controlled by a computing platform 1250. The computing platform 1250 may include at least one processor 1251 and a memory 1252, and the processor 1251 may execute instructions 1253 stored in the memory 1252.
[0146] The processor 1251 may be any conventional processor, such as a commercially available CPU. The processor may also include a graphics processor (Graphic Process Unit, GPU), a field programmable gate array (Field Programmable Gate Array, FPGA), a system on chip (System on Chip, SOC), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC) or a combination thereof.
[0147] Memory 1252 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0148] In addition to instructions 1253 , memory 1252 may also store data, such as road maps, route information, vehicle location, direction, speed, etc. The data stored in memory 1252 may be used by computing platform 1250 .
[0149] In the embodiment of the present disclosure, the processor 1251 may execute instruction 1253 to complete all or part of the steps of the above-mentioned data storage method.
[0150] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0151] In another exemplary embodiment, a computer program product is also provided. The computer program product includes a computer program executable by a programmable device, and the computer program has a code portion for executing the above data storage method when executed by the programmable device.
[0152] Fig.13 1 is a block diagram of a data storage device 1300 according to an exemplary embodiment. For example, the device 1300 may be provided as a server. Fig.13, the apparatus 1300 includes a processing component 1322, which further includes one or more processors, and a memory resource represented by a memory 1332 for storing instructions executable by the processing component 1322, such as an application. The application stored in the memory 1332 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1322 is configured to execute instructions to perform the above-mentioned data storage method.
[0153] The device 1300 may also include a power supply component 1326 configured to perform power management of the device 1300, a wired or wireless network interface 1350 configured to connect the device 1300 to a network, and an input / output interface 1358. The device 1300 may operate based on an operating system stored in the memory 1332.
[0154] Some embodiments of the present disclosure also provide a chip system, such as Fig.14 As shown, the chip system includes at least one processor 1401 and at least one interface circuit 1402. The processor 1401 and the interface circuit 1402 can be interconnected via lines. For example, the interface circuit 1402 can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the interface circuit 1402 can be used to send signals to other devices (such as the processor 1401). Exemplarily, the interface circuit 1402 can read instructions stored in the memory and send the instructions to the processor 1401. When the instructions are executed by the processor 1401, the data storage device can perform the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, and some embodiments of the present disclosure are not specifically limited to this.
[0155] In some embodiments of the present disclosure, the interface circuit 1402 can obtain data, program instructions and / or information from the internal storage area of the chip system; it can also obtain data, program instructions and / or information from outside the chip system.
[0156] Optionally, the chip system may also include a memory for storing necessary computer programs and data.
[0157] Those skilled in the art may also understand that the various illustrative logical blocks and steps listed in the embodiments of the present application may be implemented by electronic hardware, computer software, or a combination of the two. Whether such functions are implemented by hardware or software depends on the specific application and the design requirements of the entire system. Those skilled in the art may use various methods to implement the functions described for each specific application, but such implementation should not be understood as exceeding the scope of protection of the embodiments of the present application.
[0158] In addition, the word "exemplary" is used herein to indicate serving as an example, instance, or diagram. Any aspect or design described as "exemplary" in this article is not necessarily understood to be advantageous compared to other aspects or designs. On the contrary, the use of the word exemplary is intended to present concepts in a specific way. As used herein, the term "or" is intended to represent an inclusive "or" rather than an exclusive "or". That is, unless otherwise specified or clear from the context, "X applies A or B" is intended to represent any one of the natural inclusive arrangements. That is, if X applies A; X applies B; or X applies both A and B, "X applies A or B" is satisfied under any of the aforementioned examples. In addition, unless otherwise specified or clearly pointed to a singular form from the context, the articles "one" and "an" as used in this application and the appended claims are generally understood to mean "one or more".
[0159] Likewise, although the present disclosure has been shown and described with respect to one or more implementations, equivalent variations and modifications will occur to those skilled in the art after reading and understanding the specification and drawings. The present disclosure includes all such modifications and variations and is limited only by the scope of the claims. In particular, with respect to the various functions performed by the components (e.g., elements, resources, etc.) described above, unless otherwise noted, the terms used to describe such components are intended to correspond to any component (functionally equivalent) that performs the specific functions of the described components, even if the structure is not equivalent to the disclosed structure. In addition, although the specific features of the present disclosure may have been disclosed with respect to only one of several implementations, such features may be combined with one or more other features of other implementations as may be desired and conducive to any given or specific application. In addition, with respect to "including", "having", "having", "having", or variations thereof used in the specific embodiments or claims, such terms are intended to be inclusive in a manner similar to the term "comprising".
[0160] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
[0161] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A data storage method, characterized in that: include: Determine the data storage flag and operation status of the first storage space; When the data storage flag is the first flag and the operation state is the idle state, updating the data storage flag to the second flag, and synchronizing the data in the second storage space to the first storage space; The first flag bit indicates that data in the first storage space needs to be updated, the second flag bit indicates that data in the first storage space does not need to be updated, and the idle state indicates that the first storage space can be operated.
2. The method according to claim 1, characterized in that After the data storage flag is updated to a second flag and the data in the second storage space is synchronized to the first storage space, the method further includes: Determining a write status of the first storage space; When the write status is not a success status but is the idle status, the data in the second storage space is resynchronized to the first storage space.
3. The method according to claim 1, characterized in that Before determining the data storage flag and the operation status of the first storage space, the method further includes: Calling the first interface; the first interface is used to synchronize the data in the second storage space to the first storage space after the data in the second storage space is successfully synchronized to the first storage space, and then to perform the synchronization operation of synchronizing the data in the second storage space to the first storage space again.
4. The method according to claim 1, characterized in that The step of synchronizing the data in the second storage space to the first storage space includes: The data in the second storage space of the second software layer is synchronized to the first storage space of the first software layer.
5. The method according to claim 2, characterized in that: The method further comprises: In a case where the write status is a success status, a synchronization operation of synchronizing the data in the second storage space to the first storage space is terminated.
6. The method according to claim 2, characterized in that The method further comprises: When the write status is not a success status but an occupied status, the synchronization operation of synchronizing the data in the second storage space to the first storage space is maintained; the occupied status indicates that the second storage space is being operated.
7. The method according to claim 1, characterized in that The method further comprises: When the data storage flag is the first flag, the data in the second storage space is updated.
8. The method according to claim 1, characterized in that Determining a data storage flag bit of the first storage space includes: The data storage flag bit sent by the second software layer is obtained at preset time intervals; the second storage space is located in the second software layer.
9. A data storage device, characterized in that: include: A determination module, configured to determine a data storage flag and an operation state of the first storage space; an update module, configured to update the data storage flag bit to a second flag bit and synchronize the data in the second storage space to the first storage space when the data storage flag bit is the first flag bit and the operation state is an idle state; The first flag bit indicates that data in the first storage space needs to be updated, the second flag bit indicates that data in the first storage space does not need to be updated, and the idle state indicates that the first storage space can be operated.
10. A vehicle, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: Execute the steps of the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
12. A computer program product, characterized in that The invention comprises a computer program, which implements the steps of the method according to any one of claims 1 to 8 when being executed by a processor.