Data storage method, apparatus and system, and vehicle

By encapsulating multiple data to be stored into NvM blocks and storing them in one storage page, the problems of wasted storage resources and slow data storage speed in the prior art are solved, and more efficient data storage and longer storage module life are achieved.

WO2025092935A1PCT designated stage expired Publication Date: 2025-05-08HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/129093
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-11-01
Filing Date
2024-10-31
Publication Date
2025-05-08

AI Technical Summary

Technical Problem

When the prior art stores data in automotive controllers, it leads to waste of storage resources and slow data storage speed, and insufficient storage reliability.

Method used

By encapsulating multiple data to be stored into NvM blocks and storing multiple NvM blocks in one storage page, an overwrite mechanism is used to store data in non-blank storage pages to improve storage resource utilization and data storage speed.

Benefits of technology

While ensuring the reliability of data storage, it reduces waste of storage resources, improves data storage speed, and extends the life of storage modules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024129093_08052025_PF_FP_ABST
    Figure CN2024129093_08052025_PF_FP_ABST
Patent Text Reader

Abstract

A data storage method, apparatus and system, and a vehicle, relating to the technical field of data storage, and capable of reducing storage resource waste, increasing the utilization rate of storage resources, increasing the data storage speed and improving the reliability of data storage. For data storage requests that are simultaneously initiated, a storage stack supports combined encapsulation of multiple pieces of data on the basis of the actual lengths of the multiple pieces of data and the actual available lengths of multiple available storage pages, and selects an optimal blank storage page or a non-blank storage page for storing an encapsulated data block; or, for a data storage request, on the basis of the actual length of data and the actual available lengths of the multiple available storage pages, the storage stack supports selecting the optimal blank storage page or the non-blank storage page for storing an encapsulated data block.
Need to check novelty before this filing date? Find Prior Art

Description

Data storage method, device, system and vehicle

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on November 1, 2023, with application number 202311451032.9 and application name “Data Storage Method, Device, System and Vehicle”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] 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

[0003] The Automotive Open System Architecture (AUTOSAR) is an open, industry-standard software architecture jointly established by global automakers (such as original equipment manufacturers (OEMs) and Tier 1 automotive suppliers), component suppliers, and other electronics, semiconductor, and software vendors. This software architecture encompasses the real-time scheduling, communication, diagnostics, storage management, functional safety, and information security required to build automotive controllers and has been widely adopted in automotive software development. For data storage, AUTOSAR provides a layered, non-volatile storage mechanism, based on which data to be stored can be encapsulated into blocks and stored individually in one or more flash pages.

[0004] With the evolution of automotive electronic and electrical (E / E) architecture, automotive controllers increasingly utilize system-on-a-chip (SoC) systems for application data processing. Currently, SoCs often use external non-volatile flash memory (NOR Flash), such as serial peripheral interface (SPI) NOR Flash, to store data. External NOR Flash typically has a large flash page size. According to existing non-volatile storage mechanisms, even small amounts of data will occupy a flash page, resulting in a waste of storage resources.

[0005] Summary of the Invention

[0006] 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.

[0007] To achieve the above objectives, this application adopts the following technical solutions:

[0008] In a first aspect, a data storage method is provided, the method comprising: in response to multiple data storage requests, encapsulating data to be stored 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.

[0009] As an example, this method can be applied to the field of in-vehicle technology, such as on devices capable of data processing and storage, such as domain controllers. Domain controllers include, but are not limited to, intelligent driving domain controllers, cockpit domain controllers, chassis domain controllers, power domain controllers, thermal management controllers, and body domain controllers.

[0010] As an example, the aforementioned domain controller and other devices capable of data processing and storage may store data via a flash memory (Flash), for example, by storing data via a plurality of flash memory pages (ie, storage pages) of the flash memory.

[0011] Of course, this 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 limitations.

[0012] The solution provided in the first aspect above can support storing multiple data to be stored in a single storage page. For example, it can support storing multiple data to be stored in a single storage page simultaneously; in another example, it can support storing multiple data to be stored in the same storage page multiple times. Based on this, while 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.

[0013] As one possible implementation, the data to be stored corresponding to the multiple data storage requests includes first data and second data. Storing at least two of the multiple NvM blocks in the first storage page includes: encapsulating the first data into the first NvM block and the second data into the second NvM block; encapsulating the first NvM block and the second NvM block into a first Fee block; and storing the first Fee block in the first storage page. In this way, by encapsulating the multiple data to be stored into the same Fee block and then storing them in a single storage page, the multiple data to be stored can be stored in a single storage page. This maximizes the utilization of the remaining storage area of ​​the target storage page while ensuring normal storage of the data to be stored, thereby extending the life of the storage module.

[0014] As one possible implementation, the data to be stored corresponding to the multiple data storage requests includes first data and second data. Storing at least two of the multiple NvM blocks in the first storage page includes: encapsulating the first data into the first NvM block and then into a first Fee block, encapsulating the second data into a second NvM block and then into a second Fee block; and 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 a single storage page, multiple data to be stored can be stored in a single storage page. This maximizes the utilization of the remaining storage area of ​​the target storage page while ensuring normal storage of the data to be stored, thereby extending the life of the storage module.

[0015] As a possible implementation, the data storage requests corresponding to the first data and the second data are received at the same time. Thus, the solution provided by this application can support storing multiple data to be stored in the same storage page based on multiple simultaneous data storage requests. For example, multiple data to be stored can be stored in the same storage page by encapsulating them in the same Fee block or by encapsulating them in different Fee blocks.

[0016] 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).

[0017] As a possible implementation, the data storage requests corresponding to the first data and the second data are received at different times. Thus, the solution provided by this application can support storing multiple data to be stored in the same storage page based on 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 the same storage page.

[0018] As a possible implementation, the data to be stored corresponding to the multiple data storage requests also includes third data. The method further includes: encapsulating the third data into a third NvM block and then into a first Fee block, where 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; and storing the second part in a second storage page, where the first part is stored in the first storage page. In this way, different parts of a Fee block encapsulating multiple data to be stored can be stored in different storage pages to meet diverse data storage needs.

