CN117687580A - Data management system, micro-control unit and vehicle of Flash - Google Patents

Data management system, micro-control unit and vehicle of Flash Download PDF

Info

Publication number
CN117687580A
CN117687580A CN202410147851.2A CN202410147851A CN117687580A CN 117687580 A CN117687580 A CN 117687580A CN 202410147851 A CN202410147851 A CN 202410147851A CN 117687580 A CN117687580 A CN 117687580A
Authority
CN
China
Prior art keywords
information
preset
storage unit
unit
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410147851.2A
Other languages
Chinese (zh)
Inventor
杨永超
王佳慧
蔡朱平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Anhui Xihe Microelectronics Co ltd
Shuimu Blue Whale Nanning Semiconductor Technology Co ltd
Shenzhen Xihua Technology Co Ltd
Original Assignee
Anhui Xihe Microelectronics Co ltd
Shuimu Blue Whale Nanning Semiconductor Technology Co ltd
Shenzhen Xihua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Anhui Xihe Microelectronics Co ltd, Shuimu Blue Whale Nanning Semiconductor Technology Co ltd, Shenzhen Xihua Technology Co Ltd filed Critical Anhui Xihe Microelectronics Co ltd
Priority to CN202410147851.2A priority Critical patent/CN117687580A/en
Publication of CN117687580A publication Critical patent/CN117687580A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to the field of data storage, and provides a data management system, a micro control unit and a vehicle of Flash, wherein the system comprises: the Flash comprises at least one storage unit, wherein the storage unit at least comprises a data unit storage space and an information unit storage space, the data unit storage space is used for storing data units, the information unit storage space is used for storing information units, the data units are in one-to-one correspondence with the information units, and the information units at least comprise corresponding description information and storage addresses of the data units; and the data management module comprises an external interface for a user to call and an internal interface for the data management system to call internally. According to the Flash management method and device, the data stored in the Flash can be better managed through the structure of the Flash in the data management system and the provided internal and external interfaces.

Description

