CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims priority to German Application No. 10 2020 108 101.4 filed Mar. 24, 2020, the entire disclosure of which is incorporated by reference.

FIELD

The present disclosure relates to an apparatus for storing data in a non-volatile memory and corresponding methods.

BACKGROUND

In information technology, non-volatile memories refer to data memories whose information is retained permanently—that is, even when the device that includes the memory is not in operation or the memory is no longer supplied with power. In contrast to volatile memories, such as main memory or the registers of a CPU, non-volatile memories are used to store configuration data, user profiles, passwords, certificates or other data that can be changed during operation and are retained after power-down to be used again after a restart.

For flexible and convenient access to the data in a non-volatile memory, it can be organized in a defined manner. The most common organizational structure is a file system, where one area of memory contains the actual payload data and another area contains a description of a structure that catalogs the partitioning of the payload data. A file system or other complex storage structure has the advantage that large amounts of data can be stored in a structured way and can be processed more easily. For example, file systems allow random access to the data as well as complex management structures such as directory trees in which the data can be organized.

However, as the complexity of the organizational structure of the memory increases, so does the effort required to access the memory. In addition, the organizational structure itself requires storage space that is no longer available for user data.

However, flexible and convenient access via a file system or other complex storage structure is not a priority for every application. For smaller systems, such as embedded systems that perform a dedicated task, other properties are important. For example, in the case of devices that record log and diagnostic data on non-volatile memories, it is important that the data can be stored safely, consistently and traceably in the non-volatile memory and that this can also be guaranteed in unstable situations (transaction safety). That is, data loss in the event of a power failure should be as small as possible and should not affect the overall consistency of the written data. At the same time, the additional effort required for this must not be too high in order to be feasible even for devices with low computing capacity and memory.

SUMMARY

It is an object to provide an apparatus and a corresponding method for storing data in a non-volatile memory, which can be easily implemented even in systems with low computing capacity and low memory. Further, it is an object to provide an apparatus and a corresponding method that ensure high transaction safety and inherent consistency of the stored data. Yet further, it is an object to ensure transaction safety and inherent consistency even in the event of a power failure.

According to an aspect of the present disclosure there is provided an apparatus for storing data in a non-volatile memory, comprising a data processing unit configured to acquire data blocks, terminate each data block of the data blocks with a terminating element, and assemble the terminated data blocks into a serial data stream, and a memory unit configured to sequentially write the serial data stream to the non-volatile memory, wherein the terminating element is variable between a first code word and at least one second code word, and the data processing unit is configured to switch between using the first code word and the second code word as the terminating element in response to the non-volatile memory having been written to completely by the memory unit.

According to a further aspect of the present disclosure, there is provided a method for storing data in a non-volatile memory. The method, comprising:acquiring data blocks;terminating each data block of the data blocks with a terminating element;assembling the terminated data blocks into a serial data stream;writing the serial data stream to the non-volatile memory;
wherein the terminating element is variable between a first code word and a second code word, and terminating the data blocks includes changing the use of the first code word and the second code word as the terminating element in response to the non-volatile memory having been written to completely.

According to a further aspect of the present disclosure, there is provided a method for reading data from a non-volatile memory. The method, comprising:reading a first sequential data stream from the non-volatile memory;locating a first code word and a second code word defining a transition in the first sequential data stream;setting an initial start position based on the detected transition;reading a second sequential data stream starting at the initial start position;splitting the second sequential data stream into data blocks based on the first code word or the second code word; anddetecting a change between the first code word and the second code word in the second sequential data stream.

It is thus an idea of the present invention to write to the non-volatile memory sequentially without relying on an explicit organizational structure of the data memory for this purpose. Rather, it is an idea to impose an implicit organizational structure on the serial data stream, which is based on the abstract data type of a queue/FIFO.

The memory unit writes to the non-volatile memory sequentially. This has the advantage that all memory cells are written to equally. In this way, the maximum write cycles can be utilized for non-volatile memories that have a limited service life, such as flash memory. Without having to rely on methods such as wear-leveling, the memory can be optimally written to.

The serial data stream can also be easily used in serial protocols (e.g. RS232, Ethernet, etc.) without the need for additional computational effort for conversion and serialization. Thereby, the apparatus is suitable for embedded systems that have limited resources and no additional units for implementing communication protocols.

The data processing unit imprints the implicit organizational structure on the serial data stream with minimal additional effort. Depending on the application, one or two additional bytes per data block are sufficient to implement the implicit organizational structure. Together with the omission of an explicit organizational structure, the memory is utilized almost optimally.

In addition, the implicit organizational structure has the advantage of inherent consistency, i.e., the structure is intrinsically very robust and remains functional overall if individual memory cells are defective. Furthermore, the combination of sequential writing with the simple implicit organizational structure reduces the necessary program steps per write operation (transaction). Thereby, a high level of transaction safety can be ensured, which reduces data loss in the event of an unexpected power failure. The apparatus is thus highly suitable for storing safety-relevant log or diagnostic data, the recording of which is particularly important in the case of unstable states, e.g. in order to enable a controllable and seamless audit trail.

In a further refinement, the memory unit may be configured to sequentially address the non-volatile memory in order to write thereto completely in a sequential manner. The memory unit can write to the non-volatile memory without an explicit organizational structure.

By means of iterative addressing, the memory unit can easily and efficiently access the memory and realize sequential writing. Thus, the refinement contributes to a further reduction in the additional effort necessary for storing on the non-volatile memory.

In a further refinement, the memory unit may be configured to sequentially read the non-volatile memory, identify a change of the terminating element to determine an initial start position, and begin sequentially writing the serial data stream at the initial start position.

According to this refinement, the memory unit may first determine an initial start position, for example after a restart. Due to the implicit organizational structure, only a single sequential search run is necessary for this. The initial start position is the position after the terminating element of the last written element. The last element written can be identified from the sequentially read data by a transition from the first code word to the second code word or vice versa. An initial starting position can thus be determined quickly and efficiently. A reboot, which is frequently necessary in the case of embedded systems, can therefore be performed quickly and efficiently with essentially no loss of data.

In a further refinement, the memory unit may be configured to store a current writing position in a volatile memory.

By storing a current writing position, the memory unit can write new data to memory after a write pause without a prior search for the writing position. The current write position corresponds to a position after the terminating element of the last written element. Thereby, a write operation (transaction) can be executed particularly efficiently and with only a few operations, since the physical write to the memory can be started immediately.

In a further embodiment, the memory unit may be configured to store the current writing position in a volatile memory, and only if a value for the current writing position is available from the volatile memory, to write the serial data stream at the current writing position.

According to this embodiment, the memory unit continues a write operation at the current writing position only when a value for the current position can be obtained from the volatile memory. If no value is stored, the memory unit can determine an initial write position from the already stored data by a search and continue the write process at the position determined by the search. Storing the current position in a volatile memory thus enables continuous writing of the memory during operation and forces a search run only if the volatile memory has been reset, e.g. due to a restart. This refinement thus contributes to an increase in efficiency in a safe manner.

In a further refinement, the data processing unit may be configured to mask characters in the data blocks corresponding to the first code word or the at least second code word.

According to this refinement, it can be ensured that there are no characters in the data that correspond to the terminating elements and would thus lead to an inconsistency of the implicit organizational structure. Thereby, data can be stored independently of the choice of terminating elements, or the terminating elements can be chosen independently of the data to be stored.

In a further refinement, the data processing unit may be configured to generate a checksum for each data block of the data blocks and append it to the respective data block.

According to this refinement, each data block is thus provided with a checksum. The data can thus be easily secured against falsification without changing the implicit organizational structure. Thereby, the reliability of the data can be increased. The refinement thus specifically enables the apparatus to be uses as a log and diagnostic memory, which ensures a prober audit trail.

In a further refinement, the data processing unit may be configured to encrypt each data block of the data blocks.

According to this refinement, the data can be secured against manipulation and unauthorized access despite the lack of an explicit organizational structure. The refinement thus further enables the apparatus to be uses as a log and diagnostic memory.

In a further refinement, the data blocks may have a variable length.

The implicit organizational structure allows variable-length data to be stored without further modifications. Thereby, the available memory can be optimally utilized.

It goes without saying that the features mentioned above and those to be explained below can be used not only in the combination indicated in each case, but also in other combinations or on their own, without leaving the scope of the present invention.