[0019] In one possible implementation, 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. For example, a suitable target storage page for data storage can be selected based on the length of the Fee block containing the at least two NvM blocks and the length of the remaining storage area of ​​the multiple available storage pages, thereby maximizing utilization of the remaining storage area of ​​the target storage page and extending the life of the storage module.

[0020] 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 of the remaining storage area of ​​the target storage page and extend the life of the storage module.

[0021] 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. In other words, the present application supports storing multiple data to be stored in the same blank storage page.

[0022] As a possible implementation, the storage length corresponding to the first storage page is a third length, which is smaller than the first length. The storing of at least two NvM blocks from the plurality of NvM blocks in the first storage page includes: obtaining a fourth length of the used storage area of ​​the first storage page; and writing a Fee block encapsulating the at least two NvM blocks from the first byte Q1 to the second byte Q2 of the first storage page, where Q1 = the third length - the fourth length, and Q2 = the third length - the fourth length + the second length - 1. In this way, data to be stored can be written to a non-blank page based on an overwrite mechanism, supporting the storage of multiple data to be stored in the same storage page, thereby improving the utilization of the target storage page while extending the life of the storage module.

[0023] As a possible implementation, the difference between the first length and the second length is less than a first threshold. In this way, a target memory page that is most conducive to memory page utilization can be selected based on the sum of the lengths of the at least two NvM blocks and the length of the remaining memory area of ​​the multiple available memory pages. This maximizes the utilization of the remaining memory area of ​​the target memory page and extends the life of the memory module.

[0024] As a possible implementation, the method further includes: recording storage information of the first data after storing the first data, wherein the storage information of the first data includes an identifier of the Fee block in which the first data is located and an identifier of the NvM block in which the first data is located; upon receiving a request to read the first data, obtaining a first Fee block in which the first data is located from the multiple stored Fee blocks based on the storage information of the first data and the identifiers and length information of the multiple stored Fee blocks; obtaining an identifier of the number of NvM blocks encapsulated in the first Fee block, an identifier of the NvM block, and length information; obtaining the first NvM block in which the first data is located from the first Fee block based on the storage information of the first data and the identifiers of the number of NvM blocks encapsulated in the first Fee block, and the identifiers and length information of the NvM blocks; and parsing the first NvM block to obtain the first data. In this manner, recording the storage information of the data facilitates faster and more accurate reading of the target data when subsequently reading data.

[0025] As a possible implementation, the first Fee block is written for the i-th time, where i is an integer and i>1. The method further includes: 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 based on the storage page information. In this way, by recording the data storage information, data rollback can be facilitated in the event of a subsequent data read failure.

[0026] 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 in which the first data is located from the multiple stored Fee blocks based on 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 in which the first data is located and the identification of the NvM block in which the first data is located; obtaining a number identification, an identification, and length information of the NvM blocks encapsulated in the first Fee block; obtaining the first data from the first Fee block based on the storage information of the first data and the number identification, the identification, and length information of the NvM blocks encapsulated in the first Fee block, 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 based on the storage page information, wherein i is an integer and i>1.

[0027] As an example, this method can be applied to the field of in-vehicle technology, such as on devices capable of data processing and storage, such as domain controllers. Domain controllers include, but are not limited to, intelligent driving domain controllers, cockpit domain controllers, chassis domain controllers, power domain controllers, thermal management controllers, and body domain controllers.

[0028] As an example, the aforementioned domain controller and other devices capable of data processing and storage may store data via a flash memory (Flash), for example, by storing data via a plurality of flash memory pages (ie, storage pages) of the flash memory.

[0029] Of course, this 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 limitations.

[0030] The solution provided in the second aspect can facilitate data rollback in the event of a subsequent data read failure by recording data storage information. For example, in the event of a data read failure, the storage page, Fee block, and NvM block containing the most recently written data related to the target Fee block can be more quickly and accurately determined, allowing the target data to be quickly and accurately read from these pages.

[0031] As a possible implementation, obtaining the first data from the first Fee block based on the storage information of the first data and the number identifier, NvM block identifier, and length information of the NvM blocks encapsulated in the first Fee block includes: obtaining the first NvM block containing the first data from the first Fee block based on the storage information of the first data and the number identifier, NvM block identifier, and 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 manner, recording the data storage information facilitates faster and more accurate reading of the target data based on this information during subsequent data reads. For example, this facilitates faster and more accurate determination of the storage page, Fee block, and NvM block containing the target data based on the recorded data storage information, thereby enabling faster and more accurate reading of the target data.

[0032] In a third aspect, a data storage device is provided, which includes: a memory for storing computer program instructions and data; and 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.

[0033] 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.

[0034] 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.

[0035] In a sixth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to implement the method in any possible implementation of the first aspect or the second aspect.

[0036] In a seventh aspect, a chip system is provided, comprising a processing circuit and a storage medium storing computer program instructions; when the computer program instructions are executed by the processor, the method of any possible implementation of the first or second aspect is implemented. The chip system may be composed of a chip alone or may include a chip and other discrete components. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] FIG1 is a schematic diagram of a conventional non-volatile storage management system architecture;

[0038] FIG2 is a schematic diagram of a conventional data storage solution;

[0039] FIG3 is a schematic diagram of a data storage effect achieved based on a conventional data storage solution;

[0040] FIG4 is a schematic diagram of a domain controller system architecture provided by an embodiment of the present application;

[0041] FIG5 is a schematic diagram of another domain controller system architecture provided in an embodiment of the present application;

[0042] FIG6 is a flowchart of a data storage method according to an embodiment of the present application;

[0043] FIG7 is a first schematic diagram of an example of a data storage process according to an embodiment of the present application;

[0044] FIG8 is a second schematic diagram of an example of a data storage process provided in an embodiment of the present application;

[0045] FIG9 is a third schematic diagram of an example of a data storage process provided in an embodiment of the present application;

[0046] FIG10 is a schematic diagram of an overwriting mechanism provided in an embodiment of the present application;

[0047] FIG11 is a schematic diagram of an overwriting process provided in an embodiment of the present application;

[0048] FIG12 is a schematic diagram of a circular queue provided in an embodiment of the present application;

[0049] FIG13 is a flow chart of a method for creating and updating a circular queue according to an embodiment of the present application;

[0050] FIG14 is a second flow chart of a data storage method provided in an embodiment of the present application;

[0051] FIG15 is a schematic diagram of a data rollback mechanism provided in an embodiment of the present application;

[0052] FIG16 is a fourth schematic diagram of an example of a data storage process provided in an embodiment of the present application;

[0053] FIG17 is a fifth exemplary diagram of a data storage process according to an embodiment of the present application;

[0054] FIG18 is a flowchart of a data storage method according to an embodiment of the present application;

[0055] FIG19 is a sixth schematic diagram of an example of a data storage process provided in an embodiment of the present application;

[0056] FIG20 is a fourth flow chart of a data storage method provided in an embodiment of the present application;

[0057] FIG21 is a seventh schematic diagram of an example of a data storage process provided in an embodiment of the present application;

[0058] FIG22 is an exemplary schematic diagram of a data storage process according to an embodiment of the present application;

[0059] FIG23 is a ninth schematic diagram of an example of a data storage process according to an embodiment of the present application;

[0060] Figure 24 is a flowchart of the data storage method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying 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 merely a description of the association relationship of associated objects, indicating that three relationships can exist, 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.

[0062] Hereinafter, the terms "first," "second," and so on are used solely to distinguish different descriptive 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 preceding the "field" in "first field" and "second field" does not define the position or order of the "fields." "First" and "second" do not define whether the modified "fields" are in the same message, nor do they restrict the order of the "first field" and "second field." For another example, if the described object is a "level," the ordinal number preceding the "level" in "first level" and "second level" does not define the priority of the "levels." For another example, the number of described objects is not limited by the ordinal number and can be one or more. For example, in the case of "first device," the number of "devices" can be one or more. Furthermore, 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 "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 "second information" can be information of the same content or 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 the use of such prefixes should not constitute unnecessary limitations.

[0063] 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 connection 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.

[0064] 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. A block is the smallest unit of flash memory erase, and a flash page is the storage unit of flash memory.

[0065] In some examples, the flash memory may be NOR Flash. NOR Flash is a fast, randomly read / write flash memory primarily used to store data that requires rapid access, such as program code and firmware. The principle of NOR Flash is to store data in individual storage units (also known as "storage pages," collectively referred to as "storage pages" in the following embodiments). Each storage page has an independent address, and data can be read and written based on the storage page address, resulting in faster addressing and read / write speeds.

[0066] For example, when the controller used by AUTOSAR is a microcontroller unit (MCU), the MCU's flash memory is typically NOR flash memory built into the MCU. Based on the built-in NOR flash memory provided by the MCU, the MCU can encapsulate the data to be stored into blocks and store them in blank memory pages in the flash memory.

[0067] For example, taking the AUTOSAR non-volatile storage management system architecture as shown in Figure 1, which includes a software component (SWC), a runtime environment (RTE), a storage stack, and Flash, as shown in Figure 2, the RTE can pass the data storage request initiated by the SWC to the storage stack, and the storage stack will encapsulate the data to be stored and write it to the blank storage page in the hardware device Flash.

[0068] As an example, as shown in FIG1 , 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 and then individually encapsulated into a Fee Block. For example, as shown in FIG2 , first, the NvM module of the storage stack may encapsulate the first data to be stored into a first NvM Block and then pass it to the Fee module. Then, the Fee module may encapsulate the first NvM Block into a first Fee Block and pass it to the Fls module. Finally, the Fls module of the storage stack may store the first Fee Block in a blank storage page in the Flash. For example, the Fls module may store the first Fee Block in one or more blank storage pages in the Flash.

[0069] Taking the data to be stored including data 1, data 2 and data 3 shown in Figure 3 as an example, as shown in Figure 3, based on the non-volatile storage mechanism shown in Figure 2, the NvM module can add NvM data headers and NvM data trailers at 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, and then pass them to the Fee module; the Fee module can add Fee data headers and Fee data trailers at 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, and then store them in three blank storage pages of the Flash (storage page 1, storage page 2 and storage page n as shown in Figure 3, where n is a positive integer greater than 2).

[0070] With the evolution of E / E architecture, controllers have gradually evolved from MCUs to SoCs, and SoCs often use external NOR Flash, such as SPI NOR Flash. The storage page length of external NOR Flash (such as SPI NOR Flash) is typically larger than that of internal NOR Flash. If data is still stored based on the non-volatile storage mechanism shown in Figure 2, regardless of whether the Fee Block length is long or short, each Fee Block occupies at least one storage page. For example, as shown in Figure 3, assuming that the storage page shown in Figure 3 is SPI NOR Flash, although the Fee Block lengths corresponding to Data 2 and Data 3 are very short, they still each occupy a dedicated storage page based on the non-volatile storage mechanism shown in Figure 2. For another example, the storage page length of SPI NOR Flash is typically large. Therefore, the conventional data storage mechanism shown in Figure 2 not only wastes storage resources, but also increases the number of page erases and writes, shortening the lifespan of the Flash, as the erase and write cycles of Flash are generally limited. In the long run, this waste of storage resources also increases the erase and write cycles of the storage page, thereby reducing the lifespan of the Flash.

[0071] In order to reduce the waste of storage resources, improve the utilization of storage resources and increase the life of Flash, an embodiment of the present application provides a data storage method, which can support storing the data to be stored in a non-blank storage page, for example, storing one data to be stored in a non-blank storage page, or storing multiple data to be stored in a non-blank storage page, wherein a blank storage page (hereinafter referred to as "blank page") refers to a storage page that does not store data, and correspondingly, a non-blank storage page (hereinafter referred to as "non-blank page") refers to a storage page that stores data. Of course, the method can also support storing the data to be stored in a blank page.

[0072] 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 a 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.

[0073] 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.

[0074] For example, multiple Fee blocks respectively encapsulating one or more data to be stored may be stored in a blank page or a non-blank page; or as another example, a Fee block encapsulating multiple data to be stored may be stored in a blank page or a non-blank page.

[0075] In some embodiments, the data storage method provided in the embodiments of the present application can store multiple data to be stored in multiple storage pages.

[0076] For example, multiple parts of a Fee block encapsulating multiple data to be stored can 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 can be stored in storage page 1, and the second part can 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 can all be either blank pages or non-blank pages.

[0077] 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.

[0078] For example, multiple parts of a Fee block encapsulating data to be stored can be stored in multiple storage pages, where 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 can be stored in a blank page, and the second part can be stored in a non-blank page. For another example, the first part of the Fee block encapsulating data to be stored can be stored in a blank page, and the second part can be stored in another blank page. For another example, the first part of the Fee block encapsulating data to be stored can be stored in a non-blank page, and the second part can be stored in another non-blank page.

[0079] 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 encapsulating a data to be stored can be stored in a blank page or a non-blank page.

[0080] As an example, the data storage method provided in the embodiments 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.

[0081] The vehicle described in the embodiments of the present application is a broad concept and can be any vehicle, such as a land vehicle, a water vehicle, an air vehicle, an industrial device, an agricultural device, or an entertainment device. For example, the vehicle described in the embodiments of the present application can be a vehicle (such as a car, a bus, a subway, a high-speed train, a motorcycle, a flying car, a train, etc.), an industrial vehicle (such as a forklift, a trailer, a tractor, etc.), an engineering vehicle (such as an excavator, a bulldozer, a crane, etc.), an agricultural device (such as a mower, a harvester, etc.), an amusement ride, a toy vehicle, a boat, an air cushion vehicle, a submarine, an airplane, a helicopter, etc. The embodiments of the present application do not limit the specific type, form, or function of the vehicle.

[0082] In some examples, the domain controller can be divided into several domains (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.

[0083] The intelligent driving domain primarily provides autonomous driving perception and decision-making services, such as image reception, image processing and judgment, data processing and calculation, navigation and route planning, and rapid real-time situation judgment and decision-making. The intelligent driving domain requires processing algorithms at the three levels of perception, decision-making, and control, placing the highest demands on the domain controller's hardware and software. The cockpit domain primarily controls the various electronic information systems within the vehicle's intelligent cockpit, including the central control system, in-vehicle infotainment system, head-up display, seating system, instrumentation system, rearview mirror system, driver behavior monitoring system, and navigation system. The chassis domain primarily controls the vehicle's driving behavior and posture. Its functions include, but are not limited to, brake system management, transmission system management, driving system management, steering system management, vehicle speed sensor management, body posture sensor management, air suspension system management, and airbag system management. The powertrain domain primarily controls the vehicle's powertrain, optimizing its performance and ensuring safety, including engine management, transmission management, battery management, power distribution management, emissions management, speed limit management, and fuel and power conservation management. 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, sunroof, wipers, electric trunk, smart keys, air conditioning, antennas, gateway communications, etc.

[0084] Please refer to Figure 4, which shows a schematic diagram of a domain controller system architecture for implementing a data storage method provided by an embodiment of the present application. As shown in Figure 4, the domain controller may include SWC, RTE, storage stack, and Flash from top to bottom.

[0085] Flash is a hardware storage device used to store data. Flash can include multiple memory pages, such as flash pages. Each memory page can be used to store data. Each memory page has an independent address. When storing and reading data, the individual memory pages can be read and written based on the memory page address, resulting in faster addressing and read / write speeds.

[0086] As an example, the Flash shown in FIG4 may include but is not limited to flash memories such as NOR Flash.

[0087] 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 this application.

[0088] In this embodiment of the present application, an in-vehicle application in the SWC can initiate a data storage request or a data read request. A data storage request is used to request the storage of application data of the in-vehicle application, and a data read request is used to request the reading of stored application data of the in-vehicle application. Application data may include, but is not limited to, autonomous driving data, vehicle driving data, road image data, and the like, and is not specifically limited in this embodiment of the present application.

[0089] 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.

[0090] As a non-volatile memory manager, the storage stack can encapsulate the data to be stored and write it to the Flash memory upon receiving a data storage request. Alternatively, upon receiving a data read request, the storage stack can retrieve the target data from the stored data. As an example, as shown in Figure 4, the storage stack may include an NvM module, a Fee module, and a Fls module.

[0091] Among them, the NvM module shown in Figure 4 can be used to encapsulate the data to be stored into an NvM Block when receiving a data storage request. For example, the NvM module can add an NvM data header to the head of the data to be stored and an NvM data trailer to the tail of the data to be stored, and then encapsulate it into an NvM Block and pass it to the Fee module. The NvM data header carries the identifier and length information of the NvM Block, and the NvM data trailer can carry but is not limited to the integrity identifier of the data to be stored, such as a cyclic redundancy check (CRC) check value, etc.

[0092] In some embodiments, as shown in Figure 4, the NvM module can also be used to read the target data from the Fee Block according to the NvM data header and NvM data tail of the NvM Block in the Fee Block when receiving (such as receiving through the MemIf module shown in Figure 4) the target Fee Block read by the Fee module from the Flash, 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 and passing it to the corresponding in-vehicle application in the SWC.

[0093] In some embodiments, as shown in Figure 4, 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 Fee Block from the Fee module through the MemIf module.

[0094] The Fee module shown in Figure 4 can be used to encapsulate the NvM Block from the NvM module into a 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 a Fee Block and store it in Flash. For example, the Fee Block is stored in Flash through the Fls module, where the Fee data header carries the Fee Block identifier, length information, and the number of NvM Blocks encapsulated in the Fee Block. The Fee data tail carries a devil number, write count, and migration count, etc. 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 to 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.

[0095] In the embodiment of the present application, the Fee module can support encapsulating multiple NvM Blocks into one Fee Block, and can also support encapsulating one NvM Block into one Fee Block.

[0096] In an embodiment of the present application, the Fee module shown in FIG4 can support storing a Fee Block in a blank page or 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, where the multiple storage pages include 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 an NvM Block in at least one blank page and / or at least one non-blank page.

[0097] In some embodiments, the Fee module shown in FIG. 4 may also be used to record storage information of stored data.

[0098] 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 rapid and accurate reading of subsequent data.

[0099] 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.

[0100] In some embodiments, the Fee module shown in Figure 4 can also be used to obtain the target Fee Block from the Flash based on the recorded storage information and the Fee data header and Fee data tail of the Fee Block when receiving a data read request. For example, the target Fee Block where the target data is located is determined based on the identifier of the Fee Block and the number of NvM Blocks, the target storage page is obtained from the Flash through the Fls module, and the offset address of the target Fee Block encapsulating the target data in the target storage page is determined based on the length information of the Fee Block, and then the target Fee Block is parsed and passed to the NvM module.

[0101] In some embodiments, as shown in FIG5 , 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 configured to encapsulate multiple data to be stored into multiple NvM blocks and then pass them to the first Fee module when the NvM module simultaneously receives multiple data storage requests; the second NvM module is configured to encapsulate the data to be stored into an NvM block and then pass it to the second Fee module when the NvM module receives a single data storage request. The first Fee module is configured to encapsulate multiple NvM blocks from the first NvM module into a single Fee block, and ultimately encapsulate the multiple NvM blocks into one or more Fee blocks and then store them in at least one blank page and / or at least one non-blank page in the Flash memory; the second Fee module is configured to encapsulate an NvM block from the second NvM module into a single Fee block and then store it in at least one blank page and / or at least one non-blank page in the Flash memory.

[0102] In some embodiments, as shown in Figure 5, the Fee module may also include a rollback module for recording storage information of the 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.

[0103] The data storage method provided in the embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0104] Please refer to Figure 6, which shows a flow chart of a data storage method provided by an embodiment of the present application. The data storage method shown in Figure 6 can be applied to a storage stack, a domain controller, or other processing modules on a vehicle, without specific limitation. As shown in Figure 6, the data storage method can be implemented based on S601-S602:

[0105] 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.

[0106] Taking the system structure shown in FIG4 or FIG5 as an example, the data storage request is initiated by the SWC, and the RTE may pass the data storage request to the storage stack after receiving the data storage request.

[0107] 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.

[0108] 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 the 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 kNvM block.

[0109] In some embodiments, multiple data storage requests occur simultaneously, for example, multiple data storage requests are initiated simultaneously by a SWC, or multiple data storage requests are received simultaneously by a storage stack.

[0110] 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.

[0111] In some embodiments, some of the multiple data storage requests occur simultaneously, while some of the requests do not occur simultaneously with the other requests. For example, at least two of the multiple data storage requests are initiated by the SWC at a first moment, while one or more of the multiple data storage requests are initiated by the SWC at one or more other moments. For another example, at least two of the multiple data storage requests are received by the storage stack at a first moment, while one or more of the multiple data storage requests are received by the storage stack at one or more other moments.

[0112] S602: Store at least two NvM blocks from a plurality of NvM blocks in a first storage page, and store at least one NvM block from the plurality of NvM blocks in a second storage page.

[0113] The first storage page and the second storage page are storage pages among a plurality of available storage pages of the Flash.

[0114] 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 in which at least two of the plurality of 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 may be 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 in which at least two of the plurality of NvM blocks are located; or another example may be 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 in which at least two of the plurality of 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 in which at least two of the plurality of NvM blocks are located is less than a first threshold.

[0115] Similarly, the second storage page is a second target storage page that satisfies a 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 in which 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 may be 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 in which at least one of the multiple NvM blocks is located; or another example may be 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 in which 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 in which at least one of the multiple NvM blocks is located is less than a first threshold.

[0116] In some embodiments, the first storage page is a blank page. For example, if the length of the remaining storage area of ​​the first storage page is a first length and the storage length corresponding to the first storage page is a third length, the first length satisfies: first length = third length, which means that the first storage page currently does not store data and is a blank page.

[0117] In some embodiments, the first storage page is a non-blank page. For example, if the length of the remaining storage area of ​​the first storage page is a first length and the storage length corresponding to the first storage page is a third length, the first length satisfies: the first length < the third length, meaning that data is currently stored in the first storage page and the first storage page is a non-blank page.

[0118] 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, which means that the second storage page currently does not store any data and is a blank page.

[0119] 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, meaning that data is currently stored in the second storage page and the second storage page is a non-blank page.

[0120] 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 at different times, which is not specifically limited in this embodiment of the present application. For example, the multiple data storage requests corresponding to the at least two NvM blocks may all occur simultaneously; for another example, the multiple data storage requests corresponding to the at least two NvM blocks may not all occur simultaneously; for another example, at least two of the multiple data storage requests corresponding to the at least two NvM blocks may occur simultaneously, and at least one may not occur simultaneously with the other requests.

[0121] As an example, S602 may specifically include the following cases 1 to 5:

[0122] Case 1: encapsulate multiple NvMs into different Fee blocks, and then store the multiple Fee blocks in the first storage page.

[0123] For example, if the data storage requests corresponding to multiple NvM blocks do not occur simultaneously, the multiple NvM blocks can be encapsulated into different Fee blocks and then stored in the first storage page. Of course, if the data storage requests corresponding to multiple NvM blocks occur simultaneously, or if at least two of the multiple data storage requests corresponding to multiple NvM blocks occur simultaneously and at least one does not occur simultaneously with the other requests, the multiple NvM blocks can also be encapsulated into different Fee blocks and then stored in the first storage page, without specific limitation.

[0124] 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 in which 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 this, the utilization rate of the remaining storage area of ​​the first storage page can be maximized.

[0125] 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 first data and 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 a first NvM block and the second data has been encapsulated into a second NvM block as an example, first, the first NvM block can be encapsulated into a first Fee block and the second 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 a 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, or a 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 that 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.

[0126] 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.

[0127] 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.

[0128] Among them, the data storage requests corresponding to at least two NvM blocks among the above-mentioned multiple NvM blocks may occur simultaneously, or may not occur simultaneously, or there may be multiple requests that occur simultaneously, and at least one of them may not occur simultaneously with other requests; at least one NvM block among the above-mentioned multiple NvM blocks may occur simultaneously with any one of the at least two NvM blocks among the above-mentioned multiple NvM blocks, or may not occur simultaneously with at least two NvM blocks among the above-mentioned multiple NvM blocks, without specific limitation.

[0129] 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 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 areas of the first storage page and the second storage page can be maximized.

[0130] 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, 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 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.

[0131] Alternatively, taking the example of multiple data storage requests including 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 being used to request the storage of first data, second data, third data and fourth data respectively, and the first data being encapsulated into a first NvM block, the second data being encapsulated into a second NvM block, the third data being encapsulated into a third NvM block, and the fourth data being encapsulated into a fourth NvM block in response to the first data storage request, the second data storage request, the third data storage request and the fourth data storage request, 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.

[0132] 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 multiple NvM blocks.

[0133] Case 3: multiple NvMs are encapsulated into one Fee block, and then the Fee block is stored in the first storage page.

[0134] 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.

[0135] 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 in which 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 this, the utilization rate of the remaining storage area of ​​the first storage page can be maximized.

[0136] 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 first data and 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 a first NvM block and the second data has been encapsulated into a second NvM block as an example, first, the first NvM block and the second 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 a first storage page that satisfies the requirement that the length of the remaining storage area of ​​the first storage page is ≥ the length of the first Fee block, or a first storage page that satisfies the requirement that the length of the remaining storage area of ​​the first storage page is ≥ the length of the first Fee block, and that the length of the remaining storage area of ​​the first storage page - the length of the first Fee block is < a first threshold; finally, the first Fee block can be stored in the first storage page.

[0137] That is, a Fee block encapsulating multiple NvM blocks may be stored in a storage page, where the storage page may be a blank page or a non-blank page.

[0138] Case 4: encapsulating at least two NvM blocks among the plurality of NvM blocks into one Fee block, and then storing the one Fee block in the first storage page; and encapsulating at least one NvM block among the plurality of NvM blocks into one Fee block, and then storing the one Fee block in the second storage page.

[0139] Among them, the data storage requests corresponding to at least two of the above-mentioned multiple NvM blocks can occur simultaneously; at least one of the above-mentioned multiple NvM blocks can occur simultaneously with any one of the at least two of the above-mentioned multiple NvM blocks, or can occur not simultaneously with at least two of the above-mentioned multiple NvM blocks, without specific limitation.

[0140] 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 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 areas of the first storage page and the second storage page can be maximized.

[0141] 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, first, 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.

[0142] 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, and 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.

[0143] 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.

[0144] Case 5: encapsulating at least two NvM blocks in a plurality of NvMs into one Fee block, and then storing a first portion of the one Fee block in a first storage page, and storing a second portion of the one Fee block in a second storage page.

[0145] The data storage requests corresponding to at least two NvM blocks among the plurality of NvM blocks may occur simultaneously.

[0146] 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 in which at least two of the 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 in which at least two of the 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.

[0147] Taking multiple data storage requests including a first data storage request, a second data storage request, and a third data storage request, where 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, first, 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. The length of the remaining storage area of ​​the first storage page satisfies the following conditions: 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 ≥ the length of the second part of the first Fee block; or 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 minus the length of the first part of the first Fee block < a first threshold; 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 minus 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.

[0148] That is, a Fee block encapsulating multiple NvM blocks may 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 multiple NvM blocks.

[0149] 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.

[0150] For example, based on the data storage method provided in the above-mentioned embodiments of the present application, as shown in Figure 7, 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 blank page (such as the first storage page), the Fee block can be stored in the blank page.

[0151] For another example, based on the data storage method provided in the above-mentioned embodiments of the present application, as shown in FIG8 , when the length of a Fee block (such as the first Fee block) encapsulating multiple data to be stored is close to filling up 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.

[0152] For another example, based on the data storage method provided in the above embodiments of the present application, as shown in (a) or (b) in FIG9 , 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 a blank page as shown in (a) in FIG9 , or a non-blank page as shown in (b) in FIG9 , and the second storage page can be a blank page as shown in (a) and (b) in FIG9 . Of course, in some embodiments, the first and second parts of the first Fee block can also be stored in non-blank pages, or the first part of the first Fee block can be stored in a blank page and the second part of the first Fee block can be stored in a non-blank page, which is not specifically limited in the embodiments of the present application.

[0153] In an embodiment of the present application, as an example, when a Fee block is stored in a non-blank page, the Fee block can be written to the non-blank page based on an overwrite mechanism. As an example, please refer to Figure 10, which shows a schematic diagram of an overwrite mechanism provided by an embodiment of the present application. As shown in Figure 10, buffer data can be generated first when overwriting, 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 that already carry data according to the length of its data (as shown in the third byte of Figure 10), wherein 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 will only be performed for the bytes filled with 0x10, and the write operation will not be performed for 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.

[0154] Taking the writing of the first Fee block to a non-blank first storage page as an example, the first Fee block can be written to the remaining storage area of ​​the first storage page based on the overwrite mechanism shown in Figure 10, where at least two NvM blocks can be encapsulated in the first Fee block. For example, the fourth length of the used storage area of ​​the first storage page can be obtained first, and then the first Fee block can be written from the first byte Q1 to the second byte Q2 of the first storage page, where Q1 = the third length - the fourth length, and Q2 = the third length - the fourth length + the second length - 1.

[0155] As shown in Figure 11, 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 need to write 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, and 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.

[0156] It can be understood that based on the overwrite mechanism, multiple writes to a storage page are achieved 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.

[0157] In some embodiments of the present application, after completing data storage, the storage stack may also record the data's storage information, where 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, to facilitate the rapid and accurate reading of subsequent data. Taking first data as an example, after completing storage of the first Fee block where the first data is located, the storage stack may record the first data's storage information through a rollback module, where the first data's storage information includes the identifier of the first NvM block where the first data is located.

[0158] In some embodiments, after completing the storage of data, the storage stack may also record the S most recent (S is an integer greater than 1) write addresses (such as the identifier of the storage page) and the corresponding data write location 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 S most recent (S is an integer greater than 1) write addresses (such as the identifier of the storage page) and the corresponding data write location index (CurrentIndex) corresponding to the first Fee block.

[0159] As an example, as shown in FIG12 , the storage stack may use a circular queue FeeBlockAddrTable to record the most recent S write addresses (such as the identifier of the storage page) corresponding to the Fee block where the data is located and the current data write location index (CurrentIndex).

[0160] As an example, as shown in FIG13 , 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:

[0161] 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.

[0162] Taking the circular queue recording 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 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.

[0163] Taking the completion of the i-th data write 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:

[0164] 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.

[0165] The data related to the first Fee block is data that is the same as the identifier (such as ID) of the first Fee block.

[0166] For example, after the storage of the i-th data related to the first Fee block is completed, the recorded i-th write address is such as write address i, and the corresponding position index is such as i, where i=(i+1) / S.

[0167] 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 where the first data is located (such as the first Fee block) 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. Then, the NvM block where the first data is located (such as the first NvM block) 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, and the identifier and length information of the NvM blocks encapsulated in the first Fee block. Finally, the first data is obtained by parsing the first NvM block.

[0168] As an example, please refer to Figure 14, which shows a flow chart of a data reading method provided by an embodiment of the present application. As shown in Figure 14, a data reading method provided by an embodiment of the present application can be implemented based on S1401-S1405:

[0169] S1401: In response to receiving a request to read first data, obtain storage information of the first data.

[0170] 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.

[0171] 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).

[0172] 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.

[0173] 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.

[0174] 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 based on 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.

[0175] S1403: Obtain the number identifier, identifier, and length information of the NvM blocks encapsulated in the first Fee block.

[0176] As an example, the number identifier, identifier and length information of the NvM blocks encapsulated therein may be obtained by parsing the first Fee block in which the first data is located.

[0177] 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.

[0178] 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 number identifier of the NvM blocks encapsulated in the first Fee block, the identifier and length information of the NvM block.

[0179] 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.

[0180] S1405: Parse the first NvM block to obtain first data.

[0181] As an example, after parsing the first data from the first NvM block, the storage stack may pass it to the corresponding in-vehicle application in the SWC.

[0182] In some embodiments, when the first data reading fails, the data reading method provided in the embodiment of the present application can also realize 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 can be obtained, and the data encapsulated in the Fee block written for the i-1th time related to the first Fee block can be obtained according to the storage page information. Among them, the failure to read the first data may be caused by an 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.

[0183] As an example, taking the failure to read the data corresponding to position index 2 as an example, as shown in Figure 15, when the data corresponding to position index 2 fails to be read, the write position index can be rolled back from position index 2 to position index 1, and then the write address 1 corresponding to 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.

[0184] Of course, in some embodiments, when the acquisition of the first data fails, the user may be prompted that the data reading has failed.

[0185] 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.

[0186] It is understood that based on the rollback mechanism provided in the embodiments of the present application, the storage stack can roll back to the most recent relevant historical data when data read fails, thus achieving automatic rollback and active playback of data. Furthermore, since the most recent relevant historical data is generally less likely to differ significantly 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 overall process.

[0187] The following will take different data storage scenarios as examples, combined with the system architecture shown in Figure 4, to specifically introduce the data storage methods in several different scenarios provided by the embodiments of the present application.

[0188] Scenario 1: Multiple data storage requests occur simultaneously

[0189] 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.

[0190] Taking the case where the first data storage request, the second data storage request and the third data storage request occur simultaneously, where the first data storage request, the second data storage request and the third data storage request are used to request the storage of 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 shown in FIG16 , 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 it in the first storage page according to the length of the first Fee block and the length of the remaining storage area of ​​multiple storage pages in the Flash, where the first storage page can be a blank page as shown in (a) in FIG16 , or a non-blank page as shown in (b) in FIG16 .

[0191] As an example, taking the structure of the storage stack as shown in Figure 5 as an example, as shown in (a) and (b) in Figure 17, 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.

[0192] As an example, please refer to Figure 18. Figure 18 takes the simultaneous occurrence of a first data storage request, a second data storage request, and a third data storage request as an example, illustrating a flow chart of a data storage method provided by an embodiment of the present application in a scenario where multiple data storage requests occur simultaneously. As shown in Figure 18, the method can be implemented based on S1801-S1804:

[0193] S1801: The 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.

[0194] Taking the system structure shown in FIG. 4 or FIG. 5 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.

[0195] 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.

[0196] 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.

[0197] The NvM data header may carry, but is not limited to, an identifier and length information of the NvM block, and the NvM data tail may carry, but is not limited to, an integrity identifier of the data to be stored, such as a CRC check value.

[0198] S1803: The Fee module encapsulates the first NvM block, the second NvM block, and the third NvM block into the first Fee block.

[0199] 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 it into the first Fee block.

[0200] The Fee data header may carry, but is not limited to, the Fee block identifier, length information, and the number of NvM blocks encapsulated in the Fee block. The Fee data trailer may carry, but is not limited to, the magic number, the number of writes, and the number of migrations. The number of NvM blocks encapsulated in the Fee block may be TRUE or FALSE. If the number of NvM blocks encapsulated in the Fee block is TRUE, it indicates that the Fee block contains multiple NvM blocks. If the number of NvM blocks encapsulated in the Fee block is FALSE, it indicates that the Fee block contains one NvM block.

[0201] 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 requirements.

[0202] 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. The lengths of the k1 NvM blocks with a length greater than or equal to C are P1, P2, ..., Pk1 respectively, 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 after the blank storage page is After storing in the new blank storage page, 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 the combination relationship between Ci and the set Q1, Q1,…, Qk2 is finally 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.

[0203] 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.

[0204] As an example, the Fee module can determine a target storage page that meets the first condition for storing the first Fee block from multiple storage pages in the Flash, such as the first storage page, based on the length of the first Fee block and the length of the remaining storage area of ​​multiple storage pages in the Flash.

[0205] 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; for 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.

[0206] As an example, the Fee module can establish a priority queue Q for the lengths of the remaining storage areas of multiple storage pages in the Flash. The Fee module can select a length that satisfies a first condition for storing the first Fee block from the priority queue based on 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 (e.g., Qmin) to Qmin-L. Based on this, the Fee module can quickly select the optimal target storage page from multiple storage pages in the Flash.

[0207] In other 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 multiple storage pages. Any storage page among the multiple storage pages can be a blank page or a non-blank page.

[0208] Taking the case where the first data storage request, the second data storage request and the third data storage request occur simultaneously, where the first data storage request, the second data storage request and the third data storage request are used to request the storage of 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 shown in FIG19 , 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, where the first storage page can be a blank page as shown in FIG19 or a non-blank page, and similarly, the second storage page can be a blank page as shown in FIG19 or a non-blank page.

[0209] As an example, please refer to Figure 20. Figure 20 takes the simultaneous occurrence of a first data storage request, a second data storage request, and a third data storage request as an example, illustrating a flow chart of another data storage method provided by an embodiment of the present application in a scenario where multiple data storage requests occur simultaneously. As shown in Figure 20, this method can be implemented based on S1801-S1803 and S2001. For the introduction to S1801-S1803, please refer to the description of Figure 18 above and will not be repeated here. S2001 is specifically as follows:

[0210] S2001: The Fee module stores the first part of the first Fee block in a first storage page of the Flash and stores the second part of the first Fee block in a second storage page of the Flash. The first storage page and the second storage page are blank pages or non-blank pages.

[0211] 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.

[0212] As an example, the Fee module may establish a priority queue Q for the lengths of the remaining storage areas of multiple storage pages in the Flash memory. The Fee module may select one or more target storage pages for storing the first Fee block from the priority queue based on the length of the first Fee block (assuming it is L). For example, assuming that there is no storage page in the Flash memory capable of writing the entire first Fee block, and if the maximum length in the priority queue Q (e.g., Qmax) is less than the length of the first Fee block (i.e., L), in this case, the Fee module may write the first portion of the first Fee block to the storage page corresponding to Qmax and delete Qmax from the priority queue Q, where the length of the first portion of the first Fee block is Qmax. Then, the Fee module may reselect a storage page from the updated priority queue Q' based on the length of the remaining portion of the first Fee block (i.e., L-Qmax). For example, assuming that the maximum length in the updated priority queue Q' (e.g., Qmax') is greater than or equal to L-Qmax, the Fee module may write the remaining portion of the first Fee block to the storage page corresponding to Qmax'.

[0213] 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 appropriate target storage pages, such as blank pages or non-blank pages. 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.

[0214] Scenario 2: Receive a data storage request

[0215] 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, which is used to request the storage of first data. In response to the first data storage request, as shown in Figure 21 or Figure 22, the storage stack can encapsulate the first data into a first NvM block, and then encapsulate the first NvM block into a first Fee block. Then, based on the actual length of the first Fee block and the length of the remaining storage area of ​​multiple storage pages in the Flash, the target storage page, such as the first storage page, is determined, and finally the first Fee block is stored in the first storage page, where the first storage page can be a blank page as shown in Figure 21, or a non-blank page as shown in Figure 22.

[0216] As shown in FIG22 , when the first Fee block is stored in a non-blank first storage page, the first Fee block can be written to the remaining storage area of ​​the first storage page based on the overwrite mechanism. This can reduce the waste of the storage area of ​​the storage page while not affecting the data already written in the storage page, thereby maximizing the utilization of the storage page and extending the life of the Flash. For a detailed description of the overwrite mechanism, please refer to the above description and will not be repeated here.

[0217] As an example, taking the structure of the storage stack as shown in Figure 5, as shown in (a) and (b) in Figure 23, 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.

[0218] As an example, please refer to Figure 24. Figure 24 takes the case where the first data storage request, the second data storage request, and the third data storage request do not occur simultaneously as an example, and shows a flow chart of a data storage method provided by an embodiment of the present application in a scenario where multiple data storage requests do not occur simultaneously. As shown in Figure 24, the method can be implemented based on S2401-S2405:

[0219] S2401: The 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.

[0220] Taking the system structure shown in FIG. 4 or FIG. 5 as an example, the SWC may send the first data storage request to the NvM module in the storage stack through the RTE.

[0221] S2402: The NvM module encapsulates the first data into a first NvM block and sends the first NvM block to the Fee module.

[0222] For a detailed introduction to S2402, please refer to the introduction to S1802 above, which will not be repeated here.

[0223] S2403: The Fee module encapsulates the first NvM block into the first Fee block.

[0224] 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 the data into the first Fee block.

[0225] 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 ​​multiple storage pages in the Flash. The first storage page is a blank page or a non-blank page.

[0226] As an example, the Fee module can determine a target storage page that meets the first condition for storing the first Fee block from multiple storage pages in the Flash, such as the first storage page, based on the length of the first Fee block and the length of the remaining storage area of ​​multiple storage pages in the Flash.

[0227] 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 another example may be that 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.

[0228] As an example, the Fee module can establish a priority queue Q for the lengths of the remaining storage areas of multiple storage pages in the Flash. The Fee module can select a length that satisfies a first condition for storing the first Fee block from the priority queue based on 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 (e.g., Qmin) to Qmin-L. Based on this, the Fee module can quickly select the optimal target storage page from multiple storage pages in the Flash.

[0229] S2405: The Fee module writes the first Fee block into the first storage page.

[0230] It should be noted that Figure 24 only takes the existence of a storage page in the Flash that can write the entire first Fee block as an example. In some embodiments, there is no storage page in the 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.

[0231] It should be understood that the various schemes of the embodiments of the present application can be reasonably combined and used, and the explanations or descriptions of the various terms appearing in the embodiments can be referenced or explained with each other in the various embodiments, without limitation to this.

[0232] 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.

[0233] 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 that performs the corresponding functions. Those skilled in the art should easily appreciate 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 this application.

[0234] The embodiments of the present application can divide a device (such as a terminal device or a proxy server) into functional modules. For example, each functional module can be divided into corresponding functional modules, or two or more functions can be integrated into one processing module. The above-mentioned integrated modules 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 embodiments of the present application is schematic and is only a logical functional division. In actual implementation, there may be other division methods.

[0235] It should also be understood that the various modules in a device (such as a terminal device or proxy server) can be implemented in software and / or hardware, without specific limitation. In other words, the device (such as a terminal device or proxy server) is presented in the form of functional modules. The "module" here can refer to an application-specific integrated circuit (ASIC), a circuit, a processor and memory that executes one or more software or firmware programs, an integrated logic circuit, and / or other devices that can provide the above-mentioned functions.

[0236] 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 can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can 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 can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium can 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)).

[0237] The steps of the method or algorithm described in conjunction with the embodiments of the present application can be implemented in hardware or by executing software instructions by a processor. The software instructions can be composed of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) memory, registers, hard disks, mobile hard disks, 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 an integral part 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.

[0238] 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

  • Data storage method, data storage device and storage device

    CN112068772A

  • Flash storage method and device, intelligent wearable equipment and storage medium

    CN113157212A

  • Data storage method and device, medium and equipment

    CN114518845A

  • Eeprom emulation using flash memory

    US20100250875A1

  • Method to emulate eeprom using flash memory

    US20130080690A1