Data management system, micro-control unit and vehicle of Flash
Technical Field
The invention relates to the field of data storage, in particular to a data management system, a micro control unit and a vehicle of Flash.
Background
With the increasing requirements of the market on energy conservation, comfort, interconnection, safety and the like of automobiles, particularly the development of intelligent cabins, automatic driving and other technologies of new energy automobiles in recent years, the development of automobile electronic technologies is accelerated very rapidly. The ECU integration of the automobile is higher and higher, and the locally stored user data is also increased. In the past, when the vehicle-gauge product needs to locally store a large amount of data, an external EEPROM scheme is generally selected, and the small amount of data is stored simply by adopting Flash in a chip, so that the service life is ensured by an balanced erasing algorithm with the requirement on the service life.
However, the external EEPROM device is selected to increase the cost of additional devices and BOMs, and the external EEPROM device is used to perform inter-board communication such as SPI, IIC, etc., which increases the loop and additional fault point for overall data processing, and the link is easily interfered by the external environment to cause errors, which increases the complexity of PCB design and the test cost, but the Flash in chip is used to simply store data, which cannot perform effective data management when facing a large amount of data.
Disclosure of Invention
Aiming at the defects existing in the prior art, the application provides a Flash data management system, a micro control unit and a vehicle, and the data stored in the Flash can be better managed through the structure of the Flash in the data management system and the provided internal and external interfaces.
In order to solve the problems, the present application provides the following technical solutions:
in a first aspect, an embodiment of the present application provides a data management system of Flash, where the system includes:
the Flash comprises at least one storage unit, wherein the storage unit at least comprises a data unit storage space and an information unit storage space, the data unit storage space is used for storing data units, the information unit storage space is used for storing information units, the data units are in one-to-one correspondence with the information units, and the information units at least comprise corresponding description information and storage addresses of the data units;
and the data management module comprises an external interface for a user to call and an internal interface for the data management system to call internally.
In some embodiments, the internal interface includes an initialization interface, a first detection interface, and a second detection interface; wherein,
the initialization interface is used for:
invoking the first detection interface; the first detection interface is used for determining the state of each storage unit when being called;
invoking the second detection interface; and the second detection interface is used for enabling the initialization interface to execute different preset operations according to the state of each storage unit when being called.
In some embodiments, the storage unit includes a header information storage space including a first preset area, a second preset area, a third preset area, and a fourth preset area; wherein,
when the first preset area is written with first preset information and the rest preset areas are not written with preset information, the storage unit is in a first state;
when the first preset area is written with first preset information, the second preset area is written with second preset information, and the rest preset areas are not written with preset information, the storage unit is in a second state;
when the first preset area is written with first preset information, the second preset area is written with second preset information, the third preset area is written with third preset information, and the fourth preset area is not written with fourth preset information, the storage unit is in a third state;
when the first preset area is written with first preset information, the second preset area is written with second preset information, the third preset area is written with third preset information, and the fourth preset area is written with fourth preset information, the storage unit is in a fourth state.
In some embodiments, the first detection interface, when invoked, is to:
detecting a head information storage space of an Nth storage unit, and determining a state of the Nth storage unit according to information in the first preset area, the second preset area, the third preset area and the fourth preset area; wherein n=1 in the initialized state;
let n=n+1, and return to the execution step to detect the header information storage space of the nth storage unit.
In some embodiments, the second detection interface, when invoked, is to:
determining whether a storage unit in an activated state exists according to the state of each storage unit;
when the storage unit in the activated state exists and the storage unit in the page change state does not exist, enabling the initialization interface to execute a first preset operation;
when the storage unit in the activated state exists and the storage unit in the page changing state exists, determining whether data to be carried in the page changing process is carried out, and when the data carrying is completed, enabling the initialization interface to execute a second preset operation;
when the storage unit in the activated state is not present and the storage unit in the page changing state is present, determining whether the data to be carried in the page changing process is carried out, and when the data is not carried, enabling the initialization interface to execute a third preset operation.
In some embodiments, the second preset operation includes:
writing fourth information in a fourth preset area of the storage unit in the third state.
In some embodiments, the third preset operation includes:
and erasing all the storage units in the Flash which are not in the full-erasing state.
In some embodiments, the internal interface includes a search interface that, when invoked, is to:
acquiring an information unit writing address;
reading the information unit according to the information unit writing address;
when the information unit is readable, the information unit writing address is offset by a first preset byte to be used as a new information unit writing address;
and returning to the execution step, and reading the information unit according to the information unit writing address.
In some embodiments, the search interface, when invoked, is further to:
when the information unit is unreadable, acquiring a data unit writing address;
reading information of a second preset byte according to the data unit writing address, and when the non-writable state is determined according to the information of the second preset byte, shifting the data unit writing address by the second preset byte to serve as a new data unit writing address;
And returning to the execution step, and reading the information of the second preset byte according to the writing address of the data unit.
In some embodiments, the internal interface further includes a page-change task interface that, when invoked, is to:
determining a storage unit in a backup state and a storage unit in an active state;
detecting the erasure state of the storage unit in the backup state, and erasing the storage unit when the storage unit is not in the full erasure state;
starting data carrying to carry the effective data in the storage unit in the active state into the storage unit in the backup state, and writing different preset information into the storage unit in the backup state according to the carrying progress;
after the data handling is completed, the storage unit in the active state is erased.
In a second aspect, an embodiment of the present application provides a micro-control unit, where the micro-control unit includes a data management system of Flash according to the first aspect.
In a third aspect, embodiments of the present application provide a vehicle comprising a micro control unit as described in the second aspect.
The application provides a data management system, micro control unit and vehicle of Flash, this system includes: the Flash comprises at least one storage unit, wherein the storage unit at least comprises a data unit storage space and an information unit storage space, the data unit storage space is used for storing data units, the information unit storage space is used for storing information units, the data units are in one-to-one correspondence with the information units, and the information units at least comprise corresponding description information and storage addresses of the data units; and the data management module comprises an external interface for a user to call and an internal interface for the data management system to call internally. According to the Flash management method and device, the data stored in the Flash can be better managed through the structure of the Flash in the data management system and the provided internal and external interfaces.
Drawings
Fig. 1 is a system schematic diagram of a Flash data management system provided in the present application.
Fig. 2 is a schematic structural diagram of a Flash according to an embodiment of the present application.
Fig. 3 is a schematic structural diagram of a header information storage space according to an embodiment of the present application.
Fig. 4 is a schematic diagram of a detection flow of the first detection interface provided in the embodiment of the present application.
Fig. 5 is a schematic diagram of a detection flow of the second detection interface provided in the embodiment of the present application.
Fig. 6 is a schematic structural diagram of an information unit according to an embodiment of the present application.
Fig. 7 is a schematic diagram of a search flow of a search interface provided in an embodiment of the present application.
Fig. 8 is a schematic diagram of a page changing flow of the page changing interface provided in the embodiment of the present application.
Fig. 9 is a schematic structural diagram of a micro control unit according to an embodiment of the present application.
Fig. 10 is a schematic structural view of a vehicle provided in an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature. In the description of the present invention, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
For convenience in description of the first direction and the second direction in the embodiments of the present application, the first direction is an up-down direction in the drawing, the second direction is a front-back direction in the drawing, and the third direction is a left-right direction in the drawing. The x-axis arrow direction is taken as an "up" direction, the y-axis arrow direction is taken as a "back" direction, and the z-axis arrow direction is taken as a "right" direction, which is not limited in the practical application of the present application.
Referring to fig. 1, fig. 1 is a system schematic diagram of a Flash data management system according to an embodiment of the present application. As shown in fig. 1, the system includes Flash10000 and a data management module 20000.
In some embodiments, flash10000 includes at least one storage unit, where the storage unit includes at least a data unit storage space and an information unit storage space, where the data unit storage space is used to store data units, and the information unit storage space is used to store information units, where the data units are in one-to-one correspondence with the information units, and the information units include at least description information and a storage address of the corresponding data units;
In some embodiments, the data management module 20000 includes an external interface for user invocation and an internal interface for internal invocation of the data management system.
In some embodiments, the external interfaces include at least a write interface for user-invocation to perform data writing, a query interface for user-invocation to perform data querying, and a read interface for user-invocation to perform data reading.
In some embodiments, the system is applied to a vehicle comprising a micro control unit (Micro controller Unit, MCU) comprising Flash10000, the data management module 20000 being a program module running on the MCU.
In some embodiments, the micro-control unit further comprises random access memory (Random Access Memory, RAM).
Referring to fig. 2, fig. 2 is a schematic structural diagram of a Flash according to an embodiment of the present application. As shown in fig. 2, the Flash in fig. 2 includes a storage unit 1000, and at least a data unit storage space 1200 and an information unit storage space 1400 are included in the storage unit 1000; wherein,
the data unit storage space 1200 is used for storing data units, the information unit storage space 1400 is used for storing information units, the data units correspond to the information units one by one, and the information units at least comprise description information and storage addresses of the corresponding data units.
In some embodiments, the storage unit 1000 further includes a head information storage space 1100 and a tail information storage space 1500.
In some embodiments, the head information storage space 1100 is used for storing head information, the tail information storage space 1500 is used for storing tail information, and the head information storage space 1100 and the tail information storage space 1500 are backed up.
In some embodiments, the header information is used to identify the storage unit 1000, for example, to identify the state of the storage unit 1000, which will be described in detail in the following section of the specification.
In some embodiments, the storage unit 1000 further includes a reserved expansion space 1300, the reserved expansion space 1300 being a space for a subsequent expansion scheme.
In some embodiments, reserved extension space 1300 is located between data unit storage space 1200 and information unit storage space 1400.
In some embodiments, the data of reserved expansion space 1300 is a preset value, for example, 0x00.
In some embodiments, the information units in the information unit storage space 1400 include description information and physical addresses, the description information is used for describing the corresponding data units, the physical addresses are used for searching the corresponding data units, and the user can search the physical addresses of the data units corresponding to the description information by inputting the description information, so as to read the corresponding data units.
Through the information unit structure, the description information and the storage address are orderly stored in the information unit, so that the description information and the storage address can be conveniently searched later.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a header information storage space according to an embodiment of the present disclosure. As shown in fig. 3, the header information storage space 1100 includes: a first preset region 1110, a second preset region 1120, a third preset region 1130, and a fourth preset region 1140.
In some embodiments, the header information storage space 1100 further includes a reserved space 1150, and the reserved space 1150 may be used for subsequent scheme expansion.
In some embodiments, the first preset area has a size of 8 bytes, and the first preset information includes first information and second information each occupying four bytes, and illustratively, the first information is sequentially 0x5A, 0x01, 0x00, and 0xCA from a low address to a high address, the second information is the same as the first information and the second information is written below the first information, and is also sequentially 0x5A, 0x01, 0x00, and 0xCA from the low address to the high address.
In some embodiments, the size of the second preset area is 8 bytes, the second preset information includes third information and fourth information each occupying four bytes, and illustratively, the third information is 0x5A, 0x02, 0x00, and 0x1E in order from a low address to a high address, the fourth information is the same as the third information and the fourth information is written below the third information, and also 0x5A, 0x02, 0x00, and 0x1E in order from the low address to the high address.
In some embodiments, the size of the third preset area is 8 bytes, and the third preset information includes fifth information and sixth information each occupying four bytes, and illustratively, the fifth information is 0x5A, 0x03, 0x00, and 0x52 in order from a low address to a high address, the fifth information is the same as the sixth information, and the sixth information is written below the fifth information, and is also 0x5A, 0x03, 0x00, and 0x52 in order from the low address to the high address.
In some embodiments, the fourth preset area has a size of 8 bytes, and the fourth preset information includes seventh information and eighth information each occupying four bytes, and illustratively, the seventh information is 0x5A, 0x04, 0x00, and 0xAB in order from a low address to a high address, the seventh information is the same as the eighth information, and the eighth information is written below the seventh information, and is also 0x5A, 0x04, 0x00, and 0xAB in order from the low address to the high address.
In some embodiments, the storage unit is in the first state when the first preset area is written with the first preset information and the remaining preset areas are not written with the preset information.
In some embodiments, when the first preset area is written with first preset information, the second preset area is written with second preset information, and the rest preset areas are not written with preset information, the storage unit is in the second state.
In some embodiments, when the first preset area is written with first preset information, the second preset area is written with second preset information, the third preset area is written with third preset information, and the fourth preset area is not written with fourth preset information, the storage unit is in a third state.
In some embodiments, the storage unit is in a fourth state when the first preset area is written with first preset information, the second preset area is written with second preset information, the third preset area is written with third preset information, and the fourth preset area is written with fourth preset information.
In some embodiments, the first state, the second state, the third state, and the fourth state may be used to identify an execution progress of the storage unit when performing the page-changing task.
In some embodiments, the first storage unit is defined to be full, and when the valid data of the first storage unit needs to be transferred to the second storage unit, the predetermined information is written into a predetermined area of the second storage unit during the transferring process; the first state is used for identifying that data transfer is ready to start, the second state is used for identifying that data transfer is started, the third state is used for identifying that data transfer is completed, and erasing the first storage unit is started, and the fourth state is used for identifying that erasing of the first storage unit is completed.
In some embodiments, upon identifying that the state of the storage unit is the fourth state, the storage unit is marked as an active storage unit.
In some embodiments, the head information storage space 1100 and the tail information storage space 1500 are identical in structure.
In some embodiments, when writing the preset information to the preset area of the head information storage space 1100 fails, the preset information is written to the preset area of the tail information storage space 1500.
In some embodiments, the internal interface includes an initialization interface, a first detection interface, and a second detection interface.
The initialization interface is used for:
(1) Invoking the first detection interface; the first detection interface is used for determining the state of each storage unit when being called;
(2) Invoking the second detection interface; and the second detection interface is used for enabling the initialization interface to execute different preset operations according to the state of each storage unit when being called.
In some embodiments, the initialization interface is configured to query the state of the storage unit to find the active storage unit, the backup storage unit, and the error storage unit, and to correct the error storage unit when the error storage unit is found.
In some embodiments, by initializing the interface, not only the state of the storage units can be identified, but also the state of each storage unit can be ensured to be correct so as to ensure the operation of the system.
In some embodiments, the first detection interface, when invoked, is to:
detecting a head information storage space of an Nth storage unit, and determining a state of the Nth storage unit according to information in the first preset area, the second preset area, the third preset area and the fourth preset area; wherein n=1 in the initialized state;
let n=n+1, and return to the execution step to detect the header information storage space of the nth storage unit.
In some embodiments, referring to fig. 4, fig. 4 is a schematic diagram of a detection flow of the first detection interface provided in the embodiment of the present application. As shown in fig. 4, the detection flow 100 executed when the first detection interface is invoked includes steps 101 to 117.
Step 101: an nth storage unit is selected.
In some embodiments, N is a positive integer, and n=1 in the initial state.
Step 102: judging whether the storage unit is completely erased or not.
In some embodiments, if the storage unit is completely erased, step 103 is performed; if the storage unit is not fully erased, step 115 is performed.
In some embodiments, a full erase of a storage unit refers to the storage unit not storing valid data, e.g., the storage unit storing data that is empty, e.g., 0x00.
Step 103: it is determined whether the header information storage space is readable.
In some embodiments, if the header information storage space is readable, then step 104 is performed; if the header information storage space is not readable, step 105 is performed.
In some embodiments, power loss in the event of an unexpected situation, such as writing information to the head information storage space, may result in the head information storage space being unreadable.
Step 104: the header information is read.
Step 105: and judging whether the tail information storage space is readable or not.
In some embodiments, if the tail information storage space is readable, then step 106 is performed; if the tail information storage space is not readable, then step 115 is performed.
In some embodiments, when writing information to the head information storage space fails, information is written to the tail information storage space, so if the head information storage space is not readable and the tail information storage space is readable, valid data is stored in the tail information storage space.
Step 106: and reading tail information.
Step 107: judging whether the first preset information exists in the first preset area or not.
In some embodiments, step 108 is performed when the first preset information exists in the first preset area; when the first preset information does not exist in the first preset area, step 117 is performed.
Step 108: marked as a first state.
In some embodiments, marking as the first state refers to marking the storage unit as the first state in RAM.
Step 109: judging whether the second preset area has second preset information or not.
In some embodiments, when the second preset information exists in the second preset area, step 110 is performed; when the second preset area does not have the second preset information, step 117 is performed.
Step 110: marked as a second state.
Step 111: judging whether third preset information exists in the third preset area or not.
In some embodiments, when the third preset information exists in the third preset area, step 112 is performed; when the third preset information does not exist in the third preset area, step 117 is performed.
Step 112: marked as a third state.
Step 113: judging whether fourth preset information exists in the fourth preset area or not.
In some embodiments, when the fourth preset information exists in the fourth preset area, step 114 is performed; when the fourth preset information does not exist in the fourth preset area, step 117 is performed.
Step 114: marked as the fourth state.
Step 115: judging whether all the storage units are traversed.
In some embodiments, step 117 is performed when all storage units have been traversed; when all the storage units have not been traversed, step 116 is performed.
Step 116: n=n+1.
After the execution of step 116, the routine returns to step 101.
Step 117: and END.
In some embodiments, performing step 117 means that the first detection interface call is complete.
Through the above detection flow, the states of all the storage units can be obtained through the first detection interface.
In some embodiments, the second detection interface, when invoked, is to:
determining whether a storage unit in an activated state exists according to the state of each storage unit;
when the storage unit in the activated state exists and the storage unit in the page change state does not exist, enabling the initialization interface to execute a first preset operation;
when the storage unit in the activated state exists and the storage unit in the page changing state exists, determining whether data to be carried in the page changing process is carried out, and when the data carrying is completed, enabling the initialization interface to execute a second preset operation;
when the storage unit in the activated state is not present and the storage unit in the page changing state is present, determining whether the data to be carried in the page changing process is carried out, and when the data is not carried, enabling the initialization interface to execute a third preset operation.
In some embodiments, the memory cell in the fourth state is marked in RAM as an active state memory cell.
In some embodiments, if there is a storage unit of one of the first state, the second state, and the third state, it is determined that there is a storage unit of the page-change state.
In some embodiments, if the storage unit changes from the second state to the third state, or if the storage unit is directly detected as being in the third state, it is determined that the data handling is complete.
For example, when the first storage unit is detected to be in the fourth state, the first storage unit is determined to be in the active state, and when the second storage unit is detected to be in the third state, the second storage unit is determined to be in the page-changing state, and the data transfer is completed.
In some embodiments, referring to fig. 5, fig. 5 is a schematic diagram illustrating a detection flow of the second detection interface according to the embodiment of the present application. As shown in fig. 5, the detection flow 200 performed when the second detection interface is invoked includes steps 201 to 213.
Step 201: the active storage unit is marked empty in RAM.
Step 202: searching the storage unit in the fourth state.
Step 203: it is determined whether a fourth state of storage unit is searched.
In some embodiments, step 204 is performed when a fourth state of the storage unit is searched; when the fourth state of the storage unit is not searched, step 205 is performed.
Step 204: and marking the searched storage unit in the fourth state as the storage unit in the activated state in the RAM.
Step 205: the storage unit in the backup state is marked as empty in RAM.
Step 206: and judging whether a storage unit in a page change state exists or not.
In some embodiments, step 207 is performed when there is a storage unit in the page state; when there is no storage unit in the page change state, step 212 is performed.
Step 207: and judging whether the data carrying is finished or not.
In some embodiments, upon completion of the data handling, step 208 is performed; when data handling is not completed, step 210 is performed.
Step 208: the storage unit in the page change state is marked as the storage unit in the backup state in the RAM.
Step 209: and enabling the initialization interface to execute a second preset operation.
Step 210: it is determined whether an active storage unit exists.
In some embodiments, step 212 is performed when there is an active storage unit; when there is no active storage unit, step 211 is performed.
Step 211: and enabling the initialization interface to execute a third preset operation.
Step 212: and enabling the initialization interface to execute a first preset operation.
In some embodiments, the first preset operation includes causing the second detection interface to end the detection process.
In some embodiments, the second preset operation includes: writing fourth information in a fourth preset area of the storage unit in the third state.
In some embodiments, the fourth information is used to identify that the data handling is completed and the storage unit in the original active state is erased during the page replacement process, and after writing the fourth information, the storage unit in the backup state is set as the storage unit in the active state in the RAM.
In some embodiments, when writing the fourth information into the fourth preset area of the storage unit in the third state, if the structure of the head information storage space of the storage unit is as shown in fig. 3, when the fourth information is not writable in the fourth preset area in the head information storage space of the storage unit, the fourth information is written into the fourth preset area in the tail information storage space of the storage unit.
In some embodiments, the second preset operation includes the following steps.
And erasing the storage unit in the activated state, and writing fourth information into a fourth preset area of the storage unit in the third state when the storage unit in the activated state is erased.
After writing the fourth information in the fourth preset area of the storage unit in the third state, the storage unit will be changed to the fourth state, and the storage unit in the fourth state will be marked as the storage unit in the activated state in the RAM, so that the storage unit in the original activated state is erased at this time.
It can be understood that erasing the storage unit in the original active state erases the first preset information, the second preset information, the third preset information and the fourth preset information in the storage unit.
In some embodiments, the third preset operation includes: and erasing all the storage units in the Flash which are not in the full-erasing state.
In some embodiments, in the process of defining data transfer, data is transferred from the first storage unit to the second storage unit, the storage unit having a page change state is stored, and the data to be transferred in the page change process is not transferred, which means that the second storage unit is in the first state or the second state, and the second storage unit is in the first state or the second state, which reflects that the data transfer process is not finished, but no storage unit having an active state is present at this time, and the process of transferring the data from the storage unit having an active state to the storage unit having a backup state means that the data in the original active state is damaged, the data to be transferred cannot be obtained from the first storage unit at this time, and the data written in the second storage unit is incomplete, so that all the storage units having a non-full erase state in Flash are erased, and Flash is initialized.
In some embodiments, when all the storage units in the Flash that are not in the full erase state are erased, a specific storage unit, for example, a storage unit that is set by a user and is not erased, may be skipped.
In some implementations, the internal interface includes a search interface that, when invoked, is to:
acquiring an information unit writing address;
reading the information unit according to the information unit writing address;
when the information unit is readable, the information unit writing address is offset by a first preset byte to be used as a new information unit writing address;
and returning to the execution step, and reading the information unit according to the information unit writing address.
In some embodiments, please refer to fig. 6 again, fig. 6 is a schematic diagram of an information unit provided in the embodiment of the present application. As shown in fig. 6, the information unit 1410 includes: header information 1411, description information 1412, storage address 1414, and verification information 1415.
Wherein the header information 1411 is used to identify the information element 1410, and the verification information 1415 is generated at least by the header information 1411, the description information 1412, and the storage address 1414 in the information element 1410.
In some embodiments, the verification information is a CRC check code.
In some embodiments, the information unit 1410 further comprises a first reserved extension space 1413 and a second reserved extension space 1416, the reserved extension space being used for subsequent scheme extensions, the first reserved extension space 1413 being located between the description information 1412 and the storage address 1414, the second reserved extension space 1416 being located below the verification information 1415.
In some implementations, the size of information element 1410 is constant, and the first preset byte is equal to the size of information element 1410; illustratively, assuming that information units 1410 occupy a total of 16 bytes of address, the first preset byte is 16 bytes, so that each information unit 1410 is checked in turn.
Through the information unit structure, the description information and the storage address are orderly stored in the information unit, so that the description information and the storage address can be conveniently searched later.
In some embodiments, the search interface, when invoked, is further to:
when the information unit is unreadable, acquiring a data unit writing address;
reading information of a second preset byte according to the data unit writing address, and when the non-writable state is determined according to the information of the second preset byte, shifting the data unit writing address by the second preset byte to serve as a new data unit writing address;
And returning to the execution step, and reading the information of the second preset byte according to the writing address of the data unit.
Through the steps, the data unit and the information unit can be comprehensively checked through the search interface at the same time, so that subsequent management operation of the data unit and the information unit can be conveniently executed.
In some embodiments, referring to fig. 7, fig. 7 is a schematic diagram of a search flow of a search interface provided in the embodiments of the present application. As shown in fig. 7, the search flow 300 includes the steps of: steps 301 to 312.
Step 301: the information unit write address is obtained.
In some embodiments, the retrieved information unit write address is the initial write address of the information unit, i.e. the address of the first information unit written when the storage unit is not writing an information unit.
In some embodiments, the information unit is written from a high address to a low address, and step 308 further includes shifting the writing address of the information unit by a first preset byte.
Step 302: it is determined whether the information unit write address is located within an address range of the storage unit.
In some embodiments, since an address offset is required for the write address of an information unit after reading the information unit, the address offset may be shifted out of the address range of the storage unit, so step 302 is performed to check whether the write address of the information unit is within the address range of the storage unit, and prevent the read data from being in error.
In some embodiments, if the information unit write address is not within the address range of the storage unit, the search interface stops working and feeds back an error message.
In some embodiments, if the information unit write address is within the address range of the storage unit, step 303 is performed.
Step 303: it is determined whether the information unit is readable.
In some embodiments, if the information units read are all null, e.g., 0x00 or 0xff, the information units are not readable.
In some embodiments, step 304 is performed when the information element is readable; when the information unit is not readable, step 309 is performed.
In some embodiments, when the information unit is not readable, not only step 309 is performed, but also the current information unit write address is recorded, and when a new information unit needs to be written, a new information unit is written from the current information unit write address.
The above steps thus enable not only checking the validity of the information unit, but also determining the write address at which a new information unit is written.
Step 304: the information unit is read.
Step 305: and judging whether the information unit is legal or not.
In some embodiments, the information unit is legal, which means that the data in the information unit meets the preset data requirement.
Illustratively, assuming that the structure of the information unit is the structure shown in fig. 6, the information unit readable means that the pre-verification information and the verification information 1415 generated according to the header information 1411, the description information 1412 and the storage address 1414 are the same, and the information unit 1410 has a corresponding data unit.
In some embodiments, if the information unit is legal, step 306 is performed.
In some embodiments, if the information unit is illegal, it may be that the data of the information unit is damaged, skip the information unit, read the next information unit, and execute step 308.
Step 306: the description information and the physical address in the information unit are read.
In some embodiments, the description information in the information unit is used to describe the data unit to which the information unit corresponds.
In some embodiments, the physical address in the information unit is an address of a data unit corresponding to the information unit, and the data unit corresponding to the information unit can be found through the physical address in the information unit.
Step 307: and storing the physical address and the corresponding relation between the description information and the physical address in the RAM.
In some embodiments, the physical address and the correspondence between the description information and the physical address are stored in the RAM, and then the user inputs the description information, for example, invokes a read interface in the external interface to directly query the physical address of the data unit corresponding to the description information, and data is read from the data unit stored in the RAM.
Step 308: the write address of the information unit is offset by a first predetermined byte.
In some embodiments, after performing step 308, the process returns to performing step 302 to check whether the information unit write address shifted by the first preset byte is within the address range of the storage unit.
In some embodiments, step 308 comprises the following steps.
The writing direction of the information unit is obtained, and the writing address of the information unit is shifted towards the writing direction of the information unit by a first preset byte.
Step 309: the data unit write address is obtained.
In some embodiments, the retrieved data unit write address is the initial write address of the data unit, i.e. the address of the first data unit written when the storage unit is not writing a data unit.
Step 310: and reading information of a second preset byte, and judging whether the information can be written or not.
In some embodiments, because the address occupied by the data unit is not fixed, unlike the information unit having a fixed size, only the second preset byte is read at a time.
In some embodiments, the size of the second preset byte depends on the minimum write unit of Flash; for example, if Flash writes a minimum of 8 bytes of data at a time, the second preset byte is 8 bytes.
In some embodiments, the information unit further stores information reflecting the size of the data unit, and after step 306, further includes storing the information reflecting the size of the data unit in RAM, so that when step 309 is performed, the complete data unit is sequentially read according to the information.
In some embodiments, if the second preset byte of information is read and it is determined that the writing is impossible, step 311 is performed; if the second predetermined byte is read and it is determined that writing is possible, step 312 is performed.
In some embodiments, writable refers to read information being empty.
Step 311: the write address of the data unit is offset by a second predetermined byte.
In some embodiments, step 311 comprises the following steps.
The writing direction of the data unit is obtained, and the writing address of the data unit is shifted towards the writing direction of the data unit by a second preset byte.
Step 312: and (5) completing the retrieval.
In some embodiments, step 312 further performs the step of: recording the current data unit writing address, and writing a new data unit from the current data unit writing address when the new data unit needs to be written.
In some embodiments, the internal interface further includes a page-change task interface that, when invoked, is to:
(1) Determining a storage unit in a backup state and a storage unit in an active state;
(2) Detecting the erasure state of the storage unit in the backup state, and erasing the storage unit when the storage unit is not in the full erasure state;
(3) Starting data carrying to carry the effective data in the storage unit in the active state into the storage unit in the backup state, and writing different preset information into the storage unit in the backup state according to the carrying progress;
(4) After the data handling is completed, the storage unit in the active state is erased.
In some embodiments, the external interface of the data management system includes a write interface for a user to call to perform data writing, and when the write interface is called, if the storage unit is full during writing, the write interface automatically calls the page-changing interface.
In some embodiments, when a certain storage unit is fully written, if there is no storage unit in the backup state, any storage unit that has been fully erased may be determined as a storage unit in the backup state.
In some embodiments, after power-up, flash needs to determine that one storage unit is an active storage unit, and when Flash is written with data, the Flash writes the data into the active storage unit.
In some embodiments, the data unit storage space of the active storage unit stores at least one data unit, and the sequence of data units stored from low address to high address is as follows: block1, block2, block3, block4, block5, block1, at this time, there are a total of 5 data units with different description information, and the data unit storage space includes 2 blocks 1 at the same time, defined as block1A and block1B respectively, at this time, the sequence of the data units stored from low address to high address is: block1A, block, block3, block4, block5, block1B, block1A and block1B are valid data, and need to be determined with reference to the writing order of the data units, for example, the writing order of the data units is defined to be written from a low address to a high address, and block1B is valid data because it is the latest written data unit, and at this time, the valid data in the data unit storage space is block2, block3, block4, block5, block1B.
In some embodiments, the data in the first storage unit is transferred to the second storage unit, and referring to fig. 8, fig. 8 is a schematic diagram of a page changing flow of the page changing interface according to the embodiment of the present application. As shown in fig. 8, the page-changing flow 400 includes the steps of: steps 401 to 406.
Step 401: a storage unit in a backup state and a storage unit in an active state are determined.
Step 402: and detecting the erased state of the storage unit in the backup state, and erasing the storage unit when the storage unit is not in the full-erased state.
Step 403: when writing data into the first storage unit, if the available writing space of the first storage unit is insufficient, writing first preset information into a first preset area of the second storage unit to identify that the second storage unit is in a first state.
Step 404: writing second preset information in a second preset area of the second storage unit to identify the second storage unit as a second state, determining valid data in the first storage unit, and starting writing the valid data into the second storage unit.
Step 405: and after the writing of the effective data is completed, writing third preset information in a third preset area of the second storage unit to identify that the second storage unit is in a third state.
Step 406: and after the data in the first storage unit is erased, writing fourth preset information into a fourth preset area of the second storage unit to mark the second storage unit as a fourth state.
In some embodiments, the storage unit is a logical sector (logic sector), and the Flash in the present application includes at least two logical sectors, so that when one logical sector is full, valid data can be carried into the other logical sector.
In some embodiments, erasing the data in the first storage unit refers to changing the data in the first storage unit to a null value, e.g., 0x00 or 0xff.
In some embodiments, after step 406 is performed, the present application checks whether the reserved space 1150 is properly filled; wherein filling correctly refers to each address of the reserved space 1150 being filled with preset data, e.g., 0x00.
Through the page changing interface, preset information is written into the preset area of the storage unit in the backup state in the page changing process, so that the progress of the writing process is recorded, and even if the writing process is interrupted due to unexpected conditions, the writing process before unexpected conditions can be recovered according to the writing conditions of the preset information after the re-electrification.
In some embodiments, referring to fig. 9, fig. 9 is a schematic structural diagram of a micro control unit according to an embodiment of the present application. As shown in fig. 9, the micro control unit 3000 in fig. 9 includes the data management system of Flash as described above, that is, includes Flash10000 and a data management module 20000.
In some embodiments, the data management module 20000 is a program module running in the micro control unit 3000.
In some embodiments, referring to fig. 10, fig. 10 is a schematic structural diagram of a vehicle according to an embodiment of the present application. As shown in fig. 10, the vehicle 4000 in fig. 10 includes the micro control unit 3000 as described above.
In some embodiments, vehicle 4000 includes at least one micro-control unit 3000 as described above.
In summary, the present application provides a data management system, a micro control unit and a vehicle of Flash, where the system includes: the Flash comprises at least one storage unit, wherein the storage unit at least comprises a data unit storage space and an information unit storage space, the data unit storage space is used for storing data units, the information unit storage space is used for storing information units, the data units are in one-to-one correspondence with the information units, and the information units at least comprise corresponding description information and storage addresses of the data units; and the data management module comprises an external interface for a user to call and an internal interface for the data management system to call internally. According to the Flash management method and device, the data stored in the Flash can be better managed through the structure of the Flash in the data management system and the provided internal and external interfaces.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; although the present application has been described in detail with reference to the foregoing embodiments, one of ordinary skill in the art will appreciate that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not drive the essence of the corresponding technical solutions to depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (12)

1. A data management system for Flash, the system comprising:
the Flash comprises at least one storage unit, wherein the storage unit at least comprises a data unit storage space and an information unit storage space, the data unit storage space is used for storing data units, the information unit storage space is used for storing information units, the data units are in one-to-one correspondence with the information units, and the information units at least comprise corresponding description information and storage addresses of the data units;
and the data management module comprises an external interface for a user to call and an internal interface for the data management system to call internally.
2. The data management system of claim 1, wherein the internal interface comprises an initialization interface, a first detection interface, and a second detection interface; wherein,
the initialization interface is used for:
invoking the first detection interface; the first detection interface is used for determining the state of each storage unit when being called;
invoking the second detection interface; and the second detection interface is used for enabling the initialization interface to execute different preset operations according to the state of each storage unit when being called.
3. The data management system according to claim 2, wherein the storage unit includes a header information storage space including a first preset area, a second preset area, a third preset area, and a fourth preset area; wherein,
when the first preset area is written with first preset information and the rest preset areas are not written with preset information, the storage unit is in a first state;
when the first preset area is written with first preset information, the second preset area is written with second preset information, and the rest preset areas are not written with preset information, the storage unit is in a second state;
When the first preset area is written with first preset information, the second preset area is written with second preset information, the third preset area is written with third preset information, and the fourth preset area is not written with fourth preset information, the storage unit is in a third state;
when the first preset area is written with first preset information, the second preset area is written with second preset information, the third preset area is written with third preset information, and the fourth preset area is written with fourth preset information, the storage unit is in a fourth state.
4. A data management system according to claim 3, wherein the first detection interface, when invoked, is operable to:
detecting a head information storage space of an Nth storage unit, and determining a state of the Nth storage unit according to information in the first preset area, the second preset area, the third preset area and the fourth preset area; wherein n=1 in the initialized state;
let n=n+1, and return to the execution step to detect the header information storage space of the nth storage unit.
5. A data management system according to claim 3, wherein the second detection interface, when invoked, is operable to:
Determining whether a storage unit in an activated state exists according to the state of each storage unit;
when the storage unit in the activated state exists and the storage unit in the page change state does not exist, enabling the initialization interface to execute a first preset operation;
when the storage unit in the activated state exists and the storage unit in the page changing state exists, determining whether data to be carried in the page changing process is carried out, and when the data carrying is completed, enabling the initialization interface to execute a second preset operation;
when the storage unit in the activated state is not present and the storage unit in the page changing state is present, determining whether the data to be carried in the page changing process is carried out, and when the data is not carried, enabling the initialization interface to execute a third preset operation.
6. The data management system of claim 5, wherein the second preset operation comprises:
writing fourth information in a fourth preset area of the storage unit in the third state.
7. The data management system of claim 5, wherein the third preset operation comprises:
and erasing all the storage units in the Flash which are not in the full-erasing state.
8. The data management system of claim 1, wherein the internal interface comprises a search interface that, when invoked, is to:
acquiring an information unit writing address;
reading the information unit according to the information unit writing address;
when the information unit is readable, the information unit writing address is offset by a first preset byte to be used as a new information unit writing address;
and returning to the execution step, and reading the information unit according to the information unit writing address.
9. The data management system of claim 8, wherein the search interface, when invoked, is further operable to:
when the information unit is unreadable, acquiring a data unit writing address;
reading information of a second preset byte according to the data unit writing address, and when the non-writable state is determined according to the information of the second preset byte, shifting the data unit writing address by the second preset byte to serve as a new data unit writing address;
and returning to the execution step, and reading the information of the second preset byte according to the writing address of the data unit.
10. The data management system of claim 1, wherein the internal interface further comprises a page-change task interface that, when invoked, is to:
Determining a storage unit in a backup state and a storage unit in an active state;
detecting the erasure state of the storage unit in the backup state, and erasing the storage unit when the storage unit is not in the full erasure state;
starting data carrying to carry the effective data in the storage unit in the active state into the storage unit in the backup state, and writing different preset information into the storage unit in the backup state according to the carrying progress;
after the data handling is completed, the storage unit in the active state is erased.
11. A micro-control unit, characterized in that it comprises the data management system of Flash according to claim 1.
12. A vehicle, characterized in that it comprises a microcontrol unit according to claim 11.
CN202410147851.2A 2024-02-02 2024-02-02 Data management system, micro-control unit and vehicle of Flash Pending CN117687580A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410147851.2A CN117687580A (en) 2024-02-02 2024-02-02 Data management system, micro-control unit and vehicle of Flash

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410147851.2A CN117687580A (en) 2024-02-02 2024-02-02 Data management system, micro-control unit and vehicle of Flash

Publications (1)

Publication Number Publication Date
CN117687580A true CN117687580A (en) 2024-03-12

Family

ID=90132387

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410147851.2A Pending CN117687580A (en) 2024-02-02 2024-02-02 Data management system, micro-control unit and vehicle of Flash

Country Status (1)

Country Link
CN (1) CN117687580A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080109589A1 (en) * 2004-04-28 2008-05-08 Toshiyuki Honda Nonvolatile Storage Device And Data Write Method
CN104461401A (en) * 2014-12-25 2015-03-25 珠海煌荣集成电路科技有限公司 Data reading and writing management method and device for SPI flash memory
US20170090783A1 (en) * 2015-09-30 2017-03-30 Kabushiki Kaisha Toshiba Storage system that tracks mapping to a memory module to be detached therefrom
US20170220252A1 (en) * 2016-01-29 2017-08-03 Faraday&Future Inc. Flash emulated eeprom wrapper
CN113568579A (en) * 2021-07-28 2021-10-29 深圳市高川自动化技术有限公司 Memory, data storage method and data reading method
CN116225985A (en) * 2022-12-17 2023-06-06 浙江凌骁能源科技有限公司 SOC parameter power-down nonvolatile storage method and device and computer equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080109589A1 (en) * 2004-04-28 2008-05-08 Toshiyuki Honda Nonvolatile Storage Device And Data Write Method
CN104461401A (en) * 2014-12-25 2015-03-25 珠海煌荣集成电路科技有限公司 Data reading and writing management method and device for SPI flash memory
US20170090783A1 (en) * 2015-09-30 2017-03-30 Kabushiki Kaisha Toshiba Storage system that tracks mapping to a memory module to be detached therefrom
US20170220252A1 (en) * 2016-01-29 2017-08-03 Faraday&Future Inc. Flash emulated eeprom wrapper
CN113568579A (en) * 2021-07-28 2021-10-29 深圳市高川自动化技术有限公司 Memory, data storage method and data reading method
CN116225985A (en) * 2022-12-17 2023-06-06 浙江凌骁能源科技有限公司 SOC parameter power-down nonvolatile storage method and device and computer equipment

