CN113126883B - Data processing method, system and storage medium - Google Patents

Data processing method, system and storage medium

Info

Publication number
CN113126883B
CN113126883B CN201911400485.2A CN201911400485A CN113126883B CN 113126883 B CN113126883 B CN 113126883B CN 201911400485 A CN201911400485 A CN 201911400485A CN 113126883 B CN113126883 B CN 113126883B
Authority
CN
China
Prior art keywords
read
data
write
storage medium
external storage
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.)
Active
Application number
CN201911400485.2A
Other languages
Chinese (zh)
Other versions
CN113126883A (en
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.)
Shenzhen TCL New Technology Co Ltd
Original Assignee
Shenzhen TCL New Technology Co Ltd
Filing date
Publication date
Application filed by Shenzhen TCL New Technology Co Ltd filed Critical Shenzhen TCL New Technology Co Ltd
Priority to CN201911400485.2A priority Critical patent/CN113126883B/en
Publication of CN113126883A publication Critical patent/CN113126883A/en
Application granted granted Critical
Publication of CN113126883B publication Critical patent/CN113126883B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a data processing method, which comprises the following steps: according to the data processing method provided by the embodiment of the invention, the read-write middle layer is arranged between the device driving layer and the device application layer, the read-write middle layer is utilized to realize the read-write of the data in the external storage medium, and the application layer acquires the data stored in the external storage medium based on the read-write middle layer and reads the data into the external storage medium through the read-write middle layer, so that the defects that the data processing efficiency of the application layer is low and the occupied time is long because the application layer must read and write the data in page units when the application layer directly reads and writes the data from the external storage medium are avoided. In addition, the invention also discloses a data processing device, a system and a storage medium.

Description

Data processing method, system and storage medium
Technical Field
The present invention relates to the field of information storage technologies, and in particular, to a data processing method, system, and storage medium.
Background
The existing electronic devices are all provided with storage devices for storing data, and common storage devices such as EEPROM (ELECTRICALLY ERASABLE PROGRAMMABLE READ-Only Memory), FLASH and the like are driven by a driving program to realize the read-write operation of the data and the storage of the data. Therefore, when a data read/write operation is required, the controller of the electronic device will write data to the storage device by running the driver.
In the embedded development process, the EEPROM can read and write data with any length, so that the EEPROM is simple and convenient to read and write, is favored by the market, and has the defects of high price and small storage capacity. The external storage medium has the advantages of low price and large storage capacity, for example: flash storage media, however, have limited their scope of use and ease of use because they can only read and write data in units of pages. When the application layer reads and writes data to the storage device by running the driver, the application layer runs longer because the data needs to be read and written to the external storage medium by taking pages as units, the efficiency of processing the data is low, and the waiting time of a user is long.
Accordingly, there is a need for further improvements in the art.
Disclosure of Invention
In view of the shortcomings in the prior art, the invention provides a data processing method, a system and a storage medium, which overcome the defects that when an application layer in the prior art directly reads and writes data to an external storage medium, the data must be read and written in units of pages, so that the data read and write operation time is long and the data processing efficiency is low.
In a first aspect, the present embodiment discloses a data processing method, where the method is applied to a data processing system, where the data processing system includes: an application layer, a driving layer and a read-write intermediate layer arranged between the application layer and the driving layer;
The data processing method comprises the following steps:
The application layer responds to the received processing operation instruction, calls a read-write interface of the intermediate layer, and transmits information to be processed into the intermediate layer;
and the read-write middle layer calls a read interface or a write interface of the external storage medium, and performs data read operation or write operation with the external storage medium according to the information to be processed.
Optionally, the processing operation instruction is a writing operation instruction, and the information to be processed is data to be written;
The step of calling a read interface or a write interface of an external storage medium by the read-write middle layer and performing data read operation or write operation with the external storage medium according to the information to be processed comprises the following steps:
and the read-write middle layer calls a write interface of the external storage medium, and the data to be written is written into the external storage medium.
Optionally, the step of the read-write middle layer calling a write interface of the external storage medium and writing the data to be written into the external storage medium includes:
And writing the data to be written into a pre-partitioned data storage area in the external storage medium, and clearing the data to be written stored in a local memory.
Optionally, the processing operation instruction is a read operation instruction, and the information to be processed is a start address of a preset cache space;
The step of calling a read interface or a write interface of an external storage medium by the read-write middle layer and performing data read operation or write operation with the external storage medium according to the information to be processed comprises the following steps:
the read-write middle layer calls a read interface of an external storage medium, reads data to be read from the external storage medium, and stores the read data to be read into the preset cache space according to the starting address.
Optionally, after the step of storing the read data to be read in the preset buffer space, the method further includes:
the read-write middle layer calls a write interface of an external storage medium, writes the data to be read into a data backup area divided in the external storage medium, and modifies the flag bit of the flag bit area divided in the external storage medium into a first flag bit, wherein the first flag bit is a flag bit corresponding to the completion of the read operation.
Optionally, after the step of writing the data to be read into the data backup area divided in the external storage medium, the method further includes:
when resetting or starting, detecting whether the flag bit is the first flag bit;
If yes, reading data to be read from the data backup area, writing the data to be read into a local memory, and modifying the first flag bit into a second flag bit, wherein the second flag bit is a flag bit corresponding to the completion of writing operation.
Optionally, the processing operation instruction is a data modification instruction, and the information to be processed is update data corresponding to the data to be modified;
The step of calling a read interface or a write interface of an external storage medium by the read-write middle layer and performing data read operation or write operation with the external storage medium according to the information to be processed comprises the following steps:
The read-write middle layer modifies the data to be modified according to the input update data, calls a write interface of an external storage medium, and writes the modified data to be modified into the external storage medium.
Optionally, the read-write middle layer calls a write interface of the external storage medium, and before writing the data to be written into the external storage medium, the method further includes:
And according to the writing operation instruction, starting a first control process for writing the data to be written, starting spin lock for the first control process, and setting the processing sequence of the first control process to be earlier than or equal to any control process.
Optionally, before the step of reading the data to be read from the external storage medium, the method further includes:
And starting a second control process for reading the data to be read according to the received reading operation instruction, starting spin lock for the second control process, and setting the processing sequence of the second control process to be earlier than or equal to any control process.
In a second aspect, the present embodiment further discloses a data processing system, including: an application layer and a read-write intermediate layer;
The application layer responds to the received processing operation instruction, calls a read-write interface of the intermediate layer, and transmits information to be processed into the intermediate layer;
And the read-write middle layer calls a read interface or a write interface of the external storage medium, and performs data read operation or write operation with the external storage medium according to the information to be processed.
In a third aspect, the present embodiment also discloses a computer-readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the steps of the method.
Compared with the prior art, the embodiment of the invention has the following advantages:
According to the data processing method provided by the embodiment of the invention, the read-write middle layer is arranged between the external storage medium and the system application layer, the read-write middle layer is utilized to realize the read-write of the data in the external storage medium, and the application layer acquires the data stored in the external storage medium based on the read-write middle layer and writes the data into the external storage medium through the read-write middle layer, so that the defect that the data processing efficiency of the application layer is low due to the fact that the page is required to be used as a unit when the application layer directly reads and writes the data from the external storage medium and the data is inconvenient to read and write is overcome.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present invention, and other drawings may be obtained according to the drawings without inventive effort to those skilled in the art.
FIG. 1 is a schematic diagram of an exemplary application scenario in an embodiment of the present invention;
FIG. 2 is a flow chart of steps of a data processing method according to an embodiment of the present invention;
FIG. 3 is a flowchart of the steps for writing data in an embodiment of the present invention;
FIG. 4 is a schematic diagram of a memory area divided according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating steps for reading and writing data according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of data processing in an embodiment of the invention;
FIG. 7 is a flowchart illustrating steps in an embodiment of a data processing implementation in accordance with an embodiment of the present invention;
FIG. 8 is a flow chart of data processing at system reset or start-up in a specific application embodiment of the present invention;
FIG. 9 is a flowchart of the steps of data processing execution control in an embodiment of the present invention.
Detailed Description
In order to make the present invention better understood by those skilled in the art, the following description will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The inventor finds that two kinds of storage media used by various electronic products in the prior art are important, the first kind is EEPROM, the read-write is convenient, but the price is high, the storage capacity is small, the use cost of a user is high, and the second kind is external storage media. The external storage medium is a nonvolatile memory, and can store data for a long time under the condition of no current supply. The external storage medium used at present is usually a Flash storage medium, which is in communication connection with a module in the electronic product shell through an interface, the storage capacity is large, the price is low, but the read-write data can only be in page units, so when the data is required to be read-written into the Flash storage medium, the data processing efficiency is low due to long operation time of the read-write data of an application layer, the user instruction cannot be responded quickly, the waiting time of the information processing is increased, and the inconvenience is brought to the user for using the electronic equipment.
In order to solve the above problems, the embodiments of the present invention provide a method for writing and reading data into an external storage medium based on a read-write interface, specifically, by setting a read-write interface between a driving layer and an application layer of an electronic device, using the read-write interface to write and read data in the external storage medium, when the application layer receives a processing operation instruction, transferring information to be processed into the read-write interface by calling the read-write interface, calling a read interface or a write interface of the external storage medium by using the read-write interface, and performing data writing and reading operation or data writing operation with the external storage medium according to the information to be processed. The driver layer contains a driver, which is an indispensable important part in the embedded system, and has the function of providing an operation interface of external equipment for an upper layer program, and realizing the driver of the equipment, wherein the upper layer program realizes corresponding operation by calling the interface of the driver. The application layer is a business logic layer of user application, and is used for organizing and calling business logic, such as: timing tasks, menu tasks, and communication tasks. The read-write intermediate layer is arranged between the driving layer and the application layer.
For example: when the application layer needs to write the data to be written into the external storage medium, the application layer firstly stores the data to be written into the external storage medium into the memory, then calls the interface of the read-write middle layer, and transfers the data to be written into the memory, and the read-write middle layer writes the data stored in the memory into the external storage medium by calling the write interface of the external storage medium, so that the data is written into the external storage medium. Compared with the application layer, the data writing process can be carried out with any length, and the operation of writing the data into the external storage medium is realized by calling a writing interface of the external storage medium by the read-write intermediate layer, so that the data writing process can be carried out with any length for the application layer.
Referring to fig. 1, when a user wants to implement data processing on an external storage medium 10, a read-write middle layer 201 for controlling reading and writing of data stored in the external storage medium 10 is first provided between an application layer 202 and a driving layer 203 of the device 20, and the read-write middle layer 201 implements reading and writing of data with any length in the external storage medium by the application layer, so that the effect that the read-write of data is as convenient as that of an EEPROM is implemented.
The read-write middle layer 201 is configured to implement data backup, power-on recovery, and read-write parallel critical sections in the external storage medium 10, and has control functions such as processing sequence among control processes after system scheduling, when a user wants to write data into the external storage medium 10, by sending a write operation instruction to the application layer 202, the application layer 202 calls a read-write middle layer 201 interface, the data to be written is transferred into the read-write middle layer 201, the read-write middle layer 201 calls a write interface of the external storage medium 10, the data to be written is written into the external storage medium 10, the data is read from the external storage medium 10, or when the user reads data from the external storage medium 10, a read operation instruction is sent to the application layer 202, the application layer calls the read-write middle layer 201 interface, a start address of a buffer space is transferred to the read-write middle layer 201, the data to be read from the external storage medium is called by the read-write middle layer 201, and the data to be read according to the start address of the buffer space transferred by the application layer.
The application layer 202 can directly acquire the data to be read from the external storage medium by the read-write middle layer 201, or directly transfer the data to be written into the read-write middle layer, and the process of writing the data into the external storage medium according to pages is not needed, so that the process of executing the data read-write to the external storage medium is the same as the process of executing the data read-write to the EEPROM, the effect of writing the data into the external storage medium with any length is achieved, the running time of the application layer for reading and writing the data is shortened, and the efficiency of processing the data by the application layer is improved.
Further, the storage area in the external storage medium 10 is divided in advance by the read-write middle layer 201, the read-write middle layer 201 simulates an EEPROM to store corresponding data, and stores the data read from the external storage medium 10 or the data to be written into the device memory thereof, so that the effect that the application layer can read and write the data from the external storage medium 10 with any length is further realized.
By way of example, the embodiments of the present invention may be applied to the following scenarios: in this scenario, device 20 may be a communication device, an industrial control device, or other intelligent device that has an embedded operating system installed. When a user wants to read the setting parameter data from the external storage medium of the intelligent device or needs to write the setting parameter data into the external storage medium, the application layer realizes that the setting parameter data is written into the external storage medium by calling the read-write interface of the read-write interface by sending a corresponding write operation instruction or a read operation instruction to the application layer, or reads the setting parameter data from the external storage medium, so as to realize the storage of the latest configuration parameter or the update of the latest configuration parameter. The read-write middle layer can be a module integrating control functions such as the data backup, the power-on recovery and the read-write parallel critical section, the processing sequence among all control processes after system scheduling, and the control functions can be realized in the form of program codes.
It should be noted that the above application scenario is only shown for the convenience of understanding the present invention, and embodiments of the present invention are not limited in this respect. Rather, embodiments of the invention may be applied to any scenario where applicable.
Various non-limiting embodiments of the present invention are described in detail below with reference to the attached drawing figures.
Exemplary method
Referring to FIG. 2, an embodiment of the present invention is shown to provide a data processing method applied to a data processing system, the data processing system including: the device comprises an application layer, a driving layer and a read-write intermediate layer arranged between the application layer and the driving layer.
The data processing system is an embedded system and comprises an application layer, drive layer hardware and a layer, wherein the application layer is used for providing a user program 'interface', can carry out programming interface function call under windows, and can realize timing tasks, card processing tasks, menu tasks and communication tasks. The driver layer is used for providing a common interface upper layer call. The hardware layer includes an embedded processor and an external device. According to the method, a read-write intermediate layer is arranged between the driving layer and the application layer, and the read-write intermediate layer is utilized to realize the read-write of data in an external storage medium.
The method comprises the following steps, which in this embodiment may for example comprise the steps of:
and step S110, the application layer responds to the received processing operation instruction, calls a read-write middle layer interface and transmits the information to be processed into the read-write middle layer.
The processing operation instruction can be issued by a user according to the need, can be issued by touch of a touch screen, can be issued by a keyboard, can be issued by voice, and can be automatically triggered in the process that an application program installed on the intelligent equipment executes a certain instruction.
And the application layer responds to the received processing operation instruction, calls the interface of the read-write middle layer, and the information to be processed is transmitted to the read-write middle layer. The read-write middle layer is arranged between the application layer and the driving layer, and when the application layer receives a processing operation instruction, the information to be processed can be written into the read-write middle layer by calling the read-write middle layer interface. The read-write middle layer is a series of program codes and has the functions of data transmission control, data backup, power-on recovery, read-write parallel critical section, priority control after system scheduling and the like.
Specifically, the processing operation instruction received by the device may be a write operation instruction for writing data into the external storage medium or a read operation instruction for reading specified data from the external storage medium. The processing operation instruction is firstly sent to the application layer, and after the application layer receives the processing operation instruction, the processing operation instruction obtains the information to be processed according to the received processing operation instruction, and the interface of the read-write middle layer is called to transfer the information to be processed into the read-write middle layer.
And step 120, the read-write middle layer calls a read interface or a write interface of the external storage medium, and performs data read operation or write operation with the external storage medium according to the information to be processed.
And when the read-write middle layer receives the information to be processed, which is transmitted by the application layer, a read interface or a write interface of the external storage medium is called, and target data is read from the external storage medium according to the information to be processed, or the data corresponding to the information to be processed or the information to be processed is written into the external storage medium.
For the application layer, because the data writing operation or the data reading operation between the application layer and the external storage medium is realized by the read-write intermediate layer, the application layer only needs to transfer the information to be processed into the read-write intermediate layer, and the data interaction between the application layer and the external storage medium is realized by the read-write intermediate layer, the method is equivalent to the realization that the application layer can write data into the external storage medium or read-write data can be of any length, and the problems that when the application layer directly writes the data to be written into the external storage medium, the application layer needs to execute by taking pages as units, so that the occupied thread time is long and the time is long are avoided.
Further, referring to fig. 3, in an implementation manner, the processing operation instruction is a write operation instruction, and the information to be processed is data to be written, and the step of writing the data to be written into the external storage medium by using the read-write interface layer includes:
Step S210, the application layer responds to the received writing operation instruction and calls a reading and writing middle layer interface, and data to be written are transmitted into the reading and writing middle layer.
When the application layer receives a writing operation instruction for writing the data to be written into the external storage medium, the application layer responds to the received writing operation instruction, and calls the interface of the reading and writing middle layer, wherein the writing instruction is transmitted to the reading and writing middle layer. The read-write middle layer is arranged between the application layer and the driving layer, and when the application layer receives a write operation instruction, the data to be written can be written into the read-write middle layer by calling the read-write middle layer interface.
For example: the data to be written can be device parameter setting data stored in a memory in advance, when a user needs to store the device parameter setting data in an external storage medium, the device parameter setting data is sent to a writing operation instruction for writing the device parameter setting data in the external storage medium, when an application layer receives the writing operation instruction, the writing operation instruction is responded, the reading and writing middle layer interface is called, and the device parameter setting data is written in the reading and writing middle layer.
Step S220, the read-write middle layer calls a write interface of the external storage medium, and the data to be written is written into the external storage medium.
And after the read-write middle layer receives the data to be written which is transmitted by the application layer, calling a write interface of the external storage medium, and writing the data to be written into the external storage medium. For example: when the data to be written is equipment parameter setting data, the equipment parameter setting data is written into the external storage medium by calling a writing interface of the external storage medium.
When the application layer writes the received data to be written into the external storage medium, the action of writing the data to be written into the external storage medium according to pages, which is executed by the read-write intermediate layer, is completed by the read-write intermediate layer, so that the application layer is prevented from consuming a large amount of time to write the data to be written into the external storage medium, and the data processing efficiency of the application layer is improved.
Further, in order to achieve that the application layer reads any length of data in the external storage medium, and achieve the same reading and writing effect as that of data in the read-write EEPROM, the storage area in the external storage medium is divided by the read-write intermediate layer, and the storage area in the external storage medium is divided into a data storage area K1, a data backup area K1 and a flag area K2 as shown in FIG. 4. The data storage area is used for storing data, the data backup area is used for backing up the data stored in the data storage area, and the flag area is used for storing flag bits whether reading or writing is successful or not.
In another implementation manner, as shown in fig. 5, the step of performing, according to the information to be processed, a data reading operation with an external storage medium includes:
step S211, the application layer responds to the received read operation instruction, calls the interface of the read-write middle layer, and transmits the start address of the preset buffer space to the read-write middle layer.
When the application layer receives a reading operation instruction, a preset cache space is built in the memory space, a starting address of the preset cache space is obtained, a read-write middle layer interface is called, and the starting address is transmitted to the read-write middle layer.
The reading operation instruction received by the application layer can be sent by a user or can be called by an application program according to the need when executing a certain program.
Step S212, the read-write middle layer calls a read interface of an external storage medium, reads data to be read from the external storage medium, and stores the read data to be read into the preset cache space according to the starting address.
When the read-write middle layer calls the read interface of the external storage medium, the data to be read is read from the external storage medium, and the data to be read is stored in the internal preset cache space according to the initial address transmitted by the application layer.
Examples: if the current user wants to acquire the latest configuration parameters of the air conditioner from the external storage medium, the user sends a reading operation instruction to the application layer, after receiving the reading operation instruction, the application layer presets a cache space for storing the latest configuration parameters in the memory, calls an interface of the read-write middle layer, and transmits a preset starting address of the cache space for storing the latest configuration parameters to the read-write middle piece. When the read-write middleware receives the initial address of the buffer space transmitted by the application layer, the latest configuration parameters of the air conditioner are obtained from the external storage medium, and the configuration parameters are stored into the buffer space according to the initial address.
Specifically, the size of the buffer space is set according to the size of the data to be read, and the application layer requests a buffer space at least larger than the size of the data to be read according to the size of the data to be read.
When the application layer receives a writing operation instruction or a reading and writing operation instruction of data in the external storage medium, the reading and writing operation of the data in the external storage medium is realized by calling the reading and writing middle layer interface and the reading and writing interface of the external storage medium, and the data is stored in the data storage area of the external storage medium, so that the reading and writing operation of the data in the external storage medium can be realized by calling the reading and writing interface of the external storage medium to read corresponding data from the data storage area or writing the corresponding data into the data storage area.
In one embodiment, in order to avoid that the amount of information stored in the memory is too large, a large amount of memory is occupied, when the data stored in the memory is called by the read-write middle layer to the write interface of the external storage medium, after the data is written into the external storage medium, or after the data to be read stored in the memory is read by the application layer, the data to be written or the read data stored in the memory is deleted.
In order to avoid data loss caused by power failure or other abnormal conditions written into the device memory, after writing the read data to be read into the device cache space, the method further includes:
and step S213, writing the data to be read into the data backup area divided in the external storage medium.
And after the read-write middle layer stores the data to be read from the external storage medium into the equipment memory, in order to avoid the data to be read from being lost, the write interface of the external storage medium is called, the data to be read is controlled to be written into the data backup area, the data to be read is backed up, and the recovery from the data backup area is convenient when the data to be read is lost, so that the recovery of the data is realized.
Step S214, modifying the zone bit of the zone bit zone divided in the external storage medium into a first zone bit, wherein the first zone bit is the zone bit corresponding to the completion of the reading operation.
In the step, the completion state of the data reading operation is characterized by setting the zone bit in the zone bit zone, so that the operation result of the data reading operation can be identified according to the zone bit. The first flag bit is a flag bit indicating that the data reading operation is completed.
And when the data backup is successful, modifying the flag bit stored in the flag bit area into a first flag bit, and when the flag bit read from the flag bit area is the first flag bit, indicating that the data to be read stored in the equipment memory is already successfully backed up to the data backup area, wherein the read-write intermediate layer successfully reads the data to be read.
Further, after the step of modifying the flag bit of the preset flag bit zone in the external storage medium to the second flag bit, the method further includes:
when resetting or starting, detecting whether the flag bit is the first flag bit;
If yes, reading data to be read from the data backup area, writing the data to be read into a memory, and modifying the first flag bit into a second flag bit, wherein the second flag bit is a flag bit corresponding to the completion of writing operation.
When the system is reset or restarted, whether the flag bit stored in the flag bit area is a first flag bit is detected, if so, the fact that the data to be read currently stored in the data backup area is not rewritten in the equipment memory is indicated, if the system is reset or restarted after power failure, the data to be read originally stored in the equipment memory is lost, the data to be read is obtained from the data backup area, the data to be read is written into the equipment memory, and the lost data to be read in the equipment memory is recovered.
In an implementation manner of one embodiment, the first flag bit is 1, that is, 0x01 is written in the flag bit area. The second flag bit is 0, that is, the data written in the flag bit area is 1, that is, 0x00 is written in the flag bit area in the implementation of one embodiment.
Because the data information stored in the equipment memory is lost after the read-write middle layer is powered off, when the reset or the start of the read-write middle layer is detected, whether the flag bit stored in the flag bit area is 0 or 1 is detected, if the flag bit is 1, the information stored in the equipment memory is lost before the reset or the start of the read-write middle layer and is not written into the equipment memory again is indicated, so that the data stored in the data backup area is controlled to be written into the equipment memory, the flag bit is controlled to be cleared from 1 to 0, and the recovery of the data is realized.
In the implementation, when the modification of the data in the external storage medium is required, if the processing operation instruction is a data modification instruction and the information to be processed is update data corresponding to the data to be modified, the step of modifying the data in the external storage medium by using the read-write middle layer includes:
Step S310, the application layer responds to the received data modification operation instruction and calls the read-write middle layer interface to transmit the update data corresponding to the data to be modified into the read-write middle layer.
When the application layer receives the data modification operation instruction, update data corresponding to the data modification operation instruction is obtained, and the read-write middle layer interface is called to transfer the update data into the read-write middle layer.
And step 320, the read-write middle layer modifies the data to be modified according to the input update data, calls a write interface of an external storage medium, and writes the modified data to be modified into the external storage medium.
The read-write middle layer receives the update data transmitted by the application layer, modifies the data to be modified according to the update data in the equipment memory, calls a write interface of the external storage medium, writes the modified data to be modified into a data storage area of the external storage medium, and realizes modification of the data stored in the external storage medium.
In order to avoid that the control process of data reading and writing is not interrupted and the read-write operation is not parallel, after the step of calling the read-write interface by the application layer in response to the received write operation instruction, the method further comprises the following steps:
And according to the writing operation instruction, starting a first control process for writing the data to be written, starting spin lock for the first control process, and setting the processing sequence of the first control process to be earlier than or equal to any control process.
Referring to fig. 9, when the application layer receives a write operation instruction, the read-write middle layer interface is called, and whether a first control process for writing data to be written into the external storage medium is started or not is detected, if yes, the first control process is judged to be the spin lock, if yes, the data to be written into the read-write middle layer is sent, and the read-write middle layer calls the write interface of the external storage medium to write the data to be written into the external storage medium. If the first control process does not acquire the spin lock, after waiting for the first control process to acquire the spin lock, sending the data to be written to the read-write middle layer, so as to avoid the condition that the read interruption is closed when the control of writing the data to be written is performed. And when the operation of the first control process is finished, namely, after the data to be written is written into the external storage medium, automatically unlocking the spin lock by the automatic first control.
And after the step of calling the read-write interface by the application layer in response to the received read operation instruction, the method further comprises:
And starting a second control process for reading the data to be read according to the received reading operation instruction, starting spin lock for the second control process, and setting the processing sequence of the second control process to be earlier than or equal to any control process.
And the read interface of the external storage medium is called by the read-write middle layer to acquire data to be read only when the second control process is detected to acquire the spin lock, and the data to be read is stored in the cache space according to the initial address of the cache space transmitted by the application layer.
And setting a processing sequence of priority processing for the control process corresponding to the read and write operation, wherein the processing sequence is earlier than or equal to that of other control processes, so that the interference of the other control processes on the running process is avoided, and the smooth operation of the read and write operation is realized.
The following takes FreeRTOS as an example of a system to describe the method in more detail;
As shown in fig. 6, a SpiFlash chip, a SpiFlash driver and an application layer are sequentially installed in the embedded device, a read-write intermediate layer is arranged between the application layer and the SpiFlash driver, and the read-write intermediate layer can implement read-write operation on data stored in the SpiFlash chip through an external SpiFlash storage medium interface. Dividing a storage area for the external Spiflash storage device according to the size of data to be read, wherein the divided storage area comprises: a data storage area, a data backup area and a zone bit area.
Referring to fig. 7, when data is required to be written into the external SpiFlash storage medium, the target data is read out from the data storage area into the global array of the device memory, the writing interface of the external SpiFlash storage medium is called to write the global array into the data backup area to realize data backup, and after the data backup, the flag position in the flag bit area is 1. If the application layer receives the data modification operation instruction, modifying the data to be modified in the equipment memory according to the update data received by the application layer, storing the modified data into a global array, and writing the global array into a data storage area of an external SpiFlash storage medium. If the global array is successfully written, the flag bit of the flag bit area is cleared, otherwise, the flag bit is checked to be not cleared after the next power-on or reset, and the data to be modified after being read from the backup area is written into the data storage area, so that the data recovery is realized.
The steps of data processing after a system reset, or after a restart, will be described with reference to fig. 8. When the system is reset or powered on again, a read interface of an external SpiFlash storage medium is called, the first byte in the zone bit zone is read out, and if the first byte is 0, no operation is required to be executed; if the data is 1, executing the step C to call a read interface of the external SpiFlash storage medium, reading all the data in the data backup area into the global array, calling a write interface of the external SpiFlash storage medium, writing all the content in the global array into the data storage area (namely e_data_space), calling a write interface of the Flash storage medium, setting the first byte in the zone bit area (namely e_flag_space) as 0, and ending the operation of writing the data.
When an operating system of the device starts to perform data read-write operation, in order to avoid parallel control processes in the read-write process or avoid interference of other control processes in the control process of the read-write operation, a spin lock is set for the control process of the read-write operation, as shown in fig. 9, when the control process of the read-write operation is detected to start, whether the control process obtains the spin lock is judged, if the control process is not distributed to a waiting queue, until the control process obtains the spin lock, after the control process obtains the spin lock, a message is sent to a read-write intermediate layer, and the read-write intermediate layer performs corresponding read-write operation, thereby ensuring that the read-write process of the external storage medium is not interrupted and the read-write operation is not parallel.
Further, taking FreeRTOS as an example, creating a task with the highest priority to control a data read-write operation process of the read-write middle layer, so as to ensure that the read-write operation process is not interrupted by other tasks.
Exemplary apparatus
In a second aspect, an embodiment of the present invention further provides a data processing system, including: a read-write intermediate layer and an application layer;
The application layer responds to the received processing operation instruction, calls a read-write interface of the intermediate layer, and transmits information to be processed into the intermediate layer;
And the read-write middle layer calls a read interface or a write interface of the external storage medium, and performs data read operation or write operation with the external storage medium according to the information to be processed.
In one implementation, the processing operation instruction is a write operation instruction, and the information to be processed is data to be written;
The read-write middle layer is used for calling a write interface of the external storage medium and writing the data to be written into the external storage medium.
In one implementation manner, the processing operation instruction is a reading operation instruction, and the information to be processed is a starting address of a preset cache space;
The read-write middle layer is used for calling a read interface of an external storage medium, reading data to be read from the external storage medium, and storing the read data to be read into the preset cache space according to the starting address.
In one implementation manner, the processing operation instruction is a data modification instruction, and the information to be processed is update data corresponding to the data to be modified;
The read-write middle layer modifies the data to be modified according to the input update data, calls a write interface of an external storage medium, and writes the modified data to be modified into the external storage medium.
In a third aspect, an embodiment of the present invention further provides a computer device, including a memory and a processor, where the memory stores a computer program, and where the processor implements the steps of the method when executing the computer program.
In a fourth aspect, embodiments of the present invention also provide a computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the steps of the method.
In an exemplary embodiment, the computer device may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for executing the methods described above.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It is to be understood that the invention is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (11)

1. A data processing method, applied to a data processing system, the data processing system comprising: an application layer, a driving layer and a read-write intermediate layer arranged between the application layer and the driving layer;
The data processing method comprises the following steps:
The application layer responds to the received processing operation instruction, calls a read-write interface of the intermediate layer, and transmits information to be processed into the intermediate layer;
The read-write middle layer calls a read interface or a write interface of an external storage medium, and performs data read operation or write operation with the external storage medium according to the information to be processed;
when data is required to be written into an external storage medium, a write operation instruction is sent to an application layer, a read-write middle layer interface is called by the application layer, the data to be written is transferred into the read-write middle layer, the read-write middle layer calls a write interface of the external storage medium, the data to be written is written into the external storage medium, the data is read from the external storage medium, or when the data is required to be read from the external storage medium, a read operation instruction is sent to the application layer, the application layer calls the read-write middle layer interface, the initial address of a cache space is transferred into the read-write middle layer, the read interface of the external storage medium is called by the read-write middle layer, the data to be read is read from the external storage medium, and the data to be read is stored into the cache space according to the initial address of the cache space transferred by the application layer.
2. The method according to claim 1, wherein the processing operation instruction is a write operation instruction, and the information to be processed is data to be written;
The step of calling a read interface or a write interface of an external storage medium by the read-write middle layer and performing data read operation or write operation with the external storage medium according to the information to be processed comprises the following steps:
and the read-write middle layer calls a write interface of the external storage medium, and the data to be written is written into the external storage medium.
3. The method according to claim 2, wherein the read-write interface invokes a write interface of an external storage medium, and the step of writing the data to be written to the external storage medium comprises:
And writing the data to be written into a pre-partitioned data storage area in the external storage medium, and clearing the data to be written stored in a local memory.
4. The method according to claim 1, wherein the processing operation instruction is a read operation instruction, and the information to be processed is a start address of a preset buffer space;
The step of calling a read interface or a write interface of an external storage medium by the read-write middle layer and performing data read operation or write operation with the external storage medium according to the information to be processed comprises the following steps:
the read-write middle layer calls a read interface of an external storage medium, reads data to be read from the external storage medium, and stores the read data to be read into the preset cache space according to the starting address.
5. The method for processing data according to claim 4, further comprising, after the step of storing the read data to be read in the predetermined buffer space:
the read-write middle layer calls a write interface of an external storage medium, writes the data to be read into a data backup area divided in the external storage medium, and modifies the flag bit of the flag bit area divided in the external storage medium into a first flag bit, wherein the first flag bit is a flag bit corresponding to the completion of the read operation.
6. The data processing method according to claim 5, wherein after the step of writing the data to be read into the data backup area divided in the external storage medium, further comprising:
when resetting or starting, detecting whether the flag bit is the first flag bit;
If yes, reading data to be read from the data backup area, writing the data to be read into a local memory, and modifying the first flag bit into a second flag bit, wherein the second flag bit is a flag bit corresponding to the completion of writing operation.
7. The data processing method according to claim 1, wherein the processing operation instruction is a data modification instruction, and the information to be processed is update data corresponding to the data to be modified;
The step of calling a read interface or a write interface of an external storage medium by the read-write middle layer and performing data read operation or write operation with the external storage medium according to the information to be processed comprises the following steps:
The read-write middle layer modifies the data to be modified according to the input update data, calls a write interface of an external storage medium, and writes the modified data to be modified into the external storage medium.
8. The method according to claim 2, wherein the read-write interface invokes a write interface of an external storage medium, and further comprising, before writing the data to be written to the external storage medium:
And according to the writing operation instruction, starting a first control process for writing the data to be written, starting spin lock for the first control process, and setting the processing sequence of the first control process to be earlier than or equal to any control process.
9. The method of claim 4, wherein the read-write interface invokes a read interface of an external storage medium, and wherein prior to the step of reading data to be read from the external storage medium, the method further comprises:
And starting a second control process for reading the data to be read according to the received reading operation instruction, starting spin lock for the second control process, and setting the processing sequence of the second control process to be earlier than or equal to any control process.
10. A data processing system, comprising: an application layer and a read-write intermediate layer;
The application layer responds to the received processing operation instruction, calls a read-write interface of the intermediate layer, and transmits information to be processed into the intermediate layer;
the read-write middle layer calls a read interface or a write interface of an external storage medium, and performs data read operation or write operation with the external storage medium according to the information to be processed;
when data is required to be written into an external storage medium, a write operation instruction is sent to an application layer, a read-write middle layer interface is called by the application layer, the data to be written is transferred into the read-write middle layer, the read-write middle layer calls a write interface of the external storage medium, the data to be written is written into the external storage medium, the data is read from the external storage medium, or when the data is required to be read from the external storage medium, a read operation instruction is sent to the application layer, the application layer calls the read-write middle layer interface, the initial address of a cache space is transferred into the read-write middle layer, the read interface of the external storage medium is called by the read-write middle layer, the data to be read is read from the external storage medium, and the data to be read is stored into the cache space according to the initial address of the cache space transferred by the application layer.
11. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 9.
CN201911400485.2A 2019-12-30 Data processing method, system and storage medium Active CN113126883B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911400485.2A CN113126883B (en) 2019-12-30 Data processing method, system and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911400485.2A CN113126883B (en) 2019-12-30 Data processing method, system and storage medium

Publications (2)

Publication Number Publication Date
CN113126883A CN113126883A (en) 2021-07-16
CN113126883B true CN113126883B (en) 2024-07-09

Family

ID=

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103885427A (en) * 2014-03-31 2014-06-25 珠海万力达电气股份有限公司 Embedded type microcomputer protection method based on RTEMS operation system
CN108205472A (en) * 2017-08-15 2018-06-26 珠海市魅族科技有限公司 Memory release method, release device, computer installation and readable storage medium storing program for executing
CN109240947A (en) * 2018-08-13 2019-01-18 武汉普利商用机器有限公司 Intelligent card data method of reseptance and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103885427A (en) * 2014-03-31 2014-06-25 珠海万力达电气股份有限公司 Embedded type microcomputer protection method based on RTEMS operation system
CN108205472A (en) * 2017-08-15 2018-06-26 珠海市魅族科技有限公司 Memory release method, release device, computer installation and readable storage medium storing program for executing
CN109240947A (en) * 2018-08-13 2019-01-18 武汉普利商用机器有限公司 Intelligent card data method of reseptance and device

Similar Documents

Publication Publication Date Title
JP4548601B2 (en) Automotive control unit
EP2375323A1 (en) Firmware image update and management
JP4768237B2 (en) Portable electronic device and method for controlling portable electronic device
US10579300B2 (en) Information handling system firmware persistent memory runtime reclaim
KR101051703B1 (en) Integrated circuit card and integrated circuit card system with suspend / reset function
CN113377408B (en) High-reliability SRAM type FPGA online upgrading method and system
CN104123153A (en) Apparatus and method for firmware upgrade using USB
CN106547636B (en) Debugging system and method
CN109408122B (en) Equipment starting method, electronic equipment and computer storage medium
CN110874237A (en) Software upgrading method, device, terminal and readable storage medium
CN112015447B (en) System updating method and device of electronic equipment, electronic equipment and storage medium
CN114661368B (en) Chip and starting method thereof
CN115061713A (en) Method and device for upgrading electronic equipment
CN111026417A (en) Embedded equipment upgrading method and embedded equipment
CN113126883B (en) Data processing method, system and storage medium
JP6192089B2 (en) Information processing apparatus, control method and control program for information processing apparatus
CN113126883A (en) Data processing method, system and storage medium
CN112269585B (en) Joint driver firmware online updating method and device and joint driver
WO2012077604A1 (en) Processing device, program update method, and program
JP2002175193A (en) Device and method for rewriting program
CN110515665B (en) Starting method, system and device of processor system
TW201913391A (en) Methods for resetting a flash memory device and apparatuses using the same
CN110740382A (en) Method, device, television and medium for avoiding undesired automatic restart of television
CN116431190B (en) Firmware upgrading method and device, BMC chip, server and medium
WO2023203768A1 (en) Electronic control device and writing control method

Legal Events

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