Data storage method, device and system and vehicle
By encapsulating multiple data storage requested data into NvM blocks in the automotive controller and storing data in the same storage page, and using an overwrite mechanism to store data in non-blank pages, the problems of waste of storage resources and shortening of Flash life are solved, and more efficient storage resource utilization and data storage reliability are achieved.
Patent Information
- Application Number
- CN202311451032.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-01
- Publication Date
- 2025-05-13
AI Technical Summary
The existing nonvolatile storage mechanisms lead to waste of storage resources and shortened Flash life in automotive controllers, especially when the data to be stored is small, the storage page length of external NOR Flash is larger, resulting in waste of resources and additional erases.
By encapsulating the data to be stored corresponding to multiple data storage requests into NvM blocks and storing them in the same storage page, the overwrite mechanism is used to store data in non-blank pages, and the remaining space of the storage page is reasonably utilized to extend the life of the Flash.
Improve the utilization rate of storage resources, reduce waste of storage resources, extend the service life of Flash, and improve the speed and reliability of data storage.
Smart Images

Figure CN119987645A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data storage technology, and in particular to a data storage method, device, system and vehicle. Background Art
[0002] The automotive open system architecture (AUTOSAR) is an open industry-standard software architecture jointly established by global automobile manufacturers (such as original equipment manufacturers (OEM) manufacturers, first-tier automobile suppliers, etc.), component suppliers and other electronics, semiconductor and software suppliers. This software architecture covers the real-time scheduling, communication, diagnosis, storage management, functional safety and information security required to build automotive controllers, and has been widely used in automotive software development. When storing data, AUTOSAR provides a hierarchical non-volatile storage mechanism, based on which the data to be stored can be encapsulated into blocks and stored separately in one or more Flash pages.
[0003] With the evolution of automotive electronic and electrical architecture (E / E architecture), automotive controllers mostly use system on a chip (SoC) to be responsible for application data related processing, etc. Currently, SoC mostly uses external non-volatile flash memory (NOR Flash), such as serial peripheral interface (SPI) NOR Flash to store data. The Flash page length of the external NOR Flash is usually large. According to the existing non-volatile storage mechanism, when the data to be stored is not large, it will also occupy a Flash page, so this mechanism will cause a waste of storage resources. Summary of the invention
[0004] The present application provides a data storage method, device, system and vehicle, which can reduce the waste of storage resources, improve the utilization rate of storage resources, and improve the data storage speed and data storage reliability.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, a data storage method is provided, the method comprising: in response to multiple data storage requests, encapsulating the to-be-stored data corresponding to the multiple data storage requests into multiple NvM blocks; and storing at least two NvM blocks of the multiple NvM blocks in a first storage page.
[0007] As an example, the method can be applied to the field of vehicle-mounted technology, such as on a domain controller and other devices capable of data processing and storage. The domain controller may include but is not limited to an intelligent driving domain controller, a cockpit domain controller, a chassis domain controller, a power domain controller, a thermal management controller, a body domain controller, etc.
[0008] As an example, the above-mentioned domain controller and other devices capable of data processing and storage may store data through a flash memory (Flash), for example, by storing data through a plurality of flash memory pages (ie, storage pages) of the flash memory.
[0009] Of course, the method can also be applied to other technical fields of storing data through multiple storage pages of a storage module, and this application does not make any specific limitation.
[0010] The solution provided in the first aspect above can support storing multiple data to be stored in one storage page. For example, it can support storing multiple data to be stored in one storage page at the same time; for another example, it can support storing multiple data to be stored in the same storage page multiple times. Based on this, under the premise of ensuring the normal storage of the data to be stored, the utilization rate of the remaining storage area of the target storage page can be maximized, thereby extending the life of the storage module.
[0011] As a possible implementation, the data to be stored corresponding to the above-mentioned multiple data storage requests include first data and second data, and the above-mentioned storing at least two NvM blocks of the multiple NvM blocks in the first storage page includes: encapsulating the first data into the first NvM block, and encapsulating the second data into the second NvM block; encapsulating the first NvM block and the second NvM block into the first Fee block; and storing the first Fee block in the first storage page. In this way, multiple data to be stored can be stored in one storage page by encapsulating the multiple data to be stored into the same Fee block and then storing them in one storage page. Under the premise of ensuring the normal storage of the data to be stored, the utilization rate of the remaining storage area of the target storage page is maximized, and the life of the storage module is extended.
[0012] As a possible implementation, the data to be stored corresponding to the above-mentioned multiple data storage requests include first data and second data, and the above-mentioned storing at least two NvM blocks of the multiple NvM blocks in the first storage page includes: encapsulating the first data into the first NvM block and then into the first Fee block, encapsulating the second data into the second NvM block and then into the second Fee block; storing the first Fee block and the second Fee block in the first storage page. In this way, by encapsulating the multiple data to be stored in different Fee blocks and then storing them in one storage page, it is possible to store the multiple data to be stored in one storage page, and on the premise of ensuring the normal storage of the data to be stored, the utilization rate of the remaining storage area of the target storage page is maximized, and the life of the storage module is extended.
[0013] As a possible implementation, the data storage requests corresponding to the first data and the second data are received at the same time. In this way, the solution provided by the present application can support storing multiple data to be stored in the same storage page according to multiple data storage requests occurring simultaneously, for example, multiple data to be stored can be stored in the same storage page by encapsulating them in the same Fee block and then storing them in one storage page, or by encapsulating them in different Fee blocks and then storing them in one storage page.
[0014] In some examples, the data storage requests corresponding to the first data and the second data may also be initiated simultaneously, such as being initiated simultaneously by an application in a software component (SWC).
[0015] As a possible implementation, the data storage requests corresponding to the first data and the second data are received at different times. In this way, the solution provided by the present application can support storing multiple data to be stored in the same storage page according to multiple data storage requests that occur at different times. For example, multiple data to be stored can be stored in the same storage page by encapsulating them into different Fee blocks and then storing them in one storage page.
[0016] As a possible implementation, the data to be stored corresponding to the above-mentioned multiple data storage requests also include third data, and the above-mentioned method also includes: encapsulating the third data into the third NvM block and then encapsulating it into the first Fee block, wherein the first Fee block includes a first part and a second part, the first part includes the first NvM block and the second NvM block, and the second part includes the third NvM block; storing the above-mentioned second part in the second storage page, wherein the above-mentioned first part is stored in the first storage page. In this way, it can support storing different parts of a Fee block encapsulated with multiple data to be stored in different storage pages respectively, so as to ensure diversified data storage requirements.
[0017] As a possible implementation, the first storage page is one of a plurality of available storage pages, the length of the remaining storage area of the first storage page is a first length, the length of the Fee block encapsulating the at least two NvM blocks is a second length, and the first length is greater than or equal to the second length. For example, a suitable target storage page for storing data can be selected according to the length of the Fee block where the at least two NvM blocks are located and the length of the remaining storage area of a plurality of available storage pages, so as to maximize the utilization rate of the remaining storage area of the target storage page and extend the life of the storage module.
[0018] As a possible implementation method, multiple NvM blocks can be reasonably combined according to the length of at least two NvM blocks and the length of the remaining storage area of multiple available storage pages, and a suitable target storage page can be selected to maximize the utilization rate of the remaining storage area of the target storage page and extend the life of the storage module.
[0019] As a possible implementation, the storage length corresponding to the first storage page is the third length, and the third length is equal to the first length. That is, the present application supports storing multiple data to be stored in the same blank storage page.
[0020] As a possible implementation, the storage length corresponding to the first storage page is the third length, the third length is less than the first length, and the at least two NvM blocks among the multiple NvM blocks are stored in the first storage page, including: obtaining the fourth length of the used storage area of the first storage page; writing the Fee block encapsulating the at least two NvM blocks into the first byte Q1 to the second byte Q2 of the first storage page, where Q1 = the third length - the fourth length, Q2 = the third length - the fourth length + the second length - 1. In this way, the data to be stored can be written into a non-blank page based on the overwrite mechanism to support storing multiple data to be stored in the same storage page, thereby improving the utilization rate of the target storage page while extending the life of the storage module.
[0021] As a possible implementation, the difference between the first length and the second length is less than the first threshold. In this way, the target storage page that is most conducive to the utilization of the storage page can be selected according to the sum of the lengths of at least two NvM blocks and the length of the remaining storage area of multiple available storage pages, so as to maximize the utilization of the remaining storage area of the target storage page and extend the life of the storage module.
[0022] As a possible implementation, the method further includes: recording the storage information of the first data after storing the first data, wherein the storage information of the first data includes the identifier of the Fee block where the first data is located and the identifier of the NvM block where the first data is located; upon receiving a request to read the first data, obtaining the first Fee block where the first data is located from the stored multiple Fee blocks according to the storage information of the first data and the identifiers and length information of the stored multiple Fee blocks; obtaining the number identifier, the identifier and the length information of the NvM blocks encapsulated in the first Fee block; obtaining the first NvM block where the first data is located from the first Fee block according to the storage information of the first data and the number identifier, the identifier and the length information of the NvM blocks encapsulated in the first Fee block, and parsing the first NvM block to obtain the first data. In this way, by recording the storage information of the data, it is convenient to read the target data more quickly and accurately based on this when reading the data subsequently.
[0023] As a possible implementation, the first Fee block is written for the i-th time, where i is an integer and i>1, and the method further includes: when the acquisition of the first data fails, acquiring the storage page information of the Fee block written for the i-1th time related to the first Fee block; and acquiring the data encapsulated in the Fee block written for the i-1th time related to the first Fee block according to the storage page information. In this way, by recording the storage information of the data, data rollback can be facilitated when subsequent data reading fails.
[0024] In a second aspect, a data reading method is provided, the method comprising: in response to a request to read first data, obtaining identification and length information of multiple stored Fee blocks, wherein the multiple Fee blocks include a first Fee block; obtaining a first Fee block where the first data is located from the multiple stored Fee blocks according to the storage information of the first data and the identification and length information of the multiple stored Fee blocks, wherein the storage information of the first data is recorded after the storage of the first data is completed, and the storage information of the first data includes the identification of the Fee block where the first data is located and the identification of the NvM block where the first data is located; obtaining the number identification of the NvM blocks encapsulated in the first Fee block, the identification and length information of the NvM blocks; obtaining the first data from the first Fee block according to the storage information of the first data and the number identification of the NvM blocks encapsulated in the first Fee block, the identification and length information of the NvM blocks, and when obtaining the first data fails, obtaining storage page information of the Fee block written for the i-1th time related to the first Fee block, and obtaining data encapsulated in the Fee block written for the i-1th time related to the first Fee block according to the storage page information, wherein i is an integer and i>1.
[0025] As an example, the method can be applied to the field of vehicle-mounted technology, such as on a domain controller and other devices capable of data processing and storage. The domain controller may include but is not limited to an intelligent driving domain controller, a cockpit domain controller, a chassis domain controller, a power domain controller, a thermal management controller, a body domain controller, etc.
[0026] As an example, the above-mentioned domain controller and other devices capable of data processing and storage may store data through a flash memory (Flash), for example, by storing data through a plurality of flash memory pages (ie, storage pages) of the flash memory.
[0027] Of course, the method can also be applied to other technical fields of storing data through multiple storage pages of a storage module, and this application does not make any specific limitation.
[0028] The solution provided in the second aspect can facilitate data rollback when subsequent data reading fails by recording data storage information. For example, when data reading fails, the storage page, Fee block, and NvM block where the most recently written data related to the target Fee block is located can be determined more quickly and accurately, and the target data can be read quickly and accurately therefrom.
[0029] As a possible implementation, the above-mentioned obtaining the first data from the first Fee block according to the storage information of the first data and the number identifier of the NvM blocks encapsulated in the first Fee block, the identifier and the length information of the NvM block includes: obtaining the first NvM block where the first data is located from the first Fee block according to the storage information of the first data and the number identifier of the NvM blocks encapsulated in the first Fee block, the identifier and the length information of the NvM block; parsing the first NvM block to obtain the first data. In this way, by recording the storage information of the data, it is convenient to read the target data more quickly and accurately based on this when the subsequent data is read. For example, it is convenient to determine the storage page, the Fee block and the NvM block where the target data is located more quickly and accurately based on the recorded storage information of the data, and then quickly and accurately read the target data therefrom.
[0030] In a third aspect, a data storage device is provided, the device comprising: a memory for storing computer program instructions and data; a processor for executing the computer program instructions to support the data storage device to implement the method described in any possible implementation of the first aspect or the second aspect.
[0031] In a fourth aspect, a vehicle or other means of transport is provided, which may include the data storage device as described in the third aspect, so as to implement the method described in any possible implementation of the first aspect or the second aspect.
[0032] In a fifth aspect, a computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method in any possible implementation of the first aspect or the second aspect is implemented.
[0033] In a sixth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to implement a method in any possible implementation of the first aspect or the second aspect.
[0034] In a seventh aspect, a chip system is provided, the chip system comprising a processing circuit and a storage medium, wherein the storage medium stores computer program instructions; when the computer program instructions are executed by the processor, the method in any possible implementation of the first aspect or the second aspect is implemented. The chip system may be composed of a chip, or may include a chip and other discrete devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a schematic diagram of a conventional non-volatile storage management system architecture;
[0036] Figure 2 A schematic diagram of a conventional data storage solution;
[0037] Figure 3 A schematic diagram of a data storage effect achieved based on a conventional data storage solution;
[0038] Figure 4 A schematic diagram of a domain controller system architecture provided in an embodiment of the present application;
[0039] Figure 5 A schematic diagram of another domain controller system architecture provided in an embodiment of the present application;
[0040] Figure 6 The data storage method provided in the embodiment of the present application Figure 1 ;
[0041] Figure 7 An example of a data storage process provided in the embodiment of the present application Figure 1 ;
[0042] Figure 8 An example of a data storage process provided in the embodiment of the present application Figure 2 ;
[0043] Fig. 9 An example of a data storage process provided in the embodiment of the present application Figure 3 ;
[0044] Fig.10 A schematic diagram of an overwriting mechanism provided in an embodiment of the present application;
[0045] Fig.11 A schematic diagram of an overwriting process provided in an embodiment of the present application;
[0046] Fig.12 A schematic diagram of a circular queue provided in an embodiment of the present application;
[0047] Fig.13 A flow chart of a method for creating and updating a circular queue provided in an embodiment of the present application;
[0048] Fig.14 The data storage method provided in the embodiment of the present application Figure 2 ;
[0049] Fig.15 A schematic diagram of a data rollback mechanism provided in an embodiment of the present application;
[0050] Fig.16 An example of a data storage process provided in the embodiment of the present application Figure 4 ;
[0051] Fig.17 An example of a data storage process provided in the embodiment of the present application Figure 5 ;
[0052] Fig.18 The data storage method provided in the embodiment of the present application Figure 3 ;
[0053] Fig.19 An example of a data storage process provided in the embodiment of the present application Figure 6 ;
[0054] Fig. 20 The data storage method provided in the embodiment of the present application Figure 4 ;
[0055] Fig.21 An example of a data storage process provided in the embodiment of the present application Figure 7 ;
[0056] Fig. 22 An example of a data storage process provided in the embodiment of the present application Figure 8 ;
[0057] Fig.23 An example of a data storage process provided in the embodiment of the present application Figure 9 ;
[0058] Fig.24 The data storage method provided in the embodiment of the present application Figure 5 . DETAILED DESCRIPTION
[0059] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0060] In the following, the terms "first", "second", etc. are only used to distinguish different description objects, and have no limiting effect on the position, order, priority, quantity or content of the described objects. For example, if the described object is a "field", the ordinal number before the "field" in the "first field" and the "second field" does not limit the position or order between the "fields", and the "first" and "second" do not limit whether the "fields" they modify are in the same message, nor do they limit the order of the "first field" and the "second field". For another example, if the described object is a "level", the ordinal number before the "level" in the "first level" and the "second level" does not limit the priority between the "levels". For another example, the number of described objects is not limited by the ordinal number, and can be one or more. Taking the "first device" as an example, the number of "devices" can be one or more. In addition, the objects modified by different prefixes can be the same or different. For example, if the described object is a "device", the "first device" and the "second device" can be the same type of device or different types of devices. For another example, if the described object is "information", the "first information" and the "second information" can be information of the same content or information of different contents. In summary, the use of prefixes such as ordinal numbers to distinguish the described objects in the embodiments of the present application does not constitute a limitation on the described objects. For the statement of the described objects, please refer to the description in the context of the claims or embodiments, and no unnecessary limitation should be constituted due to the use of such prefixes.
[0061] Furthermore, in the embodiments of the present application, "connection" may be a direct connection or an indirect connection; in addition, it may refer to an electrical connection or a communication connection; for example, the connection between two electrical components A and B may refer to a direct connection between A and B, or may refer to an indirect connection between A and B through other electrical components or connecting media, or may refer to an indirect connection between A and B through other communication devices or communication media, as long as communication between A and B can be achieved.
[0062] As mentioned above, AUTOSAR provides a hierarchical non-volatile storage mechanism, based on which the data to be stored can be encapsulated into blocks and stored separately in one or more Flash pages, where Block is the smallest unit of flash memory erasure, and Flash page is the storage unit of flash memory.
[0063] In some examples, the flash memory may be NOR Flash. NOR Flash is a fast, random read and write flash memory, which is mainly used to store data that needs to be read quickly, such as program code and firmware. The principle of NOR Flash is to store data in storage units (also called "storage pages", which are uniformly referred to as "storage pages" in the following embodiments). Each storage page has an independent address. When reading and writing data, a separate storage page can be read and written based on the address of the storage page, so the addressing and reading and writing speeds are faster.
[0064] As an example, when the controller used by AUTOSAR is a microcontroller unit (MCU), the flash memory of the MCU is usually a NOR Flash built into the MCU. Based on the built-in NOR Flash provided by the MCU, the MCU can encapsulate the data to be stored into blocks and store them in blank storage pages in the Flash.
[0065] For example, the non-volatile storage management system architecture of AUTOSAR is Figure 1 As shown, software components (SWC), runtime environment (RTE), storage stack and Flash are taken as examples. Figure 2 As shown, RTE can pass the data storage request initiated by SWC to the storage stack, and the storage stack writes the data to be stored into a blank storage page in the Flash of the hardware device after encapsulating it.
[0066] As an example, Figure 1 As shown, the storage stack may include a non-volatile memory manager (NVRAM manager, NvM) module, a flash EEPROM emulation (Flash EEPROM Emulation, Fee) module and a flash driver (Fls) module. When the storage stack encapsulates the data to be stored, one piece of data to be stored will be individually encapsulated into an NvM Block (block) and then encapsulated into a Fee Block. For example, Figure 2As shown, first, the NvM module of the storage stack can encapsulate the first data to be stored into the first NvM Block and then pass it to the Fee module, and then the Fee module can encapsulate the first NvM Block into the first Fee Block and pass it to the Fls module; finally, the Fls module of the storage stack can store the first Fee Block in a blank storage page in the Flash, for example, the Fls module can store the first FeeBlock in one or more blank storage pages in the Flash.
[0067] The data to be stored include Figure 3 Take data 1, data 2 and data 3 as examples. Figure 3 As shown, based on Figure 2 In the non-volatile storage mechanism shown in FIG. 1 , the NvM module can add NvM data headers and NvM data tails to the beginning and end of data 1, data 2, and data 3 to be stored, respectively, and then encapsulate them into NvM Block 1, NvM Block 2, and NvM Block 3, respectively, and then pass them to the Fee module; the Fee module can add Fee data headers and Fee data tails to the beginning and end of NvM Block 1, NvM Block 2, and NvM Block 3, respectively, and then encapsulate them into NvM Fee 1, NvM Fee 2, and NvM Fee 3, respectively, and then store them in three blank storage pages of the Flash (such as Figure 3 As shown, storage page 1, storage page 2 and storage page n, where n is a positive integer greater than 2).
[0068] With the evolution of E / E architecture, controllers have gradually evolved from MCU to SoC. SoCs mostly use external NOR Flash, such as SPI NOR Flash. Among them, the storage page length of external NOR Flash (such as SPI NOR Flash) is usually larger than that of built-in NOR Flash. Figure 2 The non-volatile storage mechanism shown is used for data storage. Regardless of whether the length of the FeeBlock is long or short, a Fee Block occupies at least one storage page. For example, Figure 3 As shown, assuming Figure 3 The storage page shown is SPI NOR Flash. Although the length of the Fee Block corresponding to Data 2 and Data 3 is very short, based on Figure 2 The non-volatile storage mechanism shown in the figure still occupies a storage page. For example, the storage page length of SPI NOR Flash is usually large, so Figure 2The conventional data storage mechanism shown not only wastes storage resources, but also increases the number of erase and write times of storage pages, thereby reducing the life of the Flash, because the number of erase and write times of the Flash is usually limited.
[0069] In order to reduce the waste of storage resources, improve the utilization rate of storage resources and increase the life of Flash, an embodiment of the present application provides a data storage method, which can support storing data to be stored in non-blank storage pages, such as storing one data to be stored in a non-blank storage page, or storing multiple data to be stored in non-blank storage pages, wherein a blank storage page (hereinafter referred to as "blank page") refers to a storage page in which no data is stored, and correspondingly, a non-blank storage page (hereinafter referred to as "non-blank page") refers to a storage page in which data is stored. Of course, the method can also support storing data to be stored in a blank page.
[0070] For example, if the difference between the length of the remaining storage area of a blank page and the length of the Fee block encapsulating the data to be stored is less than the first threshold, or if the length of the Fee block encapsulating the data to be stored can occupy a first preset proportion K1 (such as 90%) of a blank page, the Fee block can be stored in the blank page; if the difference between the length of the remaining storage area of a non-blank page and the length of the Fee block encapsulating the data to be stored is less than the first threshold, or if the length of the Fee block encapsulating the data to be stored can occupy a second preset proportion K2 (such as 80%) of the length of the remaining storage area of a non-blank page, the Fee block can be stored in the non-blank page.
[0071] In some embodiments, the data storage method provided in the embodiments of the present application can store multiple data to be stored in one storage page.
[0072] For example, a plurality of Fee blocks respectively encapsulating one or more data to be stored may be stored in a blank page or a non-blank page; or in another example, a Fee block encapsulating a plurality of data to be stored may be stored in a blank page or a non-blank page.
[0073] In some embodiments, the data storage method provided in the embodiments of the present application can realize storing multiple data to be stored in multiple storage pages.
[0074] For example, multiple parts of a Fee block encapsulating multiple data to be stored may be stored in multiple storage pages, wherein any storage page in the multiple storage pages is a blank page or a non-blank page. Taking the example of storing a Fee block encapsulating three data to be stored (such as data 1, data 3, and data 3) in two storage pages, for example, the first part of the Fee block encapsulating data 1, data 3, and data 3 may be stored in storage page 1, and the second part may be stored in storage page 2, wherein the first part of the Fee block includes data 1, and the second part of the Fee block includes data 2 and data 3, or the first part of the Fee block includes data 1 and data 2, and the second part of the Fee block includes data 3, wherein storage page 1, storage page 2, and storage page 3 may all be blank pages or non-blank pages.
[0075] In some embodiments, the data storage method provided in the embodiments of the present application can also realize storing a piece of data to be stored in multiple storage pages.
[0076] For example, multiple parts of a Fee block encapsulating data to be stored may be stored in multiple storage pages, wherein the multiple storage pages include blank pages and / or non-blank pages. Taking the example of storing a Fee block encapsulating one data to be stored in two storage pages, for example, the first part of the Fee block encapsulating data to be stored may be stored in a blank page, and the second part may be stored in a non-blank page. For another example, the first part of the Fee block encapsulating data to be stored may be stored in a blank page, and the second part may be stored in another blank page. For another example, the first part of the Fee block encapsulating data to be stored may be stored in a non-blank page, and the second part may be stored in another non-blank page.
[0077] Of course, in some embodiments, the data storage method provided based on the embodiments of the present application can realize storing a data to be stored in a storage page, for example, a Fee block encapsulated with a data to be stored can be stored in a blank page or a non-blank page.
[0078] As an example, the data storage method provided in the embodiment of the present application can be applied to a domain controller, such as a domain controller on a vehicle. The processor in the domain controller can be a SoC.
[0079] Among them, the vehicle described in the embodiments of the present application is a broad concept, and can be any means of transport, such as land vehicles, water vehicles, air vehicles, industrial equipment, agricultural equipment or entertainment equipment, etc. For example, the vehicle described in the embodiments of the present application can be a vehicle (such as a car, bus, subway, high-speed rail, motorcycle, flying car, train, etc.), an industrial vehicle (such as a forklift, trailer, tractor, etc.), an engineering vehicle (such as an excavator, a bulldozer, a crane, etc.), agricultural equipment (such as a mower, a harvester, etc.), amusement equipment, a toy vehicle, a ship, an air cushion vehicle, a submarine, an airplane, a helicopter, etc. The embodiments of the present application do not limit the specific type, form and function of the vehicle.
[0080] In some examples, the domain controller can be divided into several areas (also called "functional domains") according to the functions of various parts of the vehicle, such as intelligent driving domain, cockpit domain, chassis domain, power domain, body domain, etc. Based on this, the on-board domain controller may include but is not limited to any one or more of the following: intelligent driving domain controller, cockpit domain controller, chassis domain controller, power domain controller, thermal management controller, and body domain controller.
[0081] Among them, the intelligent driving domain is mainly used to provide autonomous driving perception, decision-making and other services, such as image information reception, image information processing and judgment, data processing and calculation, navigation and route planning, and rapid judgment and decision-making for real-time situations. The intelligent driving domain needs to process algorithms at the three levels of perception, decision-making, and control, and has the highest requirements for the hardware and software of the domain controller. The cockpit domain is mainly used to control various electronic information system functions in the vehicle's intelligent cockpit, such as the central control system, in-vehicle infotainment system, head-up display, seat system, instrument system, rearview mirror system, driving behavior monitoring system, navigation system, etc. The chassis domain is mainly used to control the vehicle's driving behavior and driving posture. Its functions include but are not limited to brake system management, vehicle transmission system management, driving system management, steering system management, vehicle speed sensor management, body posture sensor management, air suspension system management, airbag system management, etc. The power domain is mainly used to control the vehicle's powertrain, optimize the vehicle's power performance, and ensure the vehicle's power safety, such as engine management, gearbox management, battery management, power distribution management, emission management, speed limit management, fuel saving and power saving management, etc. The body domain is mainly used to control various body functions, including but not limited to the control of headlights, taillights, interior lights, door locks, windows, sunroofs, wipers, electric trunks, smart keys, air conditioners, antennas, gateway communications, etc.
[0082] Please refer to Figure 4 , Figure 4 FIG. 1 shows a schematic diagram of a domain controller system architecture for implementing a data storage method provided by an embodiment of the present application. Figure 6 As shown, the domain controller may include SWC, RTE, storage stack and Flash from top to bottom.
[0083] Among them, Flash is a hardware storage device for storing data. Among them, Flash can include multiple storage pages, such as Flash page (flash memory page), and the storage page can be used to store data. Each storage page has an independent address. When storing and reading data, a separate storage page can be read and written based on the address of the storage page, so the addressing and reading and writing speeds are faster.
[0084] As an example, Figure 4 The Flash shown may include but is not limited to flash memories such as NOR Flash.
[0085] SWC may include a series of in-vehicle applications or functions (hereinafter collectively referred to as "in-vehicle applications"). For example, the in-vehicle applications may include but are not limited to navigation, automatic driving, automatic parking and other applications, which are not limited in the embodiments of the present application.
[0086] In the embodiment of the present application, the vehicle-mounted application in the SWC can initiate a data storage request or a data read request, wherein the data storage request is used to request to store the application data of the vehicle-mounted application, and the data read request is used to request to read the stored application data of the vehicle-mounted application. For example, the application data may include but is not limited to autonomous driving data, vehicle driving data, road image data, etc., which are not specifically limited in the embodiment of the present application.
[0087] RTE can be used to pass data storage requests or data reading requests initiated by the vehicle application in SWC to the storage stack so that the storage stack can perform subsequent data storage or data reading processes.
[0088] As a non-volatile memory manager, the storage stack can encapsulate the data to be stored and write it into the Flash when receiving a data storage request. Alternatively, the storage stack can obtain the target data from the stored data when receiving a data read request. As an example, Figure 4 As shown, the storage stack may include an NvM module, a Fee module, and an Fls module.
[0089] in, Figure 4 The NvM module shown can be used to encapsulate the data to be stored into the NvM Block when receiving a data storage request. For example, the NvM module can add an NvM data header to the header of the data to be stored, add an NvM data tail to the tail of the data to be stored, and then encapsulate it into the NvM Block and pass it to the Fee module, wherein the NvM data header carries the identification and length information of the NvM Block, and the NvM data tail can carry but is not limited to the integrity identification of the data to be stored, such as a cyclic redundancy check (CRC) check value, etc.
[0090] In some embodiments, Figure 4 As shown, the NvM module can also be used to receive (such as through Figure 4 When the MemIf module receives the target Fee Block read by the Fee module from the Flash, the target data is read from the Fee Block according to the NvM data header and NvM data tail of the NvM Block in the Fee Block, such as determining the target NvM Block where the target data is located according to the identifier of the NvM Block, and determining the offset address of the target data in the target NvM Block according to the length information of the NvM Block, and then parsing the target data therefrom and passing it to the corresponding in-vehicle application in the SWC.
[0091] In some embodiments, Figure 4 As shown, the storage stack may further include a memory abstraction interface (MemIf) module. After completing the NvM Block encapsulation, the NvM module may pass the NvM Block to the Fee module through the MemIf module; and the NvM module may receive the target FeeBlock from the Fee module through the MemIf module.
[0092] Figure 4 The Fee module shown can be used to encapsulate the NvM Block from the NvM module into the Fee Block. For example, the Fee module can add a Fee data header to the NvM Block header and a Fee data tail to the NvM Block tail, and then encapsulate it into the Fee Block and store it in the Flash. For example, the Fee Block is stored in the Flash through the Fls module, wherein the Fee data header carries the Fee Block identifier, length information, and the number of NvM Blocks encapsulated in the Fee Block, and the Fee data tail carries a devil number, write count, and migration count, etc., wherein the devil number is used to identify the data tail of the Fee Block, the write count is used to count the cumulative number of writes of the Fee Block during its life cycle, and the migration count is used to count the cumulative number of migrations of the Fee Block during its life cycle.
[0093] In the embodiment of the present application, the Fee module may support encapsulating multiple NvM Blocks into one Fee Block, and may also support encapsulating one NvM Block into one Fee Block.
[0094] In the embodiments of the present application, Figure 4The Fee module shown can support storing Fee Block in a blank page, and can also support storing Fee Block in a non-blank page. For example, the Fee module can support storing a Fee Block encapsulating multiple NvM Blocks in a blank page or in a non-blank page; for another example, the Fee module can support storing a Fee Block encapsulating multiple NvM Blocks in multiple storage pages, the multiple storage pages including at least one blank page and / or at least one non-blank page; for another example, the Fee module can support storing a Fee Block encapsulating one NvM Block in at least one blank page and / or at least one non-blank page.
[0095] In some embodiments, Figure 4 The Fee module shown can also be used to record storage information of stored data.
[0096] As an example, the storage information of the stored data may include an identifier of the NvM block where the stored data is located and an identifier of the Fee block where the stored data is located, so as to facilitate quick and accurate reading of subsequent data.
[0097] As an example, the storage information of the stored data may also include the most recent S (S is an integer greater than 1) write addresses (such as the identifier of the storage page) corresponding to the Fee block where the stored data is located and the corresponding data write location index (CurrentIndex), so as to facilitate data rollback when subsequent data reading fails.
[0098] In some embodiments, Figure 4 The Fee module shown can also be used to obtain the target Fee Block from the Flash when receiving a data read request based on the recorded storage information and the Fee data header and Fee data tail of the Fee Block, such as determining the target Fee Block where the target data is located based on the Fee Block identifier and the number of NvM Blocks, obtaining the target storage page from the Flash through the Fls module, and determining the offset address of the target FeeBlock encapsulating the target data in the target storage page based on the length information of the Fee Block, and then parsing the target Fee Block therefrom and passing it to the NvM module.
[0099] In some embodiments, Figure 5As shown, the NvM module may include a first NvM module and a second NvM module; the Fee module may include a first Fee module and a second Fee module. The first NvM module is used to encapsulate multiple data to be stored into multiple NvM Blocks and pass them to the first Fee module when the NvM module receives multiple data storage requests at the same time; the second NvM module is used to encapsulate the data to be stored into an NvM Block and pass it to the second Fee module when the NvM module receives a data storage request. The first Fee module is used to encapsulate multiple of the multiple NvM Blocks from the first NvM module into one Fee Block, and finally encapsulate the multiple NvM Blocks into one or more Fee Blocks and store them in at least one blank page and / or at least one non-blank page in the Flash; the second Fee module is used to encapsulate an NvMBlock from the second NvM module into a Fee Block and store it in at least one blank page and / or at least one non-blank page in the Flash.
[0100] In some embodiments, Figure 5 As shown, the Fee module can also include a rollback module for recording storage information of stored data, such as the identifier of the NvM block where the stored data is located and the identifier of the Fee block where the stored data is located, and the most recent S write addresses corresponding to the Fee block where the stored data is located and the corresponding data write position index.
[0101] The data storage method provided in the embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0102] Please refer to Figure 6 ,like Figure 6 A flow chart of a data storage method provided by an embodiment of the present application is shown, wherein: Figure 6 The data storage method shown can be applied to a storage stack, a domain controller, or other processing modules on a vehicle without specific limitation. Figure 6 As shown, the data storage method can be implemented based on S601-S602:
[0103] S601: In response to multiple data storage requests, encapsulate the to-be-stored data corresponding to the multiple data storage requests into multiple NvM blocks.
[0104] by Figure 4 or Figure 5 Taking the system structure shown as an example, the data storage request is initiated by the SWC, and the RTE can pass the data storage request to the storage stack after receiving the data storage request.
[0105] In some embodiments, the data to be stored corresponding to the multiple data storage requests are encapsulated into multiple NvM blocks, such as encapsulating the data to be stored corresponding to the multiple data storage requests into different multiple NvM blocks respectively.
[0106] Taking multiple data storage requests including a first data storage request, a second data storage request,..., and a kth data storage request (k is a positive integer greater than 2), where the first data storage request, the second data storage request,..., and the kth data storage request are respectively used to request storage of first data, second data,..., and kth data as an example, in response to the multiple data storage requests, the first data can be encapsulated into a first NvM block, the second data can be encapsulated into a second NvM block,..., and the kth data can be encapsulated into a kth NvM block.
[0107] In some embodiments, multiple data storage requests occur simultaneously, for example, multiple data storage requests are initiated simultaneously by the SWC; or, for example, multiple data storage requests are received simultaneously by the storage stack.
[0108] In some embodiments, the multiple data storage requests do not occur simultaneously. For example, the multiple data storage requests are initiated by the SWC at different times; or, for example, the multiple data storage requests are received by the storage stack at different times.
[0109] In some embodiments, some of the multiple data storage requests occur simultaneously, and some of the requests do not occur simultaneously with other requests. For example, at least two of the multiple data storage requests are initiated by the SWC at a first time, and one or more of the data storage requests are initiated by the SWC at one or more other times; for another example, at least two of the multiple data storage requests are received by the storage stack at a first time, and one or more of the data storage requests are received by the storage stack at one or more other times.
[0110] S602: Store at least two NvM blocks among the plurality of NvM blocks in a first storage page, and store at least one NvM block among the plurality of NvM blocks in a second storage page.
[0111] The first storage page and the second storage page are storage pages among a plurality of available storage pages of the Flash.
[0112] In some embodiments, the first storage page is a first target storage page that satisfies a first condition and is determined from one or more available storage pages of the Flash based on the length (or the sum of the lengths) of the Fee blocks where at least two of the multiple NvM blocks are located, and the length of the remaining storage area of the one or more available storage pages of the Flash. For example, the first condition is such that the length of the remaining storage area of the first storage page is greater than or equal to the length (or the sum of the lengths) of the Fee blocks where at least two of the multiple NvM blocks are located; for another example, the first condition is such that the length of the remaining storage area of the first storage page is greater than or equal to the length (or the sum of the lengths) of the Fee blocks where at least two of the multiple NvM blocks are located, and the difference between the length of the remaining storage area of the first storage page and the length (or the sum of the lengths) of the Fee blocks where at least two of the multiple NvM blocks are located is less than a first threshold.
[0113] Similarly, the second storage page is a second target storage page that satisfies the second condition and is determined from one or more available storage pages of the Flash based on the length (or the sum of the lengths) of the Fee block where at least one of the multiple NvM blocks is located and the length of the remaining storage area of the one or more available storage pages of the Flash. For example, the second condition is such that the length of the remaining storage area of the second storage page is greater than the length (or the sum of the lengths) of the Fee block where at least one of the multiple NvM blocks is located; for another example, the second condition is such that the length of the remaining storage area of the second storage page is greater than or equal to the length (or the sum of the lengths) of the Fee block where at least one of the multiple NvM blocks is located, and the difference between the length of the remaining storage area of the second storage page and the length (or the sum of the lengths) of the Fee block where at least one of the multiple NvM blocks is located is less than the first threshold.
[0114] In some embodiments, the first storage page is a blank page. For example, the length of the remaining storage area of the first storage page is the first length, and the storage length corresponding to the first storage page is the third length. The first length satisfies: the first length = the third length, that is, the first storage page currently does not store data, and the first storage page is a blank page.
[0115] In some embodiments, the first storage page is a non-blank page. Taking the case where the length of the remaining storage area of the first storage page is the first length and the storage length corresponding to the first storage page is the third length as an example, the first length satisfies: the first length < the third length, that is, data is currently stored in the first storage page, and the first storage page is a non-blank page.
[0116] In some embodiments, the second storage page is a blank page. For example, if the length of the remaining storage area of the second storage page is the fifth length and the storage length corresponding to the fifth storage page is the sixth length, the fifth length satisfies: the fifth length = the sixth length, that is, the second storage page currently does not store data, and the second storage page is a blank page.
[0117] In some embodiments, the second storage page is a non-blank page. For example, if the length of the remaining storage area of the second storage page is the fifth length and the storage length corresponding to the fifth storage page is the sixth length, the fifth length satisfies: the fifth length = the sixth length, that is, data is currently stored in the second storage page, and the second storage page is a non-blank page.
[0118] Among them, the multiple data storage requests corresponding to at least two of the multiple NvM blocks stored in the first storage page may occur simultaneously or not simultaneously, which is not specifically limited in the embodiments of the present application. For example, the multiple data storage requests corresponding to the at least two NvM blocks all occur simultaneously; for another example, the multiple data storage requests corresponding to the at least two NvM blocks do not occur simultaneously; for another example, at least two of the multiple data storage requests corresponding to the at least two NvM blocks occur simultaneously, and at least one does not occur simultaneously with other requests.
[0119] As an example, S602 may specifically include the following cases 1 to 5:
[0120] Case 1: encapsulate multiple NvMs into different Fee blocks, and then store the multiple Fee blocks in the first storage page.
[0121] For example, if the data storage requests corresponding to the multiple NvM blocks do not occur simultaneously, the multiple NvM blocks can be respectively encapsulated into different Fee blocks, and then the multiple Fee blocks are stored in the first storage page. Of course, if the data storage requests corresponding to the multiple NvM blocks occur simultaneously, or if at least two of the multiple data storage requests corresponding to the multiple NvM blocks occur simultaneously, and at least one does not occur simultaneously with other requests, the multiple NvM blocks can also be respectively encapsulated into different Fee blocks and then stored in the first storage page, without specific limitation.
[0122] As an example, the first storage page satisfies the first condition. For example, the first storage page satisfies the first condition such as the first length ≥ the seventh length, where the seventh length is the sum of the lengths of the Fee blocks where the multiple NvM blocks are located. For another example, the first storage page satisfies the first condition such as the first length ≥ the seventh length, and the difference between the first length and the seventh length is less than the first threshold; that is, the seventh length is close to the first length, based on which the utilization rate of the remaining storage area of the first storage page can be maximized.
[0123] Taking multiple data storage requests including a first data storage request and a second data storage request, the first data storage request and the second data storage request are used to request the storage of the first data and the second data respectively, and in response to the first data storage request and the second data storage request, the first data has been encapsulated into the first NvM block and the second data has been encapsulated into the second NvM block as an example, firstly, the first NvM block can be encapsulated into the first Fee block and the second NvM block can be encapsulated into the second Fee block; then, the target storage page can be selected from multiple available storage pages of the Flash, such as the first storage page that satisfies the requirement that the length of the remaining storage area of the first storage page is ≥ the sum of the lengths of the first Fee block and the second Fee block, and the first storage page that satisfies the requirement that the length of the remaining storage area of the first storage page is ≥ the sum of the lengths of the first Fee block and the second Fee block, and the length of the remaining storage area of the first storage page - the sum of the lengths of the first Fee block and the second Fee block is < a first threshold; finally, the first Fee block and the second Fee block can be stored in the first storage page.
[0124] That is, a plurality of Fee blocks respectively encapsulating different NvM blocks may be stored in one storage page, wherein the one storage page may be a blank page or a non-blank page.
[0125] Case 2: encapsulate at least two NvM blocks among the multiple NvM blocks into different Fee blocks, and then store the multiple Fee blocks in the first storage page; and encapsulate at least one NvM block among the multiple NvM blocks into one Fee block, and then store the one Fee block in the second storage page.
[0126] Among them, the data storage requests corresponding to at least two of the above-mentioned multiple NvM blocks may occur simultaneously, or may not occur simultaneously, or there may be multiple simultaneous requests and at least one of them may not occur simultaneously with other requests; at least one of the above-mentioned multiple NvM blocks may occur simultaneously with any one of the at least two of the above-mentioned multiple NvM blocks, or may not occur simultaneously with at least two of the above-mentioned multiple NvM blocks, without specific limitation.
[0127] As an example, the first storage page satisfies the first condition, and the second storage page satisfies the second condition. For example, the first storage page satisfies the first condition such as the first length ≥ the second length, where the second length is the sum of the lengths of the Fee blocks where the multiple NvM blocks are located; the second storage page satisfies the second condition such as the fifth length ≥ the ninth length, where the ninth length is the sum of the lengths of the Fee blocks where at least one NvM block among the above multiple NvM blocks is located. For another example, the first storage page satisfies the first condition such as the first length ≥ the second length, and the difference between the first length and the second length is less than the first threshold; the second storage page satisfies the second condition such as the fifth length ≥ the ninth length, and the difference between the fifth length and the ninth length is less than the first threshold; that is, the second length is close to the first length, and the ninth length is close to the fifth length. Based on this, the utilization rate of the remaining storage area of the first storage page and the second storage page can be maximized.
[0128] Taking multiple data storage requests including a first data storage request, a second data storage request and a third data storage request, the first data storage request, the second data storage request and the third data storage request are used to request the storage of first data, second data and third data respectively, and in response to the first data storage request, the second data storage request and the third data storage request, the first data has been encapsulated into a first NvM block, the second data has been encapsulated into a second NvM block, and the third data has been encapsulated into a third NvM block as an example, firstly, the first NvM block can be encapsulated into a first Fee block, the second NvM block can be encapsulated into a second Fee block, and the third NvM block can be encapsulated into a third Fee block; then, a target storage page can be selected from multiple available storage pages of the Flash, such as the first storage page and the second storage page; finally, the first Fee block and the second Fee block can be stored in the first storage page, and the third Fee block can be stored in the second storage page. Among them, the length of the remaining storage area of the first storage page satisfies: the length of the remaining storage area of the first storage page ≥ the sum of the lengths of the first Fee block and the second Fee block, and the length of the remaining storage area of the second storage page satisfies: the length of the remaining storage area of the second storage page ≥ the length of the third Fee block; or, the length of the remaining storage area of the first storage page satisfies: the length of the remaining storage area of the first storage page ≥ the sum of the lengths of the first Fee block and the second Fee block, and the length of the remaining storage area of the first storage page - the sum of the lengths of the first Fee block and the second Fee block < the first threshold, and the length of the remaining storage area of the second storage page satisfies: the length of the remaining storage area of the second storage page ≥ the length of the third Fee block, and the length of the remaining storage area of the second storage page - the length of the third Fee block < the first threshold.
[0129] Alternatively, taking the case where multiple data storage requests include a first data storage request, a second data storage request, a third data storage request and a fourth data storage request, the first data storage request, the second data storage request, the third data storage request and the fourth data storage request are used to request the storage of first data, second data, third data and fourth data, respectively, and in response to the first data storage request, the second data storage request, the third data storage request and the fourth data storage request, the first data has been encapsulated into a first NvM block, the second data has been encapsulated into a second NvM block, the third data has been encapsulated into a third NvM block, and the fourth data has been encapsulated into a fourth NvM block as an example, first, the first NvM block can be encapsulated into a first Fee block, the second NvM block can be encapsulated into a second Fee block, and the third NvM block and the fourth NvM block can be encapsulated into a third Fee block; then, a target storage page can be selected from multiple available storage pages of the Flash, such as the first storage page and the second storage page; finally, the first Fee block and the second Fee block can be stored in the first storage page, and the third Fee block can be stored in the second storage page. Among them, the length of the remaining storage area of the first storage page satisfies: the length of the remaining storage area of the first storage page ≥ the sum of the lengths of the first Fee block and the second Fee block, and the length of the remaining storage area of the second storage page satisfies: the length of the remaining storage area of the second storage page ≥ the length of the third Fee block; or, the length of the remaining storage area of the first storage page satisfies: the length of the remaining storage area of the first storage page ≥ the sum of the lengths of the first Fee block and the second Fee block, and the length of the remaining storage area of the first storage page - the sum of the lengths of the first Fee block and the second Fee block < the first threshold, and the length of the remaining storage area of the second storage page satisfies: the length of the remaining storage area of the second storage page ≥ the length of the third Fee block, and the length of the remaining storage area of the second storage page - the length of the third Fee block < the first threshold.
[0130] That is, multiple Fee blocks respectively encapsulating multiple NvM blocks may be stored in multiple storage pages, wherein the multiple storage pages include blank pages and / or non-blank pages, and at least one of the multiple storage pages stores multiple NvM blocks.
[0131] Case 3: multiple NvMs are encapsulated into one Fee block, and then the one Fee block is stored in the first storage page.
[0132] For example, in the case where data storage requests corresponding to multiple NvM blocks occur simultaneously, the multiple NvM blocks can be encapsulated into one Fee block, and then the one Fee block is stored in the first storage page.
[0133] As an example, the first storage page satisfies the first condition. For example, the first storage page satisfies the first condition such as the first length ≥ the seventh length, where the seventh length is the length of the Fee block where the multiple NvM blocks are located. For another example, the first storage page satisfies the first condition such as the first length ≥ the seventh length, and the difference between the first length and the seventh length is less than the first threshold; that is, the seventh length is close to the first length, based on which, the utilization rate of the remaining storage area of the first storage page can be maximized.
[0134] Taking multiple data storage requests including a first data storage request and a second data storage request, the first data storage request and the second data storage request are used to request storage of the first data and the second data respectively, and in response to the first data storage request and the second data storage request, the first data has been encapsulated into the first NvM block and the second data has been encapsulated into the second NvM block as an example, firstly, the first NvM block and the second NvM block can be encapsulated into the first Fee block; then, the target storage page can be selected from multiple available storage pages of the Flash, such as the first storage page that satisfies the length of the remaining storage area of the first storage page ≥ the length of the first Fee block, and the first storage page that satisfies the length of the remaining storage area of the first storage page ≥ the length of the first Fee block, and the length of the remaining storage area of the first storage page - the length of the first Fee block < the first threshold; finally, the first Fee block can be stored in the first storage page.
[0135] That is, a Fee block encapsulating a plurality of NvM blocks may be stored in a storage page, wherein the storage page may be a blank page or a non-blank page.
[0136] Case 4: encapsulating at least two NvM blocks among multiple NvMs into one Fee block, and then storing the one Fee block in the first storage page; and encapsulating at least one NvM block among multiple NvM blocks into one Fee block, and then storing the one Fee block in the second storage page.
[0137] Among them, the data storage requests corresponding to at least two of the above-mentioned multiple NvM blocks may occur simultaneously; at least one of the above-mentioned multiple NvM blocks may occur simultaneously with any one of the at least two of the above-mentioned multiple NvM blocks, or may not occur simultaneously with at least two of the above-mentioned multiple NvM blocks, without specific limitation.
[0138] As an example, the first storage page satisfies the first condition, and the second storage page satisfies the second condition. For example, the first storage page satisfies the first condition such as the first length ≥ the second length, where the second length is the length of the Fee block where the multiple NvM blocks are located; the second storage page satisfies the second condition such as the fifth length ≥ the ninth length, where the ninth length is the sum of the lengths of the Fee blocks where at least one NvM block among the above multiple NvM blocks is located. For another example, the first storage page satisfies the first condition such as the first length ≥ the second length, and the difference between the first length and the second length is less than the first threshold; the second storage page satisfies the second condition such as the fifth length ≥ the ninth length, and the difference between the fifth length and the ninth length is less than the first threshold; that is, the second length is close to the first length, and the ninth length is close to the fifth length. Based on this, the utilization rate of the remaining storage area of the first storage page and the second storage page can be maximized.
[0139] Taking multiple data storage requests including a first data storage request, a second data storage request and a third data storage request, the first data storage request, the second data storage request and the third data storage request are used to request the storage of first data, second data and third data respectively, and in response to the first data storage request, the second data storage request and the third data storage request, the first data has been encapsulated into a first NvM block, the second data has been encapsulated into a second NvM block, and the third data has been encapsulated into a third NvM block as an example, firstly, the first NvM block and the second NvM block can be encapsulated into a first Fee block, and the third NvM block can be encapsulated into a second Fee block; then, a target storage page can be selected from multiple available storage pages of the Flash, such as the first storage page and the second storage page; finally, the first Fee block can be stored in the first storage page, and the second Fee block can be stored in the second storage page. Among them, the length of the remaining storage area of the first storage page satisfies: the length of the remaining storage area of the first storage page ≥ the length of the first Fee block, and the length of the remaining storage area of the second storage page satisfies: the length of the remaining storage area of the second storage page ≥ the length of the second Fee block; or, the length of the remaining storage area of the first storage page satisfies: the length of the remaining storage area of the first storage page ≥ the length of the first Fee block, and the length of the remaining storage area of the first storage page - the length of the first Fee block < the first threshold, and the length of the remaining storage area of the second storage page satisfies: the length of the remaining storage area of the second storage page ≥ the length of the third Fee block, and the length of the remaining storage area of the second storage page - the length of the third Fee block < the first threshold.
[0140] Alternatively, taking the case where multiple data storage requests include a first data storage request, a second data storage request, a third data storage request and a fourth data storage request, the first data storage request, the second data storage request, the third data storage request and the fourth data storage request are used to request the storage of first data, second data, third data and fourth data, respectively, and in response to the first data storage request, the second data storage request, the third data storage request and the fourth data storage request, the first data has been encapsulated into a first NvM block, the second data has been encapsulated into a second NvM block, the third data has been encapsulated into a third NvM block, and the fourth data has been encapsulated into a fourth NvM block as an example, first, the first NvM block and the second NvM block can be encapsulated into a first Fee block, and the third NvM block and the fourth NvM block can be encapsulated into a second Fee block; then, a target storage page can be selected from multiple available storage pages of the Flash, such as the first storage page and the second storage page; finally, the first Fee block can be stored in the first storage page, and the second Fee block can be stored in the second storage page. Among them, the length of the remaining storage area of the first storage page satisfies: the length of the remaining storage area of the first storage page ≥ the length of the first Fee block, and the length of the remaining storage area of the second storage page satisfies: the length of the remaining storage area of the second storage page ≥ the length of the second Fee block; or, the length of the remaining storage area of the first storage page satisfies: the length of the remaining storage area of the first storage page ≥ the length of the first Fee block, and the length of the remaining storage area of the first storage page - the length of the first Fee block < the first threshold, and the length of the remaining storage area of the second storage page satisfies: the length of the remaining storage area of the second storage page ≥ the length of the third Fee block, and the length of the remaining storage area of the second storage page - the length of the third Fee block < the first threshold.
[0141] That is, multiple Fee blocks respectively encapsulating multiple NvM blocks can be stored in multiple storage pages, where the multiple storage pages include blank pages and / or non-blank pages, and at least one of the multiple storage pages stores a Fee block encapsulating multiple NvM blocks.
[0142] Case 5: encapsulate at least two NvM blocks in a plurality of NvMs into one Fee block, then store a first portion of the one Fee block in a first storage page, and store a second portion of the one Fee block in a second storage page.
[0143] The data storage requests corresponding to at least two NvM blocks among the plurality of NvM blocks may occur simultaneously.
[0144] As an example, the first storage page satisfies the first condition, and the second storage page satisfies the second condition. For example, the first storage page satisfies the first condition such as the first length ≥ the eighth length, wherein the eighth length is the length of the first part of the Fee block where at least two of the above-mentioned multiple NvM blocks are located; the second storage page satisfies the second condition such as the fifth length ≥ the ninth length, wherein the ninth length is the length of the second part of the Fee block where at least two of the above-mentioned multiple NvM blocks are located. For another example, the first storage page satisfies the first condition such as the first length ≥ the eighth length, and the difference between the first length and the eighth length is less than the first threshold; the second storage page satisfies the second condition such as the fifth length ≥ the ninth length, and the difference between the fifth length and the ninth length is less than the first threshold; that is, the eighth length is close to the first length, and the ninth length is close to the fifth length. Based on this, the utilization rate of the remaining storage area of the first storage page and the second storage page can be maximized.
[0145] Taking multiple data storage requests including a first data storage request, a second data storage request and a third data storage request, the first data storage request, the second data storage request and the third data storage request are used to request the storage of first data, second data and third data respectively, and in response to the first data storage request, the second data storage request and the third data storage request, the first data has been encapsulated into a first NvM block, the second data has been encapsulated into a second NvM block, and the third data has been encapsulated into a third NvM block as an example, firstly, the first NvM block, the second NvM block and the third NvM block can be encapsulated into a first Fee block; then, a target storage page can be selected from multiple available storage pages of the Flash, such as the first storage page and the second storage page; finally, the first part of the first Fee block can be stored in the first storage page, and the second part of the first Fee block can be stored in the second storage page. Wherein, the length of the remaining storage area of the first storage page satisfies: the length of the remaining storage area of the first storage page ≥ the length of the first part of the first Fee block, the length of the remaining storage area of the second storage page satisfies: the length of the remaining storage area of the second storage page ≥ the length of the second part of the first Fee block; or, the length of the remaining storage area of the first storage page satisfies: the length of the remaining storage area of the first storage page ≥ the length of the first part of the first Fee block, and the length of the remaining storage area of the first storage page - the length of the first part of the first Fee block < the first threshold, the length of the remaining storage area of the second storage page satisfies: the length of the remaining storage area of the second storage page ≥ the length of the second part of the first Fee block, and the length of the remaining storage area of the second storage page - the length of the second part of the first Fee block < the first threshold. As an example, the first part of the first Fee block may include a first NvM block and a second NvM block, and the second part of the first Fee block may include a third NvM block.
[0146] That is, a Fee block encapsulating multiple NvM blocks may be stored in multiple storage pages, wherein the multiple storage pages include blank pages and / or non-blank pages, and at least one of the multiple storage pages stores multiple NvM blocks.
[0147] It can be understood that based on the data storage method provided in the above embodiments of the present application, multiple NvM blocks can be reasonably combined according to the actual situation of the data to be stored, such as the actual length of the Fee block encapsulating the data to be stored, and a suitable target storage page can be selected, such as a blank page or a non-blank page. On the premise of ensuring the normal storage of the data to be stored, the utilization rate of the remaining storage area of the target storage page can be maximized to extend the life of the Flash.
[0148] For example, based on the data storage method provided in the above embodiments of the present application, Figure 7 As shown, when the length of a Fee block (such as the first Fee block) encapsulating multiple data to be stored is close to filling up a certain blank page (such as the first storage page), the Fee block can be stored in the blank page.
[0149] For another example, based on the data storage method provided in the above embodiments of the present application, Figure 8 As shown, when the length of a Fee block (such as the first Fee block) encapsulating multiple data to be stored is close to occupying the remaining storage area of a non-blank page (such as the first storage page), the Fee block can be stored in the non-blank page.
[0150] For another example, based on the data storage method provided in the above embodiments of the present application, Fig. 9 (a) or Fig. 9 In (b), the first part of the first Fee block can be stored in the remaining storage area of a non-blank page (such as the first storage page), and the second part of the Fee block can be stored in one or more other storage pages, wherein the length of the first part of the first Fee block is less than or equal to the length of the remaining storage area of the first storage page. The first storage page can be Fig. 9 (a) in the figure shows a blank page, or Fig. 9 (b) in the figure is a non-blank page. The second storage page can be Fig. 9 (a) and Fig. 9 (b) in the figure shows a blank page. Of course, in some embodiments, the first part and the second part of the first Fee block may be stored in non-blank pages, or the first part of the first Fee block may be stored in a blank page and the second part of the first Fee block may be stored in a non-blank page, which is not specifically limited in the embodiments of the present application.
[0151] In the embodiment of the present application, as an example, when the Fee block is stored in a non-blank page, the Fee block can be written to the non-blank page based on the overwrite mechanism. As an example, please refer to Fig.10 , Fig.10 FIG. 2 shows a schematic diagram of an overwriting mechanism provided by an embodiment of the present application. Fig.10 As shown, when overwriting, buffer data can be generated first, wherein the buffer data includes the same number of bytes as the target storage page. Assuming that the first byte and the second byte of the target storage page already carry data, the corresponding bytes of the buffer data are filled with 0xFF, and the data to be written occupies a corresponding number of bytes after the bytes carrying data according to the length of the data (such as Fig.10 The third byte shown in the figure), where the byte where the data to be written is located is filled with 0x10, and the byte after the data to be written is also filled with 0xFF. When writing the data to be written to the target storage page according to the buffer data, the write operation is only performed on the bytes filled with 0x10, and the write operation is not performed on the bytes filled with 0xFF. Based on this, the data to be written can be successfully stored in the remaining storage area of the target storage page.
[0152] Taking the writing of the first Fee block into the first non-blank storage page as an example, it can be based on Fig.10 The overwrite mechanism shown writes the first Fee block into the remaining storage area of the first storage page, wherein at least two NvM blocks may be encapsulated in the first Fee block. For example, the fourth length of the used storage area of the first storage page may be obtained first, and then the first Fee block may be written into the first byte Q1 to the second byte Q2 of the first storage page, wherein Q1 = the third length - the fourth length, and Q2 = the third length - the fourth length + the second length - 1.
[0153] like Fig.11 As shown, assuming that the first storage page currently stores data, wherein the currently stored data occupies the first Q1-1 bytes of the first storage page, when there is a demand for writing the first Fee, buffer data can be generated first, wherein the first Q1-1 bytes of the buffer data are filled with 0xFF, and according to the length of the first Fee block, the Q1 byte to the Q2 byte of the buffer data are filled with 0x10, and the bytes after the Q2+1 byte of the buffer data are filled with 0xFF, wherein Q1=the third length-the fourth length, Q2=the third length-the fourth length+the second length-1, based on this, the first Fee block can be successfully overwritten into the remaining storage area in the non-blank first storage page, i.e., the Q1 byte to the Q2 byte, according to the buffer data.
[0154] It can be understood that based on the overwrite mechanism, multiple writes to a storage page are implemented in the form of a cache mask, which not only does not affect the written data in the storage page, but also reduces the waste of the storage area of the storage page, maximizes the utilization of the storage page, and extends the life of the Flash.
[0155] In some embodiments of the present application, after completing the storage of data, the storage stack may also record the storage information of the data, wherein the storage information includes the identifier of the NvM block where the data is located and the identifier of the Fee block where the data is located, so as to facilitate the rapid and accurate reading of subsequent data. Taking the first data as an example, after completing the storage of the first Fee block where the first data is located, the storage stack may record the storage information of the first data through the rollback module, wherein the storage information of the first data includes the identifier of the first NvM block where the first data is located.
[0156] In some embodiments, after completing the storage of data, the storage stack may also record the most recent S (S is an integer greater than 1) write addresses (such as the identification of the storage page) and the corresponding data write position index (CurrentIndex) corresponding to the Fee block where the data is located, so as to facilitate data rollback when subsequent data reading fails. Taking the first data as an example, after completing the storage of the first Fee block where the first data is located, the storage information of the first data recorded by the storage stack through the rollback module may also include the most recent S (S is an integer greater than 1) write addresses (such as the identification of the storage page) and the corresponding data write position index (CurrentIndex) corresponding to the first Fee block.
[0157] As an example, Fig.12 As shown, the storage stack can use the circular queue FeeBlockAddrTable to record the most recent S write addresses (such as the identification of the storage page) corresponding to the Fee block where the data is located and the current data write position index (CurrentIndex).
[0158] As an example, Fig.13 As shown, taking the first Fee block as an example, the storage stack can complete the creation and update of the circular queue based on the following S1301-S1302:
[0159] S1301: After a certain type of data is stored several times, a circular queue is created for the first Fee block where the data is located.
[0160] Taking the circular queue recording the most recent S (S is an integer greater than 1) write addresses (such as storage page identifiers) and the corresponding data write location index (CurrentIndex) as an example, the circular queue length corresponding to the first Fee block can be at most S, and the address index table can include at most S write addresses.
[0161] Taking the completion of the i-th data writing corresponding to the first Fee block as an example, the storage stack can complete the update of the circular queue FeeBlockAddrTable based on the following S1302:
[0162] S1302: After completing the storage of the i-th data related to the first Fee block, record the i-th write address and the corresponding position index in the circular queue of the first Fee block.
[0163] The data related to the first Fee block is data that is the same as an identifier (such as ID) of the first Fee block.
[0164] For example, after the storage of the i-th data related to the first Fee block is completed, the i-th write address recorded is such as write address i, and the corresponding position index is such as i, where i=(i+1) / S.
[0165] In some embodiments of the present application, a data reading method is also provided. Based on this method, when a request to read stored data is received, such as when a request to read first data is received, the target storage page where the first data is located can be quickly and accurately obtained from the Flash according to the recorded storage information of the first data, and then the Fee block (such as the first Fee block) where the first data is located is obtained from the target storage page according to the storage information of the first data and the identifier and length information of the Fee block stored in the target storage page, and then the NvM block (such as the first NvM block) where the first data is located is obtained from the first Fee block according to the storage information of the first data and the number identifier of the NvM blocks encapsulated in the first Fee block, the identifier and length information of the NvM blocks encapsulated in the first Fee block, and finally the first data is obtained by parsing the first NvM block.
[0166] As an example, see Fig.14 , Fig.14 FIG. 1 shows a flow chart of a data reading method provided by an embodiment of the present application. Fig.14 As shown, a data reading method provided in an embodiment of the present application can be implemented based on S1401-S1405:
[0167] S1401: In response to receiving a request to read first data, obtaining storage information of the first data.
[0168] The storage information of the first data may be recorded and maintained by the storage stack. For example, the storage stack may record the storage information of each stored data through a rollback module.
[0169] For example, the storage information of the first data may include the identifier of the NvM block where the first data is located, the identifier of the Fee block where the first data is located, the most recent S (S is an integer greater than 1) write addresses corresponding to the first Fee block (such as the identifier of the storage page), and the corresponding data write position index (CurrentIndex).
[0170] S1402: Obtain a first Fee block where the first data is located from a plurality of stored Fee blocks according to storage information of the first data.
[0171] As an example, the write address of the target storage page (such as the first storage page) where the first Fee block is located can be obtained from the most recent S (S is an integer greater than 1) write addresses (such as the identifier of the storage page) corresponding to the first Fee block based on the identifier of the Fee block where the first data is located in the storage information of the first data and the write position index (CurrentIndex) corresponding to the first Fee block, and then the first Fee block where the first data is located can be obtained from the first storage page based on the length information of the first Fee block encapsulated in the first Fee block.
[0172] As an example, after obtaining the write address corresponding to the Fee block where the first data is located, the offset address of the target Fee block (i.e., the first Fee block) encapsulating the first data in the first storage page can be determined according to the identification and length information of the Fee block where the first data is located, and then the first Fee block can be parsed therefrom.
[0173] S1403: Obtain the number identifier of the NvM blocks encapsulated in the first Fee block, the identifier and length information of the NvM block.
[0174] As an example, the number identifier of the NvM blocks encapsulated therein, the identifier of the NvM block, and the length information may be obtained by parsing the first Fee block where the first data is located.
[0175] S1404: Obtain the first NvM block where the first data is located from the first Fee block according to the storage information of the first data and the number identifier of the NvM blocks encapsulated in the first Fee block, the identifier and the length information of the NvM block.
[0176] As an example, the target NvM block where the first data is located (i.e., the first NvM block) can be obtained from the first Fee block based on the identifier of the NvM block where the first data is located in the storage information of the first data, the identifier of the number of NvM blocks encapsulated in the first Fee block, the identifier and length information of the NvM block.
[0177] As an example, the target NvM block where the first data is located (i.e., the first NvM block) can be determined based on the identifier of the NvM block where the first data is located, and then the offset address of the first NvM block in the first Fee block can be determined based on the length information of the first NvM block, and then the first NvM block can be parsed therefrom.
[0178] S1405: Parse the first NvM block and obtain first data.
[0179] As an example, after parsing the first data from the first NvM block, the storage stack may pass it to the corresponding vehicle application in the SWC.
[0180] In some embodiments, when the first data fails to be read, the data reading method provided in the embodiment of the present application can also realize the automatic rollback of the storage data related to the Fee block based on the rollback mechanism. For example, when the acquisition of the first data fails, the write position index can be rolled back from i to i-1 according to the storage information of the first data, and the storage page information (i.e., the write address, such as the identification of the storage page) of the Fee block written for the i-1th time related to the first Fee block is obtained, and the data encapsulated in the Fee block written for the i-1th time related to the first Fee block is obtained according to the storage page information. Among them, the failure to read the first data may be caused by abnormal power failure of the device, or it may be caused by other reasons, which is not limited by the embodiment of the present application.
[0181] As an example, take the failure to read the data corresponding to position index 2 as an example, Fig.15 As shown, when the data corresponding to the read position index 2 fails, the write position index can be rolled back from position index 2 to position index 1, and then the write address 1 corresponding to the position index 1 is read, and the corresponding Fee block is read from the corresponding storage page according to the write address 1, and finally the Fee block is parsed to obtain the data encapsulated therein.
[0182] Of course, in some embodiments, when the acquisition of the first data fails, the user may be prompted that the data reading has failed.
[0183] Alternatively, in some embodiments, if the data cannot be read successfully after a preset number of rollbacks, the user may be prompted that the data reading has failed.
[0184] It can be understood that based on the rollback mechanism provided in the embodiment of the present application, the storage stack can roll back to the most recent relevant historical data when data reading fails, thereby realizing automatic rollback and active playback of data. In addition, since the most recent relevant historical data is usually less likely to be different from the data that failed to be read, rolling back to the most recent relevant historical data will have little impact on the execution of subsequent tasks and the entire process.
[0185] The following will take different data storage scenarios as examples. Figure 4 The system architecture shown specifically introduces the data storage methods in several different scenarios provided in the embodiments of the present application.
[0186] Scenario 1: Multiple data storage requests occur simultaneously
[0187] In some embodiments of scenario 1, it is assumed that multiple data storage requests occur simultaneously, where the multiple data storage requests are respectively used to request the storage of different data. In response to the multiple data storage requests, the storage stack can encapsulate the multiple data into different NvM blocks, and then encapsulate the multiple NvM blocks into the same Fee block and store them in the first storage page, where the first storage page can be a blank page or a non-blank page.
[0188] Taking the first data storage request, the second data storage request and the third data storage request occurring simultaneously, where the first data storage request, the second data storage request and the third data storage request are used to request to store the first data, the second data and the third data respectively as an example, in response to the first data storage request, the second data storage request and the third data storage request, as Fig.16 As shown, the NvM module can encapsulate the first data into the first NvM block, the second data into the second NvM block, the third data into the third NvM block, and send the first NvM block, the second NvM block and the third NvM block to the Fee module; then, the Fee module can encapsulate the first NvM block, the second NvM block and the third NvM block into the first Fee block; finally, the Fee module can store the first Fee block in the first storage page according to the length of the first Fee block and the length of the remaining storage area of each storage page in the Flash, wherein the first storage page can be as shown in FIG. Fig.16 (a) in the figure shows a blank page, or Fig.16 (b) in the figure shows a non-blank page.
[0189] As an example, take the structure of the storage stack as Figure 5 As shown in the example, Fig.17 (a) and Fig.17 As shown in (b), the NvM module can encapsulate the first data into the first NvM block, the second data into the second NvM block, and the third data into the third NvM block through the first NvM module, and the Fee module can encapsulate the first NvM block, the second NvM block and the third NvM block into the first Fee block through the first Fee module.
[0190] As an example, see Fig.18 , Fig.18Taking the simultaneous occurrence of the first data storage request, the second data storage request and the third data storage request as an example, a flowchart of a data storage method provided by an embodiment of the present application in a scenario where multiple data storage requests occur simultaneously is shown. Fig.18 As shown, the method can be implemented based on S1801-S1804:
[0191] S1801: SWC sends a first data storage request, a second data storage request and a third data storage request to the NvM module, where the first data storage request, the second data storage request and the third data storage request are used to request storage of first data, second data and third data respectively.
[0192] by Figure 4 or Figure 5 Taking the system structure shown in the figure as an example, the SWC may send the first data storage request, the second data storage request and the third data storage request to the NvM module in the storage stack through the RTE.
[0193] S1802: The NvM module encapsulates the first data, the second data and the third data into a first NvM block, a second NvM block and a third NvM block respectively and sends the encapsulated data to the Fee module.
[0194] As an example, the NvM module can add a first NvM data header to the first data header, add a first NvM data tail to the first data tail and then encapsulate it into a first NvM block, add a second NvM data header to the second data header, add a second NvM data tail to the second data tail and then encapsulate it into a second NvM block, and add a third NvM data header to the third data header, add a third NvM data tail to the third data tail and then encapsulate it into a third NvM block.
[0195] The NvM data header may carry but is not limited to the identifier and length information of the NvM block, and the NvM data tail may carry but is not limited to the integrity identifier of the data to be stored, such as a CRC check value.
[0196] S1803: The Fee module encapsulates the first NvM block, the second NvM block, and the third NvM block into the first Fee block.
[0197] As an example, the Fee module can splice the first NvM block, the second NvM block and the third NvM block, and add the first Fee data header to the head of the spliced data, add the first Fee data tail to the tail of the spliced data, and then encapsulate them into the first Fee block.
[0198] The Fee data header may carry but is not limited to the identifier of the Fee block, the length information, and the number of NvM blocks encapsulated in the Fee block, and the Fee data tail may carry but is not limited to the magic number, the number of writes, and the number of migrations, etc. The number of NvM blocks encapsulated in the Fee block is identified as TRUE or FALSE, wherein the number of NvM blocks encapsulated in the Fee block is identified as TRUE, indicating that multiple NvM blocks are encapsulated in the Fee block, and the number of NvM blocks encapsulated in the Fee block is identified as FALSE, indicating that one NvM block is encapsulated in the Fee block.
[0199] As an example, the Fee module can determine the target storage page from one or more storage pages based on the actual length information of the first NvM block, the second NvM block, and the third NvM block and the length of the remaining storage area of multiple storage pages in the Flash, so that after the first NvM block, the second NvM block, and the third NvM block are encapsulated into a Fee block and stored in the target storage page, the utilization of the target storage page can meet the preset utilization requirement.
[0200] Taking the storage length of the blank storage page as C as an example, assume that there are k1 (k1 is a positive integer greater than 1) NvM blocks with a length greater than or equal to C and k2 (k2 is a positive integer greater than 1) NvM blocks with a length less than C in the NvM blocks received by the Fee module, where the lengths of the k1 NvM blocks with a length greater than or equal to C are P1, P2, ..., Pk1, and the lengths of the k2 NvM blocks with a length less than C are Q1, Q2, ..., Qk2, respectively. Note that the remaining length of a certain NvM block with a length greater than or equal to C stored in the blank storage page is After the new blank storage page is stored, the length of the remaining storage area of the new storage page is Ci = (C-Pi%C), i∈[1,k1]. The combination of Q1…Qk2 can be solved so that the length corresponding to the combination is less than Ci and meets the given quantity requirement (such as greater than or equal to minCountC), that is, the one-dimensional packing problem with different capacities is solved, and finally the combination relationship between Ci and the set Q1, Q1,…, Qk2 is determined, for example, the NvM blocks corresponding to Q1 and Q1 are written into the C1 position, and the NvM blocks corresponding to Q3 and Q4 are written into the C2 position, etc.
[0201] S1804: The Fee module stores the first Fee block in a first storage page of the Flash, where the first storage page is a blank page or a non-blank page.
[0202] As an example, the Fee module may determine a target storage page that satisfies a first condition and is used to store the first Fee block from multiple storage pages in the Flash according to the length of the first Fee block and the length of the remaining storage area of multiple storage pages in the Flash, such as the first storage page.
[0203] For example, the first condition may be that the length of the remaining storage area of the first storage page is greater than or equal to the length of the first Fee block; or as another example, the first condition may be that the length of the remaining storage area of the first storage page is greater than or equal to the length of the first Fee block, and the difference between the length of the remaining storage area of the first storage page and the length of the first Fee block is less than a first threshold.
[0204] As an example, the Fee module can establish a priority queue Q for the length of the remaining storage area of multiple storage pages in the Flash, and the Fee module can select a length that satisfies the first condition for storing the first Fee block from the priority queue according to the length of the first Fee block (assuming it is L), such as a minimum length greater than or equal to the length of the first Fee block (i.e., L), such as Qmin. After completing the storage of the first Fee block, the Fee module can modify the length (such as Qmin) to Qmin-L. Based on this, it is convenient for the Fee module to quickly select the best target storage page from multiple storage pages of the Flash.
[0205] In some other embodiments of scenario 1, assume that multiple data storage requests occur simultaneously, wherein the multiple data storage requests are respectively used to request the storage of different data. In response to the multiple data storage requests, the storage stack may encapsulate the multiple data into different NvM blocks, and then encapsulate the multiple NvM blocks into the same Fee block and store them in multiple storage pages. Any storage page among the multiple storage pages may be a blank page or a non-blank page.
[0206] Taking the first data storage request, the second data storage request and the third data storage request occurring simultaneously, where the first data storage request, the second data storage request and the third data storage request are used to request to store the first data, the second data and the third data respectively as an example, in response to the first data storage request, the second data storage request and the third data storage request, as Fig.19 As shown, the NvM module can encapsulate the first data into the first NvM block, the second data into the second NvM block, the third data into the third NvM block, and send the first NvM block, the second NvM block and the third NvM block to the Fee module; then, the Fee module can encapsulate the first NvM block, the second NvM block and the third NvM block into the first Fee block; finally, the Fee module can store the first Fee block in the first storage page and the second storage page according to the length of the first Fee block, wherein the first storage page can be as shown in FIG. Fig.19 The blank page shown is a blank page, and it can also be a non-blank page. Similarly, the second storage page can be Fig.19 A blank page is shown, but a non-blank page is also possible.
[0207] As an example, see Fig. 20 , Fig. 20Taking the simultaneous occurrence of the first data storage request, the second data storage request and the third data storage request as an example, another data storage method flow chart provided by the embodiment of the present application in a scenario where multiple data storage requests occur simultaneously is shown. Fig. 20 As shown, the method can be implemented based on S1801-S1803 and S2001, wherein the introduction of S1801-S1803 can refer to the above description of Fig.18 The details of S2001 are as follows:
[0208] S2001: The Fee module stores a first portion of a first Fee block in a first storage page of the Flash, and stores a second portion of the first Fee block in a second storage page of the Flash, where the first storage page and the second storage page are blank pages or non-blank pages.
[0209] As an example, the Fee module can determine a first target storage page (such as the first storage page) for storing the first part of the first Fee block and a second target storage page (such as the second storage page) for storing the second part of the first Fee block from multiple storage pages in the Flash based on the length of the first Fee block and the length of the remaining storage area of the multiple storage pages in the Flash.
[0210] As an example, the Fee module may establish a priority queue Q for the length of the remaining storage area of multiple storage pages in the Flash, and the Fee module may select one or more target storage pages for storing the first Fee block from the priority queue according to the length of the first Fee block (assuming it is L). For example, assuming that there is no storage page in the Flash that can write the entire first Fee block, such as the maximum length (such as Qmax) in the priority queue Q is less than the length of the first Fee block (i.e., L), in this case, the Fee module may write the first part of the first Fee block into the storage page corresponding to Qmax, and delete Qmax from the priority queue Q, wherein the length of the first part of the first Fee block is Qmax; then, the Fee module may reselect the storage page from the updated priority queue Q' according to the length of the remaining part of the first Fee block (i.e., L-Qmax), for example, assuming that the maximum length (such as Qmax') in the updated priority queue Q' is greater than or equal to L-Qmax, the Fee module may write the remaining part of the first Fee block into the storage page corresponding to Qmax'.
[0211] It can be understood that in scenario 1, when multiple data storage requests occur simultaneously, the storage stack can reasonably combine the actual lengths of multiple NvM blocks that encapsulate the data to be stored and the lengths of the remaining storage areas of multiple storage pages in the Flash, and select a suitable target storage page, such as a blank page or a non-blank page. On the premise of ensuring the normal storage of the data to be stored, the utilization rate of the remaining storage area of the target storage page is maximized to extend the life of the Flash.
[0212] Scenario 2: A data storage request is received
[0213] In some embodiments of scenario 2, it is assumed that the storage stack receives a data storage request, such as a first data storage request, the first data storage request being used to request storage of first data, and in response to the first data storage request, such as Fig.21 or Fig. 22 As shown, the storage stack can encapsulate the first data into the first NvM block, and then encapsulate the first NvM block into the first Fee block, and then determine the target storage page, such as the first storage page, according to the actual length of the first Fee block and the length of the remaining storage area of multiple storage pages in the Flash, and finally store the first Fee block in the first storage page, wherein the first storage page can be as shown in FIG. Fig.21 The page shown is blank, or Fig. 22 A non-blank page is shown.
[0214] Among them, Fig. 22 As shown, in the case where the first Fee block is stored in a non-blank first storage page, the first Fee block can be written into the remaining storage area of the first storage page based on the overwrite mechanism, so that the waste of the storage area of the storage page can be reduced without affecting the written data in the storage page, thereby maximizing the utilization of the storage page and extending the life of the Flash. For a detailed introduction to the overwrite mechanism, please refer to the above description, which will not be repeated here.
[0215] As an example, take the structure of the storage stack as Figure 5 As shown in the example, Fig.23 (a) and Fig.23 As shown in (b), the NvM module can encapsulate the first data into the first NvM block through the second NvM module, and the Fee module can encapsulate the first NvM block into the first Fee block through the second Fee module and then store it in the first storage page.
[0216] As an example, see Fig.24 , Fig.24Taking the first data storage request, the second data storage request and the third data storage request not occurring at the same time as an example, a flowchart of a data storage method provided by an embodiment of the present application in a scenario where multiple data storage requests do not occur at the same time is shown. Fig.24 As shown, the method can be implemented based on S2401-S2404:
[0217] S2401: SWC sends a first data storage request to the NvM module, where the first data storage request is used to request storage of first data.
[0218] by Figure 4 or Figure 5 Taking the system structure shown in the figure as an example, the SWC may send the first data storage request to the NvM module in the storage stack through the RTE.
[0219] S2402: The NvM module encapsulates the first data into a first NvM block and sends the first data to the Fee module.
[0220] For a detailed introduction to S2402, please refer to the introduction to S1802 above, which will not be repeated here.
[0221] S2403: The Fee module encapsulates the first NvM block into the first Fee block.
[0222] As an example, the Fee module may add a first Fee data header to the head of the first NvM block, add a first Fee data tail to the tail of the first NvM block, and then encapsulate it into the first Fee block.
[0223] S2404: The Fee module determines a first storage page for storing the first Fee block according to the length of the first Fee block and the length of the remaining storage area of the plurality of storage pages in the Flash, where the first storage page is a blank page or a non-blank page.
[0224] As an example, the Fee module may determine a target storage page that satisfies a first condition and is used to store the first Fee block from multiple storage pages in the Flash according to the length of the first Fee block and the length of the remaining storage area of multiple storage pages in the Flash, such as the first storage page.
[0225] For example, the first condition may be that the length of the remaining storage area of the first storage page is greater than or equal to the length of the first Fee block; or as another example, the first condition may be that the length of the remaining storage area of the first storage page is greater than or equal to the length of the first Fee block, and the difference between the length of the remaining storage area of the first storage page and the length of the first Fee block is less than a first threshold.
[0226] As an example, the Fee module can establish a priority queue Q for the length of the remaining storage area of multiple storage pages in the Flash, and the Fee module can select a length that satisfies the first condition for storing the first Fee block from the priority queue according to the length of the first Fee block (assuming it is L), such as a minimum length greater than or equal to the length of the first Fee block (i.e., L), such as Qmin. After completing the storage of the first Fee block, the Fee module can modify the length (such as Qmin) to Qmin-L. Based on this, it is convenient for the Fee module to quickly select the best target storage page from multiple storage pages of the Flash.
[0227] It should be noted that Fig.24 Taking the existence of a storage page in Flash that can write the entire first Fee block as an example, in some embodiments, there is no storage page in Flash that can write the entire first Fee block. For example, the maximum length in the priority queue Q (such as Qmax) is less than the length of the first Fee block (i.e., L). In this case, the Fee module can write the first Fee block into multiple storage pages, for example, write the first part of the first Fee block into the storage page corresponding to Qmax, delete Qmax from the priority queue Q, and then re-select a storage page from the updated priority queue Q' according to the length of the remaining part of the first Fee block.
[0228] It should be understood that the various schemes of the embodiments of the present application can be used in reasonable combination, and the explanations or descriptions of the various terms appearing in the embodiments can be mutually referenced or explained in the various embodiments, without limitation.
[0229] It should also be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0230] It is understandable that, in order to implement the functions of any of the above-mentioned embodiments, a device (such as a terminal device or a proxy server) includes a hardware structure and / or software module corresponding to each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
[0231] The embodiment of the present application can divide the functional modules of the device (such as a terminal device or a proxy server). For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0232] It should also be understood that each module in a device (such as a terminal device or a proxy server) can be implemented in software and / or hardware form, and there is no specific limitation on this. In other words, a device (such as a terminal device or a proxy server) is presented in the form of a functional module. The "module" here can refer to an application-specific integrated circuit ASIC, a circuit, a processor and a memory that executes one or more software or firmware programs, an integrated logic circuit, and / or other devices that can provide the above functions.
[0233] In an optional manner, when data transmission is implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is implemented in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disk (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0234] The steps of the method or algorithm described in conjunction with the embodiments of the present application can be implemented in a hardware manner or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (RAM), flash memory, read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable read-only memory (EEPROM) memory, register, hard disk, mobile hard disk, compact disc read-only memory (CD-ROM) or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). In addition, the ASIC can be located in a device (such as a terminal device or a proxy server). Of course, the processor and the storage medium can also exist as discrete components.
[0235] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
Claims
1. A data storage method, characterized in that: The method comprises: In response to a plurality of data storage requests, encapsulate the to-be-stored data corresponding to the plurality of data storage requests into a plurality of NvM blocks; At least two NvM blocks of the plurality of NvM blocks are stored in a first memory page.
2. The method according to claim 1, characterized in that The data to be stored corresponding to the multiple data storage requests include first data and second data, and storing at least two NvM blocks of the multiple NvM blocks in the first storage page includes: Encapsulating the first data into a first NvM block, and encapsulating the second data into a second NvM block; Encapsulating the first NvM block and the second NvM block into a first Fee block; The first Fee block is stored in the first storage page.
3. The method according to claim 1, characterized in that The data to be stored corresponding to the multiple data storage requests include first data and second data, and storing at least two NvM blocks of the multiple NvM blocks in the first storage page includes: Encapsulating the first data into a first NvM block and then into a first Fee block, and encapsulating the second data into a second NvM block and then into a second Fee block; The first Fee block and the second Fee block are stored in the first memory page.
4. The method according to claim 2 or 3, characterized in that: The data storage requests corresponding to the first data and the second data are received at the same time.
5. The method according to claim 3, characterized in that: The data storage requests corresponding to the first data and the second data are received at different times.
6. The method according to any one of claims 2 to 5, characterized in that: The data to be stored corresponding to the multiple data storage requests also include third data, and the method further includes: Encapsulating the third data into a third NvM block and then into the first Fee block, wherein the first Fee block includes a first part and a second part, the first part includes the first NvM block and the second NvM block, and the second part includes the third NvM block; The second portion is stored in a second memory page wherein the first portion is stored in the first memory page.
7. The method according to any one of claims 1 to 6, characterized in that The first storage page is one of multiple available storage pages, the length of the remaining storage area of the first storage page is a first length, the length of the Fee block encapsulating the at least two NvM blocks is a second length, and the first length is greater than or equal to the second length.
8. The method according to any one of claims 1 to 7, characterized in that The storage length corresponding to the first storage page is a third length, the third length is smaller than the first length, and storing at least two NvM blocks of the plurality of NvM blocks in the first storage page includes: Acquire a fourth length of a used storage area of the first storage page; The Fee block encapsulating the at least two NvM blocks is written into the first byte Q1 to the second byte Q2 of the first storage page, wherein Q1=the third length-the fourth length, and Q2=the third length-the fourth length+the second length-1.
9. The method according to any one of claims 1 to 8, characterized in that A difference between the first length and the second length is smaller than a first threshold.
10. The method according to claim 9, characterized in that The method further includes: recording storage information of the first data after storing the first data, the storage information of the first data including an identifier of a Fee block where the first data is located and an identifier of an NvM block where the first data is located; When receiving a request to read the first data, acquiring the first Fee block where the first data is located from the stored Fee blocks according to the storage information of the first data and the identifiers and length information of the stored Fee blocks; Obtaining the number identifier, identifier and length information of the NvM blocks encapsulated in the first Fee block; Acquire the first NvM block where the first data is located from the first Fee block according to the storage information of the first data and the number identifier of the NvM blocks encapsulated in the first Fee block, the identifier and the length information of the NvM block, The first NvM block is parsed to obtain the first data.
11. The method according to claim 10, characterized in that The first Fee block is written for the i-th time, where i is an integer and i>1, and the method further includes: When the acquisition of the first data fails, acquiring storage page information of the Fee block written for the i-1th time related to the first Fee block; The data encapsulated in the Fee block written for the i-1th time and related to the first Fee block is obtained according to the storage page information.
12. A data reading method, characterized in that: The method comprises: In response to a request to read the first data, obtaining identification and length information of a plurality of Fee blocks that have been stored, the plurality of Fee blocks including the first Fee block; Acquire a first Fee block where the first data is located from the stored multiple Fee blocks according to the storage information of the first data and the identifiers and length information of the stored multiple Fee blocks, wherein the storage information of the first data is recorded after the storage of the first data is completed, and the storage information of the first data includes the identifier of the Fee block where the first data is located and the identifier of the NvM block where the first data is located; Obtaining the number identifier, identifier and length information of the NvM blocks encapsulated in the first Fee block; The first data is obtained from the first Fee block according to the storage information of the first data and the number identifier of the NvM blocks encapsulated in the first Fee block, the identifier and the length information of the NvM block, and when the acquisition of the first data fails, the storage page information of the Fee block written for the i-1th time related to the first Fee block is obtained, and the data encapsulated in the Fee block written for the i-1th time related to the first Fee block is obtained according to the storage page information, where i is an integer and i>1.
13. The method according to claim 12, characterized in that The acquiring the first data from the first Fee block according to the storage information of the first data and the number identifier of the NvM blocks encapsulated in the first Fee block, the identifier and the length information of the NvM block includes: Acquire the first NvM block where the first data is located from the first Fee block according to the storage information of the first data and the number identifier of the NvM blocks encapsulated in the first Fee block, the identifier and the length information of the NvM block; The first NvM block is parsed to obtain the first data.
14. A data storage device, characterized in that: The device comprises: Memory for storing computer program instructions and data; A processor, configured to execute the computer program instructions to support the data storage device to implement the method as described in any one of claims 1-11 or 12-13.
15. A vehicle, characterized in that: The vehicle includes the data storage device of claim 14.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by the processing circuit, the method according to any one of claims 1-11 or 12-13 is implemented.
17. A computer program product comprising instructions, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 11 or 12 to 13.
Citation Information
Patent Citations
NVM automatic configuration method, device and equipment
CN112230848A
Flash storage method and device, intelligent wearable equipment and storage medium
CN113157212A
Data storage method and device, medium and equipment
CN114518845A
Methods and systems for performing efficient page reads in a non-volatile memory
US20120198125A1
Controller and method to perform persistent memory management in a memory system
WO2023088546A1