Similar Documents

Publication Publication Date Title
US6687784B2 (en) Controller for controlling nonvolatile memory unit
US7171536B2 (en) Unusable block management within a non-volatile memory system
US6381176B1 (en) Method of driving remapping in flash memory and flash memory architecture suitable therefor
US8527730B2 (en) Data updating method, memory system and memory device
US6388919B2 (en) Memory controller for flash memory system and method for writing data to flash memory device
JP5162535B2 (en) Method and memory system using memory system
US8006030B2 (en) Memory controller for identifying the last valid page/segment in a physical block of a flash memory
CN102880521B (en) The method and apparatus of management block and access data page in non-volatile memory device
CN106648463B (en) Nand Flash block management method and system
CN101777013A (en) Solid state disk and data read-write method
US6839798B1 (en) Flash memory capable of storing frequently rewritten data
US9552287B2 (en) Data management method, memory controller and embedded memory storage apparatus using the same
CN112596668A (en) Bad block processing method and system for memory
US20090164869A1 (en) Memory architecture and configuration method thereof
JPH07306922A (en) Ic memory card and its checking method
CN101246429A (en) Electronic systems using flash memory modules as main storage and related system booting methods
CN110083305B (en) Memory system and operating method thereof
KR101826778B1 (en) EEPROM Emulation Method Considering implementation of Flash Life Cycle and Performance Improvement
US20180052635A1 (en) Electronic control apparatus and information storage method for the same
CN117687580A (en) Data management system, micro-control unit and vehicle of Flash
JP4794530B2 (en) Semiconductor device and mobile phone
US6535442B2 (en) Semiconductor memory capable of debugging an incorrect write to or an incorrect erase from the same
US8381023B2 (en) Memory system and computer system
CN110781031B (en) Controller data recovery method and device, controller and automobile
CN109144409B (en) Data processing method and device, storage medium and data system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination