Detailed Description
The technical solutions of the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is apparent that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
A storage method according to an embodiment of the present disclosure will be described with reference to fig. 1. The method is applied to a memory, an execution subject of the method can be a processing chip corresponding to the memory, and corresponding calculation logic can be preset in the processing chip so as to realize the storage method based on the calculation logic. The storage method comprises the following specific steps.
S110, initializing the memory based on the storage formats corresponding to different storage areas in the memory.
The memory may be a module for implementing data storage, and may specifically be a random access memory RAM, which may be used to store program instructions for operation of the device
In some specific application scenarios, the memory may be a small memory chip NVRAM, and is applied to an embedded device, for example, a meter, an internet of things device, a low-power device, and the like, which relate to the field of remote acquisition control. The type of the memory and the application environment in practical application are not limited to the above examples, but are not limited thereto.
The memory can comprise different storage areas, and the different storage areas can be used for storing different types of data and have different storage authorities. For example, data in some storage areas may not be altered and data in some storage areas may be read and written.
Different storage areas can be corresponding to different storage formats, and the storage formats can be used for describing the data arrangement mode and the data modification authority adopted when the storage areas respectively store data. After the different storage areas are initialized based on the storage format, the corresponding storage areas can be combined with corresponding requirements and cooperation among the different storage areas to better realize data storage.
In some embodiments, the storage area may include at least one of a partition table, a directory table, a global variable storage area, a buffer variable storage area, an application data storage area, and a reserved storage area.
In some practical application scenarios, the initialization is performed for a storage area, which may be performed for a first partition including a partition table, a directory table, a global variable storage area, and a buffer variable storage area. As shown in fig. 2, the memory includes a partition table, a directory table, a global variable storage area, a first partition including a buffer variable storage area, other partitions including an application data storage area, and a reserved partition including a reserved storage area.
The partition table is mainly used for supporting dynamic adjustment of the memory and management of the memory, and is generally fixed as the first 4 bytes of the partition, and is divided into a fixed partition and a variable partition. The fixed partition and the variable partition may correspond to different storage space sizes. Wherein the fixed partition corresponds to platform rights, which can be modified generally only at factory settings or at factory restoration operations with higher rights. The variable partition modification can belong to application authority, and can be dynamically adjusted by script files or command modes when corresponding modification requirements exist for the application or service. Variable partitions are typically used to store real-time data, temporary variables, etc. that can continue the execution of a service after a device is restarted.
The directory table is mainly used for storing corresponding information corresponding to the directory, such as directory name, file location, file size limitation, etc., which can be directly viewed in the directory. The information in the directory is used to indicate file deposit information in the memory.
The global variable storage area is mainly used for storing some variables which need to be reused when the restart or the power failure is realized, and the system architecture can conservatively use the variables under the condition that external storage and execution storage cannot be normally used. The global variable storage area can effectively utilize and store data when not depending on media such as a file system which can make errors or lose the data.
The buffer variable storage is mainly used for storing index information of a buffer area of each storage medium, and can be, for example, a directory index, an address index of a RAM, and the like, so as to provide interaction between applications.
When the partition table is initialized, corresponding initialization operation can be realized based on the storage requirements of the storage areas, so that different application environments can be better targeted.
In some embodiments, to ensure the storage effect of the memory, the storage space in the memory is saved, the number of sectors and the number of sectors bytes may be used for the partition in the memory, the number of sectors bytes may be defined by a script file or an implicit fixed number of sectors, the partition size is the product of the number of sectors and the number of sectors bytes, the actual value of the number of sectors may be implemented by adding 1 to the value of the sector bit field, for example, 2 bits of 0 represents 1 sector, and if the number of corresponding sectors bytes is 512 bytes, the size corresponding to the partition is 512 bytes.
Through the method, the storage space in the memory is effectively planned, the storage performance of the memory is improved, and the business processing effect based on the memory is improved.
And S120, checking the format of the initialized memory.
After initializing the memory, the format of the memory may be verified. The purpose of the verification is to ensure that the initialized format and the storage function are normal. Specifically, verification may be performed for each partition, so as to prevent data in different storage areas from being illegally modified. The check value adopted by the check needs to be written back frequently, so that the byte which needs to be provided with isolation can be estimated to be stored according to the service life of the medium in the implementation process.
In some embodiments, when checking the format of the memory, the CRC algorithm may be used to check each partition. The CRC check algorithm is a data transmission error detection function, performs polynomial computation on data, and attaches the obtained result to the back of the frame, and the receiving device also performs a similar algorithm to ensure the correctness and integrity of data transmission. Specifically, for example, a check code may be added after the frame to be sent, where the check code enables the generated frame to be divided by a specific number, and if the frame is found to be unable to be divided in the check process, it indicates that the data is modified, otherwise, it indicates that the data is correct.
In practical application, other verification methods can be adopted to verify the format of the memory, and the description is omitted.
And S130, storing the format information of the initialized memory to a backup storage medium under the condition that the verification is passed.
Under the condition that verification is passed, the storage can be stored based on a normal format, and the initialization of the storage is normally completed, so that in order to ensure the fault tolerance in the subsequent process and improve the reliability of actual data, the format information of the initialized storage can be stored in a backup storage medium. If the storage medium in the storage fails or the data is lost in the subsequent process, the backup data stored in the storage can be restored based on the format information in the backup storage medium, and the storage can be restored to obtain the available storage.
In some embodiments, the backup storage medium includes at least one of a single-chip internal storage, a single-chip external storage, an operation storage medium, a mobile storage, and a cloud storage. The internal storage of the single chip microcomputer can be other storage media in the single chip microcomputer, which are set by the memory, and the external storage of the single chip microcomputer can be storage media contained in other devices connected with the single chip microcomputer, so that the format information of the memory can be backed up effectively under the condition that data transmission between the single chip microcomputer and the single chip microcomputer can be realized. The operating storage medium may be a storage medium that directly interacts with the processor, such as a volatile storage medium, e.g., cache, memory, etc. The removable storage may be a removable storage device such as a sd card, a usb disk, or a removable storage medium. Cloud storage can be stored by accessing the singlechip into a network for transmission to a cloud. The storage medium can realize the backup effect for the format information, and the practical application is not limited to the above example, and will not be repeated here.
By storing the format information to the backup storage medium, the reliability of the actual data can be effectively ensured, the partition can be effectively restored when the storage is in error, and the usability of the device is improved.
In some embodiments, the directory table of the memory may also be checked after the initialized memory format information is stored in the backup storage medium. Since the directory table is used to store the received corresponding data when the subsequent memory receives the data, it can be further checked. The specific checking process may be a checking of the storing function of the directory table and/or a checking of the creating function of the directory table and/or a determination of whether a storage medium is present and/or a determination of whether the size of the storage file exceeds a limit size.
The storage function of the check directory table may be to determine whether data can be stored in the directory table, the creation function of the check directory table may be to determine whether a new directory can be constructed in the directory table, determine whether a medium exists or not, whether a storage medium corresponding to the directory table can be searched or not can be searched, and determine whether the size of a storage file exceeds a limit size or not may be to determine whether the data stored in the current directory exceeds a preset upper limit of the storage size.
Under the condition that the size of the storage file exceeds the limit size, in order to ensure that corresponding information can be effectively recorded in the subsequent process, some information in the directory table can be liberated, and specifically, the storage file can be deleted and/or compressed based on the storage date corresponding to the storage file. Based on the corresponding storage date of the storage file, the storage file stored earlier can be deleted, and the storage file can be compressed to free a certain storage space. The specific implementation process may be operated based on the actual application environment, which is not described herein.
If corresponding data is lost in the memory or the memory itself fails in the subsequent process, the data in the backup storage medium can be transferred to the memory or other storage media for replacement, and normal execution of work is continued, so that smooth progress of the storage process of corresponding service is ensured.
And S140, after the storage data is input into the memory, synchronizing the storage data to an operation storage medium, wherein the operation storage medium comprises a random access memory.
After the stored data is entered in the memory, the stored data may be synchronized into the operating storage medium. The running storage medium may be a Random Access Memory (RAM), such as a cache, a memory, etc. that performs direct data interaction with the processor, and often has a fast data processing speed, and after synchronizing the data in the memory, application access and concurrent access may be accelerated. A step of
When writing is needed, exclusive locking can be performed on data in the memory, and after the critical section is controlled. After the steps are finished, the method can be used for circularly waiting for receiving the dynamic storage state, is matched with a hardware backup battery or a super capacitor, is used for differentially treating the written data, and can be used for writing the data temporarily written in the operation storage into a nonvolatile medium after the same area is accumulated to a certain size or the timing transfer time meets the condition, so that the medium with a high erasing life like ferroelectric FRAM can be properly and timely written under the condition of ensuring the performance. Through the steps, the high-efficiency utilization of the data in the memory is ensured, the effective backup of the data is also ensured, and the processing of corresponding business is facilitated.
In some embodiments, after the stored data is entered in the memory, it may be managed based on the variable data identification. The method comprises the steps of determining a data item type corresponding to storage data, wherein the data item type comprises at least one of a data item, a basic data item and a composite data item, the basic data item is used for identifying data content, the data item is used for referring to the basic data item, the composite data item is defined through an independent storage area, and storage and management of the storage data are carried out based on the data item type.
The data items are divided into composite data items, basic data items and data items, wherein the basic data items are used for identifying data contents, the data items usually refer to the basic data items to express data storage, the composite data items are defined by independent 4 bytes, the basic data items are usually only related to protocol types and the like and are generally unchanged or rarely changed, the data items are used for reading and writing one data item and Identification (ID) definition of a buffer zone, the data items generally comprise but are not limited to data item types, groups, numbers, reference data items, lengths and the like, the empty data items or invalid data item IDs are uniformly identified as 0xEEEEEEEE, and when the data items are used, bytes occupied by the IDs are calculated, and bytes of occupied data areas are not calculated.
In some embodiments, after the stored data is input into the memory, the stored data in the memory may also be managed based on a script file and/or a unified data structure and/or an information file.
The script file may be a file preset in the processing chip when processing some services, and is used for processing some specific services. The script file is usually a json file, is small and light, is very suitable for the occasion of embedded product migration and traffic communication, and can be flexibly configured, maintained and managed by using json images and arrays to cooperate with data item definition.
The unified data structure is matched with unified data storage, so that program and data separation, application and application can be achieved, the unified data structure is transferred between the application and the system, the unified data structure content can be constructed by the unified data storage, thus, data transmission and merging of all versions can be realized, storage and reading, analysis and construction can realize headless property, all data are realized based on data item IDs, when reporting, the data are summarized into a data script format which is finally issued, when storing, different versions of data items can be obtained, when using an object, only the current version format is seen, the unified data structure reduces test pressure and expandability, and is convenient to use, the parameter pointer is added by the basic data structure type, and meanwhile, the unit test and the subsequent problem investigation can be supported according to the using stage.
The information file is mainly divided into curve files and parameter files, and basically has similar definition, including a name space, a file name and a file unified storage Identification (ID) definition, wherein the name space is defined by the file unified storage Identification (ID); the method comprises the steps of recording a data item, wherein each data item corresponds to a directory, a curve file name is obtained by adopting density (1 byte) +the byte number of the data item (2 nibbles) +an index number (nibbles) +initial (3 bytes) +identification (1 byte), if the data item is changed, a new curve file is generated, the data item is changed to represent one measurement data, one measurement point possibly comprises a plurality of measurement data, the measurement data is the minimum unit, the data item change comprises adding, deleting and modifying the measurement data, an ID is adopted to uniquely identify the data item, the curve file comprises a first 256 bytes of file head of each curve file and a data area, the byte number is represented by adopting a two-byte 16 system, the maximum support data item length 2047, if the byte number of the data item exceeds 2047, the two data items are required to be disassembled for storage, the index number is represented by adopting a byte 16 system, the same data length under the same object is changed by adopting a maximum byte 16 system, the initial three byte 16 systems represent density serial numbers, the highest bit 1bit is used to represent whether the base58 system is used for representing the density serial number, the rest 11 bits can represent the density of the current serial number, when the current curve item can be generated, and the current serial number can be restarted when the density of the data item is changed from the initial value of 2048.
In some embodiments, the memory may also be verified based on a certain frequency, and in the event of a failure of the memory's storage medium, the storage medium of the memory may be replaced with a removable storage medium. The mobile storage medium can be a removable storage medium, and data transmission is realized between the mobile storage medium and the singlechip through an interface on the singlechip. When the storage medium of the memory fails, the storage of data cannot be realized, and in order to ensure the continuation and effective execution of the work, the memory may be replaced with a removable storage medium. The processing mode of the mobile storage medium can refer to the processing mode of the memory in the steps so as to improve the fault tolerance in the actual working process.
The above method is described based on a specific scenario example, as shown in fig. 3, the core component may be a storage portion corresponding to a single chip microcomputer, including a single chip microcomputer internal storage (MCU ROM), an operation storage (RAM or cache), an external storage (SPI norflash), an operation storage (QSPI XIP Flash), and a memory (NVRAM). The core component is connected with a service component, and comprises an intersection chip (RN 8302), an analog sampling (ADI), a remote signaling (Pin Input) and Other Input/output (Other IO) which are used for transmitting corresponding data to the core component. The interaction component comprises a serial display (SPI LCD) and a pipe teaching Key (Pin Key) and is used for receiving corresponding external instructions and transmitting the corresponding external instructions to the core component. Removable devices include memory cards (SDCard) and U disk (USB sevice) for use as alternative storage devices.
According to the method, the storage method is firstly initialized based on the storage formats corresponding to different storage areas, so that the initialized storage can adapt to the requirements corresponding to different storage formats. After initialization, the memory is checked to ensure the availability of the memory. By storing the initialized format information of the memory into the backup storage medium, the requirement of the storage format corresponding to the memory is reserved, so that the memory can be effectively restored when the memory is temporarily unavailable. After the storage data is input into the memory, the storage data is synchronized to the operation storage medium, and under the condition that the operation storage medium is a random access memory, the operation storage medium has faster data interaction capability, so that the effective utilization of the storage data is ensured. According to the method, under the condition that hardware individuation requirements are not carried out on the memory, the memory can adapt to different storage requirements, different functions can be realized, interactive processing of data is rapidly and effectively completed, service execution efficiency is improved, and use experience is improved.
Based on the above storage method, the embodiment of the present disclosure further provides a storage system. The memory system may include a memory and a processing chip corresponding to the memory.
The memory may be the memory in the example corresponding to fig. 1. The processing chip can realize the following steps based on the memory, namely initializing the memory based on storage formats corresponding to different storage areas in the memory, checking the format of the initialized memory, storing format information of the initialized memory to a backup storage medium under the condition that the check is passed, synchronizing the storage data to an operation storage medium after the storage data is input into the memory, and the operation storage medium comprises a random access memory.
While the process flows described above include a plurality of operations occurring in a particular order, it should be apparent that the processes may include more or fewer operations, which may be performed sequentially or in parallel (e.g., using a parallel processor or a multi-threaded environment).
While the process flows described above include a plurality of operations occurring in a particular order, it should be apparent that the processes may include more or fewer operations, which may be performed sequentially or in parallel (e.g., using a parallel processor or a multi-threaded environment).
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification embodiments may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present description embodiments may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present embodiments may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The embodiments of the specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments. In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the embodiments of the present specification. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and variations of the present application will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the application are to be included in the scope of the claims of the present application.