CN106528440B - Flash memory operation method and device based on embedded system - Google Patents
Flash memory operation method and device based on embedded system Download PDFInfo
- Publication number
- CN106528440B CN106528440B CN201610950273.1A CN201610950273A CN106528440B CN 106528440 B CN106528440 B CN 106528440B CN 201610950273 A CN201610950273 A CN 201610950273A CN 106528440 B CN106528440 B CN 106528440B
- Authority
- CN
- China
- Prior art keywords
- file
- mode
- physical address
- block
- flash
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0238—Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
- G06F12/0246—Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a Flash memory operation method and device based on an embedded system, which are used for solving the problem that in the prior art, Flash needs to be designed and planned respectively according to different operation systems. The method comprises the following steps: receiving a flash memory operation request initiated by an application layer; judging whether the operation mode is operated according to a file mode or a physical address mode; when the operation mode is determined to be operated according to the file mode, whether a file corresponding to the address interval indicated by the operation address information exists in the flash memory is continuously judged, and if yes, the file is correspondingly operated according to the operation instruction; otherwise, creating a file corresponding to the address interval, and performing corresponding operation on the created file according to the operation instruction; and when the operation mode is determined to be the operation according to the physical address mode, performing corresponding operation according to the operation instruction and the address interval indicated by the operation address information. The invention provides a method for uniformly operating and managing Flash for embedded products of different operating systems.
Description
The application is a divisional application of a chinese patent application entitled flash memory operation method and device based on an embedded system, and is proposed in 2014, 3, 26 and with an application number of 201410117104.0.
Technical Field
The invention relates to the technical field of storage, in particular to a flash memory operation method and device based on an embedded system.
Background
Flash memory (Flash) is a storage device of an embedded platform, and for some embedded platform devices, such as set top boxes, Flash is used for storing contents of system software, application software, user information and the like. When designing the system software, the storage address of the above content needs to be planned strictly in detail. Some application modules, such as a CA module, an advertisement module, or a program management module, all use the storage information of Flash to perform operations such as reading, writing, or erasing on Flash, and each application module can only operate in an address interval allocated to itself, and once an address is wrongly written, a serious system failure may be caused.
The embedded platforms of different operating systems are used, and the operating modes of the Flash are greatly different. For the Linux operating system, a Memory Technology Device (MTD) is used to establish a uniform abstract interface for Flash, and a user calls a standard interface provided by the Linux system itself to read, write or erase a file to perform a related operation on Flash. For the UCOS operating system, a user directly calls an original drive of the Flash to read, write or erase files of the Flash.
The prior art has the following defects: when application layer software is switched among different operating systems, because the operating modes of Flash are different under different operating systems, Flash needs to be designed and planned according to different operating systems.
Disclosure of Invention
The embodiment of the invention provides a Flash memory operation method and device based on an embedded system, which are used for solving the problem that in the prior art, Flash needs to be designed and planned respectively aiming at different operating systems.
The embodiment of the invention provides a flash memory operation method and device based on an embedded system, which comprises the following two aspects.
In a first aspect, a method for operating a flash memory based on an embedded system includes:
receiving a flash memory operation request initiated by an application layer, wherein the flash memory operation request carries an operation instruction, operation address information and an operation mode;
judging whether the operation mode is operated according to a file mode or a physical address mode;
when the operation mode is determined to be operated according to the file mode, whether a file corresponding to the address interval indicated by the operation address information exists in the flash memory is continuously judged, and if yes, the file is correspondingly operated according to the operation instruction; otherwise, creating a file corresponding to the address interval, and performing corresponding operation on the created file according to the operation instruction;
and when the operation mode is determined to be the operation according to the physical address mode, performing corresponding operation according to the operation instruction and the address interval indicated by the operation address information.
Through the possible implementation mode, a unified Flash operation method is provided for embedded products of different operation systems, after a file storage path for subsequent Flash operation is planned during system software design, technicians do not need to care about an embedded platform to which application layer software is applied, the Flash operation method provided by the embodiment of the invention is directly adopted, corresponding processing is carried out according to different operation modes, Flash can be stably and reliably operated, the possibility of out-of-range storage is reduced, and the reliability of the system is ensured. Products in different operating systems can be mutually inherited, products with the same application can be rapidly switched, and the development and debugging time of new products is shortened.
With reference to the first aspect, in a first possible implementation manner, before receiving a flash memory operation request initiated by an application layer, the method further includes:
in a system configuration stage, acquiring a preset operation mode, and judging whether the operation mode is operated according to a file mode or a physical address mode;
when the operation mode is determined to be the operation according to the file mode, establishing a file storage path when the flash memory is subjected to subsequent operation, acquiring the memory technology equipment information of the flash memory, and configuring block information according to the memory technology equipment information;
when the operation mode is determined to be the operation according to the physical address mode, acquiring public flash memory interface information of a flash memory, and configuring block information according to the public flash memory interface information;
wherein the block information includes a block number, a head address, and a block size of each block.
By the possible implementation mode, different configuration methods for the UCOS system and the Linux system are provided, so that different operation modes can be further adopted for the flash memory according to different operation modes of the two systems.
With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner, the determining whether a file corresponding to an address interval indicated by the operation address information exists in the flash memory includes:
determining an address interval according to the initial physical address and the end physical address carried in the operation address information;
and determining the block number of each block covered by the address interval according to the block information, and judging whether a file corresponding to the block number of each covered block exists in the flash memory.
Through the possible implementation mode, the operation address information indicated by the application layer can be corresponded to the file in the Linux system, so that the file can be further operated correspondingly according to the operation instruction.
With reference to the second possible implementation manner of the first aspect, in a third possible implementation manner, creating a file corresponding to an address interval includes:
determining the block number of each block covered by the address interval, creating a file corresponding to each block in each block, and naming the created file by adopting the block number of each block.
Through the possible implementation mode, when the file corresponding to the address interval does not exist, the file is created in the mode of corresponding the block to the file, so that the corresponding file can be found through operating the address information during subsequent operation.
With reference to the second or third possible implementation manner of the first aspect, in a fourth possible implementation manner, performing corresponding operation on the created file according to the operation instruction includes:
and reading, writing or erasing the data in the file corresponding to each block covered by the address interval according to the operation instruction.
With reference to the first possible implementation manner of the first aspect, in a fifth possible implementation manner, when it is determined that the operation mode is an operation according to a physical address mode, performing a corresponding operation according to an address interval indicated by the operation address information according to the operation instruction includes:
and when the operation mode is determined to be the operation according to the physical address mode, reading, writing or erasing the data in each block corresponding to the address interval according to the operation instruction.
In a second aspect, an embedded system based flash memory operating device includes:
the receiving unit is used for receiving a flash memory operation request initiated by an application layer, wherein the flash memory operation request carries an operation instruction, operation address information and an operation mode;
a judging unit for judging whether the operation mode is operated in a file mode or a physical address mode;
the first execution unit is used for continuously judging whether a file corresponding to the address interval indicated by the operation address information exists in the flash memory when the operation mode is determined to be the operation according to the file mode, and if so, performing corresponding operation on the file according to the operation instruction; otherwise, creating a file corresponding to the address interval, and performing corresponding operation on the created file according to the operation instruction;
and the second execution unit is used for performing corresponding operation according to the operation instruction and the address interval indicated by the operation address information when the operation mode is determined to be the operation according to the physical address mode.
Through the possible implementation mode, a device capable of uniformly operating the Flash is provided for embedded products of different operating systems, and a set of standard adaptive operation interfaces are provided for an application layer in a module mode, so that the compatibility of the Flash equipment is better. After a file storage path for subsequent Flash operation is planned during system software design, technicians do not need to care which embedded platform the application layer software is applied to, the Flash operation device provided by the embodiment of the invention is directly adopted to perform corresponding processing according to different operation modes, Flash can be stably and reliably subjected to related operation, the possibility of out-of-range storage is reduced, and the reliability of the system is ensured. Products in different operating systems can be mutually inherited, products with the same application can be rapidly switched, and the development and debugging time of new products is shortened.
With reference to the second aspect, in a first possible implementation manner, the method further includes: the configuration unit is used for acquiring a preset operation mode before receiving a flash memory operation request initiated by an application layer, judging whether the operation mode is operated in a file mode or a physical address mode, creating a file storage path when the flash memory is subsequently operated when the operation mode is determined to be operated in the file mode, acquiring the memory technology equipment information of the flash memory, configuring block information according to the memory technology equipment information, acquiring public flash memory interface information of the flash memory when the operation mode is determined to be operated in the physical address mode, and configuring the block information according to the public flash memory interface information; wherein the block information includes a block number, a head address, and a block size of each block.
Through the possible implementation manner, the flash memory operating device in the embodiment of the invention adopts different configuration manners for the UCOS system and the Linux system, so that different operation manners can be further adopted for the flash memory according to different operation modes of the two systems respectively.
With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner, the first execution unit is specifically configured to:
determining an address interval according to the initial physical address and the end physical address carried in the operation address information;
and determining the block number of each block covered by the address interval according to the block information, and judging whether a file corresponding to the block number of each covered block exists in the flash memory.
Through the possible implementation mode, the operation address information indicated by the application layer can be corresponded to the file in the Linux system, so that the file can be further operated correspondingly according to the operation instruction.
With reference to the second possible implementation manner of the second aspect, in a third possible implementation manner, the first execution unit is specifically configured to:
determining the block number of each block covered by the address interval, creating a file corresponding to each block in each block, and naming the created file by adopting the block number of each block.
Through the possible implementation mode, when the file corresponding to the address interval does not exist, the file is created in the mode of corresponding the block to the file, so that the corresponding file can be found through operating the address information during subsequent operation.
With reference to the second or third possible implementation manner of the second aspect, in a fourth possible implementation manner, the first execution unit is specifically configured to:
and reading, writing or erasing the data in the file corresponding to each block covered by the address interval according to the operation instruction.
With reference to the first possible implementation manner of the second aspect, in a fifth possible implementation manner, the second execution unit is specifically configured to:
and when the operation mode is determined to be the operation according to the physical address mode, reading, writing or erasing the data in each block corresponding to the address interval according to the operation instruction.
Drawings
FIG. 1 is a block diagram of a Flash software architecture according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a Flash adaptation processing module according to an embodiment of the present invention processing Flash;
FIG. 3 is a flowchart of a method for operating a flash memory based on an embedded system according to an embodiment of the present invention;
FIG. 4 is a diagram of a flash memory operating device based on an embedded system according to an embodiment of the present invention.
Detailed Description
In order to provide a unified Flash operation method among various operating systems, so that application layer software can call Flash through a unified interface and adopt the same way to operate Flash, the embodiment of the invention provides a Flash operation method and a Flash operation device based on an embedded system, and the following description is combined with the attached drawings of the specification to describe the preferred embodiment of the invention.
In the Flash memory operation method based on the embedded system in the embodiment of the invention, a Flash adaptation processing module is added between the Linux and UCOS operation systems and the application module, so that a set of standard adaptation operation interfaces are provided for the upper application module, and Flash is operated and managed uniformly. In a Linux system, a physical address which is indicated to be operated by an application layer corresponds to a file in the Linux system, and Flash is correspondingly operated according to a file mode; in the UCOS system, the physical address which is indicated to be operated by the application layer is sent to Flash in the system, and the Flash is directly operated according to the physical address.
Preferred embodiments of the present invention will be described below with reference to the accompanying drawings.
Referring to fig. 1, the software of the embedded platform product is designed in a layered and modular manner, as is the design of the Flash software. The driver layer above the hardware processes the operation of Flash according to the difference of the operating system, compared with the UCOS operating system, the Linux operating system introduces MTD, divides the Flash device driver into four layers from bottom to top, and sequentially becomes the hardware driver layer (namely the Flash original driver 190): the Flash hardware device is responsible for reading, writing and erasing operations of the Flash hardware device; MTD primal device layer 180: the method mainly comprises two parts, wherein one part is general codes of MTD original equipment, and the other part is data of each specific Flash, such as partitions; MTD device layer: based on the MTD original equipment, the Linux operating system can define MTD character equipment 160 and MTD block equipment 170 to form an equipment layer; the equipment node: the character device node 140 and the block device node 150 are established under the/dev subdirectory by the mknod, and the user can access the MTD character device and the block device by accessing the device nodes. The Flash adaptation processing module 110 in the embodiment of the present invention is located in the middle layer, is located between the application layer 100 and different embedded platforms (i.e., the UCOS system and the Linux system), and provides a set of standard adaptation operation interfaces for upper layer applications in a modular manner.
Referring to fig. 2, the Flash adaptation processing module mainly provides four types of interfaces for the application layer, but is not limited to these four types, and then the standard adaptation operation interface may be continuously developed according to the needs of the application layer. The four interfaces are respectively a version information interface for checking a Flash adaptation driving module, a Flash information interface for acquiring block information such as the total size, the block size and the total number of the Flash, an initialization interface for initializing and configuring a Flash operation mode, and an operation interface for reading, writing and erasing the Flash. The process of performing initialization configuration includes steps 2000 to 2005, and the process of performing read/write and erase operations includes steps 2010 to 2015, and a specific process of performing operations such as read, write, and erase on the Flash memory by the Flash adaptation processing module is described below.
Referring to fig. 3, in the embodiment of the present invention, a specific process of operating the Flash memory by the Flash adaptation processing module is as follows:
step 300: the Flash adaptation processing module receives a Flash operation request initiated by an application layer, wherein the Flash operation request carries an operation instruction, operation address information and an operation mode.
Specifically, before receiving a Flash operation request initiated by an application layer, system configuration needs to be performed, and the Flash adaptation processing module provides an initialization interface for calling the application layer. When the application layer calls the initialization interface, the system starts initialization operation, acquires a preset operation mode and judges whether the operation mode is operated according to a file mode or a physical address mode; in specific implementation, the Flash adaptation processing module sets the operation mode of the blocks corresponding to all Flash physical addresses, specifically sets the Flash blocks in the Linux system to operate in a file mode, and represents the Flash blocks by a number of '1'; the Flash block in the UCOS system is set to operate in a physical address mode, represented by the number "0". A user can set a preset operation mode to an operation mode corresponding to the current operating system according to the currently used operating system, for example, if the currently used operating system is a Linux system, the user sets the preset operation mode to operate in a file mode in advance; if the UCOS system is currently used, the user sets a preset operation mode to operate according to a physical address mode in advance; if two operating systems need to be used simultaneously, one operating system is initialized and the other operating system is initialized according to any sequence, for example, a Linux system is initialized, the operating mode of the Linux system is set to operate in a file mode, a UCOS system is initialized, and the operating mode of the UCOS system is set to operate in a physical address mode.
When the operation mode is determined to be operated according to a file mode, because an MTD (maximum Flash Interface, CFI) of a Common Flash Interface is introduced into a Linux system, block information of Flash needs to be acquired from MTD information, after a file storage path for subsequent operations such as writing, erasing and the like is established, MTD information of the Flash is acquired, and block information is configured according to the MTD information; when the operation mode is determined to be operated according to the physical address mode, the block information of the flash memory can be directly obtained from the CFI information, and the block information can be directly configured according to the CFI information; the block information is used for indicating the block number, the starting address and the block size of each block, and the block is a minimum unit for indicating data storage in the flash memory; in practical application, one Flash is composed of a plurality of blocks with the same size, wherein the block size can be configured manually, or the block size indicated in CFI information or MTD information can be adopted, each block is numbered in sequence, and each block corresponds to the first address thereof.
After the system initialization stage is completed, the Flash adaptation processing module receives a Flash operation request initiated by an application layer, where the Flash operation request carries an operation instruction, operation address information, and an operation mode, where the operation instruction is used to indicate what kind of operation is performed on Flash, such as reading, writing, or erasing.
Step 310: and judging whether the operation mode is operated in a file mode or a physical address mode.
Specifically, in the embodiment of the present invention, for example, the Linux system operates in a file manner, and the UCOS system operates in a physical address manner, but the Linux system is not limited to the two operating systems, and other operating systems that operate in a file manner or in a physical address manner are also within the scope included in the embodiment of the present invention. The Flash adaptation processing module acquires an operation mode of Flash to be read, written or erased from the Flash operation request, wherein the operation mode is set during initialization, if the operation mode is 1, the Flash adaptation processing module operates in a file mode, and if the operation mode is 0, the Flash adaptation processing module operates in a physical address mode.
Step 320: and when the operation mode is determined to be the operation according to the file mode, the Flash adaptation processing module continuously judges whether a file corresponding to the address interval indicated by the operation address information exists in the Flash memory, if so, the file is correspondingly operated according to the operation instruction, otherwise, the file is created corresponding to the address interval, and the created file is correspondingly operated according to the operation instruction.
Specifically, when the operation mode is determined to be the operation according to the file mode, whether a file corresponding to the address interval indicated by the operation address information exists in the flash memory is judged, that is, the address interval is determined according to the initial physical address and the end physical address carried in the operation address information; and determining the block number of each block covered by the address interval according to the block information, and judging whether the flash memory has a file corresponding to the block number of each covered block. For example, the block size of Flash is 64k, Flash input operation address information is written in, wherein the starting physical address is 0x10000, the ending physical address is 0x30000, the Flash adaptation processing module inquires an address interval from the starting physical address to the ending physical address according to the block size indicated in the block information during initialization, and the block numbers of all blocks covered by the address interval are the 2 nd block and the 3 rd block, so that whether a file corresponding to the block number exists in Flash is judged; these files may be normally commanded with the block number, in which case the file names of the corresponding files are "file _ 2" and "file _ 3".
And if the file corresponding to the block number of each block exists, performing corresponding operation on the file according to the operation instruction. For example, a write operation is performed on the files with the file names "file _ 2" and "file _ 3" described above.
If the file corresponding to the block number of each block does not exist, establishing the file corresponding to the address interval, and the specific steps are as follows: determining the block number of each block covered by the address interval, creating a file corresponding to each block in each block, and naming the created file by adopting the block number of each block. For example, when there is no file corresponding to the block number of each block covered by the address section in Flash, if the block numbers of the covered blocks are determined to be the 5 th to 7 th blocks, three files having file names "file _ 5", "file _ 6", and "file _ 7" are created corresponding to the 5 th to 7 th blocks.
After the files are created, corresponding reading, writing or erasing operations are carried out on the created files.
The steps are completed when the operation mode is according to the file mode, the application layer inputs the physical address of the Flash to be operated, the physical address is corresponding to the file in the Linux system, and the operation mode of the physical address is simulated by adopting the files, so that the files are directly operated correspondingly. Therefore, the method can be operated in the same way as the UCOS system, namely, the physical address of the Flash to be operated is input from the application layer, so that the physical address of the Flash to be operated can be correspondingly operated, and in the Linux system, the physical address of the Flash to be operated input from the application layer is corresponding to a file in the Linux system, and then the file is correspondingly operated, namely, the physical address of the section corresponding to the file is correspondingly operated.
Step 330: and when the Flash adaptation processing module determines that the operation mode is the operation according to the physical address mode, performing corresponding operation according to the operation instruction and the address interval indicated by the operation address information.
Specifically, when the operation mode is determined to be the operation according to the physical address mode, the Flash is correspondingly operated according to the operation instruction and the address interval indicated by the starting physical address and the ending physical address. For example, the block size of Flash is 64k, the operation address information input by Flash is read, wherein the starting physical address is 0x40000, the ending physical address is 0x50000, and the Flash adaptation processing module reads the data in the address interval from 0x40000 to 0x50000, namely the 5 th block, according to the Flash read directly indicated by the operation instruction.
Before the corresponding operation is introduced to the file or block in the address interval, the actual structure of the Flash memory is introduced, a plurality of blocks exist in one Flash memory, the embedded platform processes binary data which only consists of 0 and 1, the data to be stored in the Flash is also binary, in the operation to the Flash, only 1 can be written into 0, but not 0 can be written into 1, therefore, before the Flash is written into, the erasing operation is firstly carried out, namely, the content in the Flash is completely changed into 1, in the writing operation, only the bit of 0 can be written into when the writing operation is carried out. The minimum unit of an erase operation is a block, i.e., at least one block is erased at a time.
When the application layer calls the operation interface for reading, writing or erasing, the Flash adaptation processing module also processes according to different operation modes.
When the operation mode is determined to be the operation according to the file mode, performing corresponding operation on the file according to the operation instruction, specifically: and reading, writing or erasing the data in the file corresponding to each block covered by the address interval according to the operation instruction.
Specifically, if the operation instruction indicates to perform a reading operation, reading data stored in a file corresponding to each block covered by the address interval; for example, when the block size is 64k, if the application layer needs to read data in an address interval 0x00000 to 0x20000 in the linux system, the Flash adaptation processing module reads data stored in files corresponding to blocks covered by the address interval, that is, files named "file _ 1" and "file _ 2" corresponding to the 1 st block and the 2 nd block, by using a uniform operation interface.
If the operation instruction indicates to perform writing operation, writing the data to be written into the file corresponding to each block covered by the address interval; for example, when the block size is 64k, if the application layer is to write data in an address interval 0x00000 to 0x20000 in the linux system, the Flash adaptation processing module writes data stored in files corresponding to blocks covered by the address interval, that is, files named "file _ 1" and "file _ 2" corresponding to the 1 st block and the 2 nd block, by using a uniform operation interface.
If the operation instruction indicates to perform an erasing operation, erasing data in the file corresponding to each block covered by the address interval; when the block size is 64k, the application layer needs to read data in an address interval 0x00000 to 0x20000 in the linux system, and then, through the Flash adaptation processing module and by using a uniform operation interface, all the stored data in the files corresponding to the blocks covered by the address interval, namely the files named "file _ 1" and "file _ 2" corresponding to the 1 st block and the 2 nd block, are written to be 1.
And when the operation mode is determined to be the operation according to the physical address mode, reading, writing or erasing the data in each block corresponding to the address interval according to the operation instruction.
Specifically, if the operation instruction indicates to perform a read operation, data stored in each block corresponding to the address interval is read; for example, when the block size is 64k, if the application layer needs to read data in an address interval of 0x10000 to 0x20000 in the UCOS system, the Flash adaptation processing module reads the data stored in each block covered by the address interval, that is, the 2 nd block, by using a uniform operation interface.
If the operation instruction indicates to perform writing operation, writing the data to be written into each block corresponding to the address interval; for example, when the block size is 64k, if the application layer needs to read data in an address interval of 0x10000 to 0x20000 in the UCOS system, the Flash adaptation processing module uses a uniform operation interface to erase data stored in each block covered by the address interval, that is, the 2 nd block, and then performs a write operation.
If the operation instruction indicates to carry out erasing operation, erasing data stored in each block corresponding to the address interval; for example, when the block size is 64k, if the application layer wants to read data in an address interval 0x10000 to 0x20000 in the UCOS system, the Flash adaptation processing module uses a uniform operation interface to write all the stored data in each block covered by the address interval, i.e. the 2 nd block, to 1.
Therefore, the Flash of each operating system is operated by using a uniform interface.
The method and apparatus of the present invention will be described in detail with reference to the accompanying drawings using specific embodiments.
Based on the same inventive concept, according to the flash memory operating method based on the embedded system provided in the above embodiment of the present invention, correspondingly, another embodiment of the present invention further provides a flash memory operating device based on the embedded system, and a schematic structural diagram of the device is shown in fig. 4, which specifically includes:
a receiving unit 400, configured to receive a flash memory operation request initiated by an application layer, where the flash memory operation request carries an operation instruction, operation address information, and an operation mode;
a judging unit 410 for judging whether the operation mode is operated in a file manner or a physical address manner;
a first executing unit 420, configured to, when it is determined that the operation mode is a file-based operation, continuously determine whether a file corresponding to the address interval indicated by the operation address information exists in the flash memory, and if yes, perform a corresponding operation on the file according to the operation instruction; otherwise, creating a file corresponding to the address interval, and performing corresponding operation on the created file according to the operation instruction;
and the second execution unit 430 is configured to, when it is determined that the operation mode is the operation according to the physical address mode, perform a corresponding operation according to the operation instruction and the address interval indicated by the operation address information.
A configuration unit 440, configured to, before receiving a flash memory operation request initiated by an application layer, obtain a preset operation mode, determine whether the operation mode is operated in a file manner or in a physical address manner, when it is determined that the operation mode is operated in the file manner, create a file storage path when performing subsequent operation on a flash memory, obtain memory technology device information of the flash memory, configure block information according to the memory technology device information, and when it is determined that the operation mode is operated in the physical address manner, obtain common flash memory interface information of the flash memory, and configure block information according to the common flash memory interface information; wherein the block information includes a block number, a head address, and a block size of each block.
The first execution unit 420 is specifically configured to: determining an address interval according to the initial physical address and the end physical address carried in the operation address information;
and determining the block number of each block covered by the address interval according to the block information, and judging whether a file corresponding to the block number of each covered block exists in the flash memory.
The first execution unit 420 is specifically configured to: determining the block number of each block covered by the address interval, creating a file corresponding to each block in each block, and naming the created file by adopting the block number of each block.
The first execution unit 420 is specifically configured to: and reading, writing or erasing the data in the file corresponding to each block covered by the address interval according to the operation instruction.
The second execution unit 430 is specifically configured to:
and when the operation mode is determined to be the operation according to the physical address mode, reading, writing or erasing the data in each block corresponding to the address interval according to the operation instruction.
In summary, the solution provided by the embodiment of the present invention provides a unified Flash operation method for embedded products of different operating systems, and provides a set of standard adaptive operation interfaces for an application layer in a modular manner, which makes the compatibility of Flash devices better, and after a file storage path for subsequent Flash operation is planned during system software design, a technician does not need to care what embedded platform the application layer software is applied to, and directly adopts the Flash operation method of the embodiment of the present invention, which can stably and reliably perform related operations on Flash, reduce the possibility of out-of-range storage, and ensure the reliability of the system.
The Flash operation processing technology provided by the embodiment of the invention provides a method for operating and managing Flash in a unified way for embedded products of different operating systems, so that products of different operating systems can be mutually inherited, products with the same application can be rapidly switched, and the development and debugging time of new products is shortened. And a clear layered design is provided, the stability of system software is improved, and the overall performance of the product is improved.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.
Claims (9)
1. A Flash memory operation method based on embedded system, the said embedded system includes Linux system and UCOS system, increase a Flash adaptation processing module between said Linux system and UCOS system and application module, used for offering a set of standard adaptation operation interface for upper application module, characterized by that, the said method includes:
in a system configuration stage, the Flash adaptation processing module provides an initialization interface for calling of an application layer;
when the application layer calls the initialization interface, the embedded system starts initialization operation, acquires a preset operation mode and judges whether the operation mode is operated according to a file mode or a physical address mode;
receiving a physical address to be operated carried in an instruction sent by the application layer;
if the current system uses a Linux system, setting the operation mode corresponding to the indication to be operated according to a file mode, and searching a file in the Linux system according to the physical address to be operated for operation;
and if the UCOS system is used by the current system, setting the operation mode corresponding to the indication to operate according to a physical address mode, and sending the physical address to be operated to the Flash adaptation processing module, so that the UCOS system operates the Flash adaptation processing module according to the physical address.
2. The method of claim 1, wherein the determining whether the operation mode is operated in a file manner or a physical address manner specifically comprises:
when the operation mode is determined to be operated according to a file mode, establishing a file storage path when the flash memory is subjected to subsequent operation, acquiring the memory technology equipment information of the flash memory, and configuring block information according to the memory technology equipment information;
when the operation mode is determined to be the operation according to the physical address mode, acquiring public flash memory interface information of a flash memory, and configuring block information according to the public flash memory interface information;
wherein the block information includes a block number, a head address, and a block size of each block.
3. The method according to claim 2, wherein the searching for the file in the Linux system according to the physical address to be operated specifically comprises:
judging whether a file corresponding to the address interval indicated by the physical address to be operated exists in the Flash adaptation processing module;
if yes, searching a file in the Linux system according to the physical address to be operated;
and if not, creating a file for each block in the blocks covered by the address interval, and taking the created file as a system file corresponding to the physical address to be operated.
4. The method of claim 3, wherein determining whether a file corresponding to the address interval indicated by the physical address to be operated exists in the Flash adaptation processing module comprises:
determining an address interval according to a starting physical address and an ending physical address carried in the physical address information to be operated;
and determining the block number of each block covered by the address interval according to the block information, and judging whether a file corresponding to the block number of each covered block exists in the flash memory.
5. The method of claim 3, wherein creating a file for each of the blocks covered by the address range comprises:
determining the block numbers of the blocks covered by the address interval, creating a file corresponding to each block in the blocks, and naming the created file by adopting the block number of each block.
6. The method of claim 4 or 5, wherein creating a file for each of the blocks covered by the address range further comprises:
and reading, writing or erasing the data in the file corresponding to each block covered by the address interval according to the physical address to be operated.
7. The method of claim 3, wherein enabling the UCOS system to operate the Flash adaptation processing module according to the physical address specifically comprises:
and when the operation mode is determined to be the operation according to the physical address mode, triggering the Flash adaptation processing module to read, write or erase the data in each block corresponding to the address interval according to the physical address to be operated.
8. A flash memory operating device based on an embedded system including a Linux system and a UCOS system, the device comprising:
the Flash adaptation processing module is positioned between the Linux system, the UCOS system and the application module and is used for providing a set of standard adaptation operation interfaces for the upper application module, the Flash adaptation processing module provides an initialization interface for calling of an application layer in a system configuration stage, when the initialization interface is called by the application layer, the embedded system starts initialization operation and obtains a preset operation mode, and whether the operation mode is operated according to a file mode or a physical address mode is judged;
a receiving unit, configured to receive a physical address to be operated, where the physical address to be operated is carried in an instruction sent by the application layer;
a judgment unit including
The first execution unit is used for setting the operation mode corresponding to the indication to be operated according to a file mode if the current system uses a Linux system, and searching a file in the Linux system for operation according to the physical address to be operated;
and the second execution unit is used for setting the operation mode corresponding to the indication to be operated according to a physical address mode if the UCOS system is used by the current system, and sending the physical address to be operated to the Flash adaptation processing module so that the UCOS system operates the Flash adaptation processing module according to the physical address.
9. The apparatus of claim 8, further comprising: the configuration unit is used for acquiring a preset operation mode, judging whether the operation mode is operated according to a file mode or a physical address mode, creating a file storage path when the flash memory is subsequently operated when the operation mode is determined to be operated according to the file mode, acquiring the memory technology equipment information of the flash memory, configuring block information according to the memory technology equipment information, acquiring the public flash memory interface information of the flash memory when the operation mode is determined to be operated according to the physical address mode, and configuring the block information according to the public flash memory interface information; wherein the block information includes a block number, a head address, and a block size of each block.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610950273.1A CN106528440B (en) | 2014-03-26 | 2014-03-26 | Flash memory operation method and device based on embedded system |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410117104.0A CN103870392B (en) | 2014-03-26 | 2014-03-26 | Flash memory operating method and device based on embedded system |
CN201610950273.1A CN106528440B (en) | 2014-03-26 | 2014-03-26 | Flash memory operation method and device based on embedded system |
Related Parent Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410117104.0A Division CN103870392B (en) | 2014-03-26 | 2014-03-26 | Flash memory operating method and device based on embedded system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106528440A CN106528440A (en) | 2017-03-22 |
CN106528440B true CN106528440B (en) | 2020-06-09 |
Family
ID=50908946
Family Applications (2)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610950273.1A Active CN106528440B (en) | 2014-03-26 | 2014-03-26 | Flash memory operation method and device based on embedded system |
CN201410117104.0A Active CN103870392B (en) | 2014-03-26 | 2014-03-26 | Flash memory operating method and device based on embedded system |
Family Applications After (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410117104.0A Active CN103870392B (en) | 2014-03-26 | 2014-03-26 | Flash memory operating method and device based on embedded system |
Country Status (1)
Country | Link |
---|---|
CN (2) | CN106528440B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109344089B (en) * | 2018-10-18 | 2021-06-22 | 京信通信***(中国)有限公司 | Method and device for operating norflash |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100454302C (en) * | 2005-10-24 | 2009-01-21 | 中兴通讯股份有限公司 | File management system and method |
KR100843543B1 (en) * | 2006-10-25 | 2008-07-04 | 삼성전자주식회사 | System comprising flash memory device and data recovery method thereof |
CN101149685A (en) * | 2007-11-07 | 2008-03-26 | 苏州壹世通科技有限公司 | Combined device and method for starting up multiple operation system from mobile memory apparatus |
CN102736932B (en) * | 2012-05-16 | 2015-12-16 | 上海斐讯数据通信技术有限公司 | The method for making of image file, image file and the starting factor method of multisystem |
CN103577201B (en) * | 2012-07-20 | 2018-04-06 | 上海斐讯数据通信技术有限公司 | The update method and system of Embedded Double system |
CN103269391B (en) * | 2013-05-03 | 2016-09-14 | 惠州Tcl移动通信有限公司 | A kind of bracket with foldable protection set assembly |
CN103345456B (en) * | 2013-06-21 | 2015-12-02 | 烽火通信科技股份有限公司 | Regulate circuit and the method for BootLoader enabling address |
-
2014
- 2014-03-26 CN CN201610950273.1A patent/CN106528440B/en active Active
- 2014-03-26 CN CN201410117104.0A patent/CN103870392B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN103870392B (en) | 2017-01-11 |
CN106528440A (en) | 2017-03-22 |
CN103870392A (en) | 2014-06-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103309709A (en) | Firmware upgrading method, device and communication equipment | |
KR101555210B1 (en) | Apparatus and method for downloadin contents using movinand in portable terminal | |
CN104679540A (en) | Computer system and computer system starting method | |
CN104216771B (en) | The method for restarting and device of software program | |
CN106020837A (en) | Method and system for loading set top box drive | |
CN110765032A (en) | Method for reading and writing I2C memory based on system management bus interface | |
CN108829449A (en) | A kind of method, apparatus, equipment and the medium of BIOS start-up operation system | |
CN110209420A (en) | A kind of method and device updating bootstrap loader | |
CN113190241B (en) | Method and device for expanding capacity of data partition, electronic equipment and storage medium | |
US20110004719A1 (en) | Memory Element | |
CN112181637B (en) | Memory resource allocation method and device | |
CN106528440B (en) | Flash memory operation method and device based on embedded system | |
CN104182352A (en) | Device and method for accessing to physical memory address spaces larger than 4GB | |
CN116954674A (en) | eMMC firmware upgrading method, firmware upgrading equipment and storage device | |
CN105511904A (en) | Method and apparatus for automatically updating shortcut window | |
CN105278993A (en) | Linux system based drive module upgrading method and apparatus | |
CN113010195B (en) | System upgrading method, storage medium and terminal equipment | |
CN103777955A (en) | Method and device for installing and operating Unix-like in Windows environment | |
CN110515751B (en) | Method and system for loading and running VxWorks real-time protection process | |
CN113190445A (en) | Interface test method, interface test device and interface test system | |
CN104090845A (en) | Automatic game testing method and system and related device | |
CN111063387B (en) | Method, device and equipment for testing performance of solid state disk and storage medium | |
CN110968337A (en) | Software upgrading method and device | |
CN110928582B (en) | Information processing apparatus and method of configuring target device of information processing apparatus | |
CN111966285B (en) | Method, main control chip and system for storing data into EEPROM |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |