WO2017020647A1 - 基于新型存储器的嵌入式文件系统及其实现方法 - Google Patents

基于新型存储器的嵌入式文件系统及其实现方法 Download PDF

Info

Publication number
WO2017020647A1
WO2017020647A1 PCT/CN2016/084288 CN2016084288W WO2017020647A1 WO 2017020647 A1 WO2017020647 A1 WO 2017020647A1 CN 2016084288 W CN2016084288 W CN 2016084288W WO 2017020647 A1 WO2017020647 A1 WO 2017020647A1
Authority
WO
WIPO (PCT)
Prior art keywords
nand flash
flash chip
spi nand
file
spi
Prior art date
Application number
PCT/CN2016/084288
Other languages
English (en)
French (fr)
Inventor
闫栓
Original Assignee
深圳市中兴微电子技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市中兴微电子技术有限公司 filed Critical 深圳市中兴微电子技术有限公司
Publication of WO2017020647A1 publication Critical patent/WO2017020647A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring

Definitions

  • the present invention relates to the field of computer storage, and in particular, to an embedded file system based on a novel memory and an implementation method thereof.
  • the size of the entire chip is required to be smaller and smaller, the external interface is less and less, and at the same time, the data storage requirements are met.
  • the design and layout of the flash memory are complicated, so a new type of memory is integrated on such a chip while implementing the file system. The method is a very meaningful thing.
  • the file system is based on NAND (Not AND, Nand) Flash memory, which has no loss of power-down data, fast data access speed, electrically erasable, large capacity, and online programmable. , low price and high reliability and many other advantages.
  • NAND Not AND, Nand Flash memory
  • the software system level implementation (including the related timing configuration and implementation of I/O interface functions) is realized by serial accessing data using a complicated input/output (I/O) interface.
  • I/O input/output
  • an embodiment of the present invention provides an embedded file system based on a novel memory and an implementation method thereof.
  • Embodiments of the present invention provide an implementation method of an embedded file system based on a novel memory.
  • the system has a serial peripheral interface and a non-flash SPI Nand flash chip; the method includes:
  • MTD layer interface corresponding to the file processing; the MTD layer interface is used when accessing the SPI Nand flash chip;
  • the SPI Nand flash chip is accessed in the specified partition to complete the access operation to the file.
  • the determining that the system supports the SPI Nand flash chip includes:
  • Detecting a type of the chip and ID information of the chip if the type of the chip and the ID information are the same as the pre-stored chip type and ID information, determining that the system supports the SPI Nand flash chip; otherwise It is determined that the system does not support the SPI Nand flash chip.
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the current block erase operation is ended; otherwise, the erase interface function is called through the MTD layer interface to complete the erase operation on the current block, and the result is returned to the MTD. Floor.
  • the embodiment of the invention further provides an embedded file system based on a novel memory, the system comprising: a serial peripheral interface and a non-flash SPI Nand flash chip, an initialization setting module, a bad block management module, and a file processing module;
  • the initialization setting module is configured to: after the system is initialized, determine that the system supports the SPI Nand flash chip; set a memory technology device MTD layer interface corresponding to file processing; and the MTD layer interface is used to access the Called when the SPI Nand flash chip is used;
  • the bad block management module is configured to identify and mark and store the bad blocks of the SPI Nand flash chip; and store the bad block marks for the file system to access the SPI Nand flash chip, and perform the marked bad blocks.
  • the file processing module is configured to access the SPI Nand flash chip in a specified partition during file processing to complete access to the file.
  • the initial setting module determines that the system supports the SPI Nand flash chip, and includes:
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the write data interface function is called through the MTD layer interface, and the write command is executed according to the address of the specified buffer, and finally the data in the memory is written into the address specified by the SPI Nand flash chip; wherein, the SPI corresponding to the data read and write process is used. Standard mode, or Dual mode, or Qual mode.
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the current block erase operation is ended; otherwise, the erase interface function is called through the MTD layer interface to complete the erase operation on the current block, and the result is returned to the MTD. Floor.
  • the embedded file system based on the novel memory and the implementation method thereof are provided in the embodiment of the present invention, wherein the system is provided with a serial peripheral interface and a non-flash (SPI Nand flash) chip; the method includes: after the system is initialized Determining that the system supports the SPI Nand flash chip; setting a memory technology device (MTD) layer interface corresponding to file processing; the MTD layer interface is used when accessing the SPI Nand flash chip; The bad blocks of the SPI Nand flash chip are marked and stored; the stored bad block marks are used to check the marked bad blocks when the file system accesses the SPI Nand flash chip; the SPI Nand flash is determined according to preset conditions.
  • the chip performs partition processing; during file processing, the SPI Nand flash chip is accessed in a specified partition to complete access to the file.
  • the embodiment of the invention implements the operation of the file system based on the SPI Nand flash chip.
  • the chip pin since the chip pin only occupies four wires, the space for the PCB layout is saved, and the requirements of the chip size and the interface are small;
  • the SPI standard interface is a high-speed, full-duplex, synchronous communication bus, the data read and write speed is guaranteed to meet the speed requirement of file access; in addition, based on the characteristics of the SPI standard interface, the software system level of the present invention is complicated to implement. Low degree and simple design.
  • FIG. 1 is a schematic flowchart of an implementation method of an embedded file system based on a novel memory according to an embodiment of the present invention
  • FIG. 2 is a schematic structural diagram of an embedded file system based on a novel memory according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of an embedded file system based on an SPI Nand flash chip according to scenario 1 of the present invention
  • FIG. 4 is a schematic diagram of a startup process of an embedded file system based on a SPI Nand flash chip according to scenario 2 of the present invention
  • FIG. 5 is a schematic diagram of a bad block management process of an embedded file system based on the SPI Nand flash chip according to the third scenario of the present invention.
  • FIG. 6 is a schematic diagram of a file reading process of an embedded file system based on the SPI Nand flash chip according to the fourth scenario of the present invention.
  • FIG. 7 is a schematic diagram of a file update process of an embedded file system based on the SPI Nand flash chip according to the fifth aspect of the present invention.
  • FIG. 8 is a schematic diagram of a file deletion process of an embedded file system based on the SPI Nand flash chip according to the scenario 6 of the present invention.
  • the system is provided with a serial peripheral interface and a non-flash (SPI Nand flash) chip; the method includes: after the system is initialized, determining that the system supports the SPI Nand flash chip Setting a memory technology device (MTD) layer interface corresponding to the file processing; the MTD layer interface is used to access the SPI Nand flash chip; identifying the bad block of the SPI Nand flash chip and marking and storing The stored bad block flag is used to check the marked bad block when the file system accesses the SPI Nand flash chip; the SPI Nand flash chip is partitioned according to a preset condition; during file processing, the specified The partition accesses the SPI Nand flash chip to complete access to the file.
  • MTD memory technology device
  • FIG. 1 is a schematic flowchart of a method for implementing an embedded file system based on a novel memory according to an embodiment of the present invention. As shown in FIG. 1 , the method includes:
  • Step 101 After the system is initialized, determine that the system supports the SPI Nand flash chip.
  • Step 102 Set an MTD layer interface corresponding to the file processing; the MTD layer interface is used when accessing the SPI Nand flash chip;
  • Step 103 Identify bad blocks of the SPI Nand flash chip and mark and store them; store the bad block marks for the file system to access the SPI Nand flash chip, and check the marked bad blocks;
  • Step 104 Perform partition processing on the SPI Nand flash chip according to a preset condition.
  • Step 105 During the file processing, the SPI Nand flash chip is in the specified partition. Make an access and complete the access to the file.
  • the access operation to the file includes at least: reading, updating, deleting, and the like.
  • the determining that the system supports the SPI Nand flash chip includes:
  • Detecting a type of the chip and identification (ID) information of the chip such as a manufacturer ID of the chip, if the type of the chip and the ID information are the same as a pre-stored chip type and ID information, determining the The system supports the SPI Nand flash chip; otherwise, it is determined that the system does not support the SPI Nand flash chip.
  • ID identification
  • the SPI Nand flash chip In practical applications, the SPI Nand flash chip must be registered first.
  • the SPI Nand controller (controller) corresponding to the chip has a unique way to operate or read and write the SPI Nand flash chip, and defines the interface suitable for the SPI Nand controller.
  • the functions related to the SPI Nand flash chip are defined in the struct nand_chip structure, and the implementation of these functions is to assign a value to the function pointer in the structure.
  • SPI Nand flash chip information is added to this structure in advance in this structure.
  • the entire SPI Nand flash is registered into the memory technology device core (MTD Core) by calling the add_mtd_device function, and the add_mtd_partitions function registers the respective partitions of the SPI Nand flash into the MTD Core.
  • Boot partition, kernel partition and other file system partitions can be performed on SPI Nand flash as needed.
  • the chip is subjected to bad block management operations. Because SPI Nand flash can happen The bit is inverted, so an error checking and correction (ECC) operation must be performed.
  • ECC error checking and correction
  • the SPI Nand flash chip may have bad blocks (the bad blocks are marked at the factory), and new bad blocks may appear during use, so the SPI Nand driver must manage the bad blocks.
  • the SPI Nand flash chip implements a specific bad block management mechanism, implements a bad block mark of the SPI Nand flash chip, and stores the bad block mark in the bad block table, and the file system passes through a memory technology device (MTD) layer. When called, it can be used to determine whether the current block is a bad block. If it is, it cannot read or write the current block.
  • MTD memory technology device
  • the entire SPI Nand flash is registered into the MTD Core by calling the add_mtd_device function, and the add_mtd_partitions function registers the respective partitions of the SPI Nand flash into the MTD Core.
  • Boot partition, kernel partition and other file system partitions can be performed on SPI Nand flash as needed.
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the command when the file is read, the command will be passed to the MTD layer, and the MTD layer will call the nand_read function. Then the nand_read function will call the cmdfunc function in the struct nand_chip.
  • This cmdfunc function and the specific SPI Nand controller related, its role is to make the SPI Nand controller send a read command to the SPI Nand flash chip, after receiving the command, the SPI Nand flash chip will be ready to wait for the next read of the SPI Nand controller.
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the write data interface function is called through the MTD layer interface, and the write command is executed according to the address of the specified buffer, and finally the data in the memory is written into the address specified by the SPI Nand flash chip; wherein the data writing process uses the SPI corresponding Standard mode, or Dual mode, or Qual mode.
  • the data in the SPI Nand flash chip will be written, the nand_write function will be called through the MTD layer, and then the related cmdfunc function of the SPI Nand controller will be called.
  • the write command is executed to update the data to the corresponding block, page, and oob, and the SPI Nand flash data is written.
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the current block erase operation is ended; otherwise, the erase interface function is called through the MTD layer interface to complete the erase operation on the current block, and the result is returned to the MTD. Floor.
  • the embodiment of the invention implements the operation of the file system based on the SPI Nand flash chip.
  • the chip pin since the chip pin only occupies four wires, space is saved for the layout of the printed circuit board (PCB), and the chip size is small. And the interface is less; and, because the SPI standard interface is a high-speed, full-duplex, synchronous communication bus, the data read and write speed is guaranteed, and the file access speed is met; in addition, based on the characteristics of the SPI standard interface,
  • the invention software system level implementation has low complexity and simple design.
  • the embodiment of the present invention further provides an embedded file system based on a novel memory.
  • the system includes: a serial peripheral interface and a non-flash (SPI Nand flash) chip 201, an initialization setting module 202, and a bad a block management module 203, a file processing module 204; wherein
  • SPI Nand flash non-flash
  • the initialization setting module 202 is configured to: after the system is initialized, determine that the system supports the SPI Nand flash chip 201; set a memory technology device MTD layer interface corresponding to file processing; and the MTD layer interface is used for accessing The SPI Nand flash chip 201 is adjusted use;
  • the bad block management module 203 is configured to identify and mark and store the bad blocks of the SPI Nand flash chip 201; the stored bad block marks are used to mark the bad when the file system accesses the SPI Nand flash chip. Block check;
  • the file processing module 204 is configured to access the SPI Nand flash chip 201 in a specified partition during file processing to complete an access operation on the file.
  • the access operation to the file includes at least: reading, updating, deleting, and the like.
  • the initial setting module 202 determines that the system supports the SPI Nand flash chip, and includes:
  • Detecting a type of the chip and ID information of the chip if the type of the chip and the ID information are the same as the pre-stored chip type and ID information, determining that the system supports the SPI Nand flash chip; otherwise It is determined that the system does not support the SPI Nand flash chip.
  • the SPI Nand flash chip In practical applications, the SPI Nand flash chip must be registered first.
  • the SPI Nand controller (controller) corresponding to the chip has a unique way to operate or read and write the SPI Nand flash chip, and defines the interface suitable for the SPI Nand controller.
  • the functions related to the SPI Nand flash chip are defined in the struct nand_chip structure, and the implementation of these functions is to assign a value to the function pointer in the structure.
  • the driver After setting the pointer function in the related nand_chip structure, scan the current SPI Nand flash chip type and chip ID, such as the vendor ID.
  • the driver reads the ID of the specific SPI Nand flash chip, and then searches according to the read content to determine the manufacturer of the SPI Nand flash chip.
  • the chip type is different for different chip feature settings. If it is not found, the SPI Nand driver will fail to load. Therefore, to add SPI Nand flash chip information to this structure in advance In the structure.
  • the entire SPI Nand flash is registered into the MTD Core by calling the add_mtd_device function, and the add_mtd_partitions function registers the respective partitions of the SPI Nand flash into the MTD Core.
  • Boot partition, kernel partition and other file system partitions can be performed on SPI Nand flash as needed.
  • the chip is subjected to bad block management operations. Since bit inversion may occur in SPI Nand flash, error checking and correction (ECC) operations must be performed.
  • ECC error checking and correction
  • the SPI Nand flash chip may have bad blocks (the bad blocks are marked at the factory), and new bad blocks may appear during use, so the SPI Nand driver must manage the bad blocks.
  • the SPI Nand flash chip implements a specific bad block management mechanism, implements a bad block mark of the SPI Nand flash chip, and stores the bad block mark in the bad block table, and the file system passes through a memory technology device (MTD) layer. When called, it can be used to determine whether the current block is a bad block. If it is, it cannot read or write the current block.
  • MTD memory technology device
  • the entire SPI Nand flash is registered into the MTD Core by calling the add_mtd_device function, and the add_mtd_partitions function registers the respective partitions of the SPI Nand flash into the MTD Core.
  • Boot partition, kernel partition and other file system partitions can be performed on SPI Nand flash as needed.
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the command when the file is read, the command will be passed to the MTD layer, the MTD layer will call the nand_read function, and then the nand_read function will call the struct.
  • the cmdfunc function in nand_chip this cmdfunc function is related to the specific SPI Nand controller. Its function is to make the SPI Nand controller issue a read command to the SPI Nand flash chip. After receiving the command, the SPI Nand flash chip will be ready to wait for the SPI. The next read of the Nand controller.
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the write data interface function is called through the MTD layer interface, and the write command is executed according to the address of the specified buffer, and finally the data in the memory is written into the address specified by the SPI Nand flash chip; wherein, the SPI corresponding to the data read and write process is used. Standard mode, or Dual mode, or Qual mode.
  • the data in the SPI Nand flash chip will be written, the nand_write function will be called through the MTD layer, and then the related cmdfunc function of the SPI Nand controller will be called.
  • the write command is executed to update the data to the corresponding block, page, and oob, and the SPI Nand flash data is written.
  • the accessing the SPI Nand flash chip in the specified partition includes:
  • the current block erase operation is ended; otherwise, the erase interface function is called through the MTD layer interface to complete the erase operation on the current block, and the result is returned to the MTD. Floor.
  • the file deletion operation will pass the nand_erase interface of the MTD layer, and then call the module to provide a bad block information table, and determine whether the current block is a bad block according to the information table. If the current block is marked as a bad block, the current block is ended.
  • the delete operation otherwise, the erase operation is performed on the current block, the erase interface designed by the module is called, the erase command is recognized, the erase operation is completed on the chip, and the result is returned to the MTD layer.
  • the SPI Nand flash chip has a flash command set and a Serial Peripheral Interface (SPI). Therefore, the SPI Nand flash chip has the characteristics of flash on the one hand and the advantages of the SPI standard interface on the other hand. :
  • the chip design is simple and the complexity is low, which reduces the hidden dangers and risks of software and hardware involved in system level implementation such as timing and I/O operations.
  • the embedded file system based on the SPI Nand flash chip in this application scenario is shown in FIG. 3, and includes: upper file operations 1, 2, . . . , n; MTD layer 301, running module 302, and spi nand flash chip 303.
  • the operation module 302 includes: an initialization and bad block management module 3021, a write module 3022, a read module 3023, and an erase module 3024;
  • the initialization and bad block management module 3021 is configured to perform initialization of a file system, partition processing, and management of bad blocks;
  • the writing module 3022 is configured to perform a file writing operation
  • the reading module 3023 is configured to perform a read operation of the file
  • the erasing module 3024 is configured to perform a delete operation of the file.
  • File operations are mainly the operations of adding, changing, and deleting files in an embedded system.
  • an MTD system is provided to establish a unified, abstract interface for flash for embedded systems.
  • the file operating system accesses the driver of the underlying SPI Nand through the interface function of the MTD layer, and completes the access operation on the data on the flash.
  • FIG. 4 is a schematic diagram of the startup process of the embedded file system based on the SPI Nand flash chip in the application scenario, and the process is as follows:
  • Step 401 After the embedded file system is powered on, the module is called;
  • the module is the running module 302 described in the scenario 1.
  • Step 402 Apply a resource and set a data buffer to initialize the SPI Nand flash chip.
  • Step 403 Determine whether the file system supports the current chip according to the unique chip type and the ID information of the vendor. If yes, go to step 404; otherwise, go to step 407;
  • Step 404 Establish an interface for reading, writing, and erasing for the MTD layer.
  • the interface is called when the file is operated to access the SPI Nand flash chip.
  • Step 405 Establish a bad block table of SPI Nand
  • the bad block table is used to manage (record, or delete) bad block flag information.
  • Step 406 Establish a partition, that is, divide the SPI Nand flash into a boot partition and a kernel partition to facilitate operation of the file system.
  • Step 407 Exit the system of the present invention and return the result to the MTD layer.
  • FIG. 5 is a schematic diagram of a bad block management process of an embedded file system based on the SPI Nand flash chip in the application scenario, where the process is as follows:
  • Step 501 Write an interface for bad block marking
  • Step 502 Establish a structure in which the ECC of the SPI Nand flash is laid out in the oob, for storing the bad block information and the ECC data;
  • Step 503 reading the bad block flag information of each block of the SPI Nand flash and writing to the bad block table
  • 1 in the bad block table may represent a normal block, and 0 represents a bad block.
  • Step 504 The file system acquires the information of the bad block table through the MTD layer when accessing the SPI Nand flash within a certain partition address range;
  • Step 505 In the current partition address range, according to the information of the bad block table to determine whether the current block is a bad block, and if so, step 506; otherwise, step 507;
  • Step 506 Find whether the next block is a bad block
  • step 508 if the lookup is beyond the scope of the partition, it exits (step 508).
  • Step 507 Continue to perform an access operation
  • Step 508 Return the result to the MTD layer.
  • FIG. 6 is a schematic diagram of a file reading process of an embedded file system based on the SPI Nand flash chip in the application scenario, where the process is as follows:
  • Step 601 Mount the file system to the specified partition
  • Step 602 Perform file display, copy and other file operations on the file in the partition
  • Step 603 The file system calls to the read data interface function through the MTD layer interface, and specifies an address range for reading data from the SPI Nand and an address of the buffer for writing the data;
  • Step 604 Execute a read command to read data in the SPI Nand flash memory into the memory
  • qual mode has the highest transfer speed, but write protection and hold lines are used for data transfer.
  • Step 605 Return the result to the MTD layer.
  • FIG. 7 is a schematic diagram of a file update process of an embedded file system based on the SPI Nand flash chip in the application scenario, where the process is as follows:
  • Step 701 Mount the file system to the specified partition.
  • Step 702 Perform file creation, content update, and the like on the partition.
  • Step 703 The file system calls to the write data interface function through the MTD layer interface, and refers to Clear the data from the buffer address into the specified address of the SPI Nand flash memory;
  • Step 704 Perform a write command operation to write the data in the memory to the designated address of the SPI Nand flash memory;
  • Step 705 Return the result to the MTD layer.
  • FIG. 8 is a schematic diagram of an embedded file system file deletion process based on the SPI Nand flash chip in the application scenario, where the process includes:
  • Step 801 Mount the file system to the specified partition
  • Step 802 Perform file operations such as deleting a file on the partition.
  • Step 803 The file system calls the erase interface function through the MTD layer interface, and performs detection of the bad block flag. If the current block is a bad block, the erase operation cannot be performed, and the erase operation is skipped; if it is a normal block , performing a block erase operation;
  • Step 804 Return the result to the MTD layer.
  • the embodiment of the present invention implements the operation of the file system based on the SPI Nand flash chip.
  • the chip pin since the chip pin only occupies four wires, the space for the PCB layout is saved, and the chip size is small and the interface is small.
  • the SPI standard interface is a high-speed, full-duplex, synchronous communication bus, ensuring data read and write speeds, meeting the speed requirements of file access; in addition, based on the characteristics of the SPI standard interface, the software system level of the present invention The implementation complexity is low and the design is simple.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention can take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
  • the embodiment of the invention implements the operation of the file system based on the SPI Nand flash chip. Since the SPI standard interface is a high-speed, full-duplex, synchronous communication bus, the data read and write speed is ensured, and the file access speed requirement is met; Compared with the technology, since the chip pin only occupies four wires, it saves space for the layout of the PCB, and meets the requirements of small chip size and small interface; in addition, based on the characteristics of the SPI standard interface, the software system level implementation complexity of the present invention Low, simple design.

Abstract

本发明公开了一种基于新型存储器的嵌入式文件系统及其实现方法,该系统中设有串行外设接口与非闪存(SPI Nand flash)芯片;该方法包括:系统初始化后,确定系统支持SPI Nand flash芯片;设置文件处理时对应的内存技术设备(MTD)层接口;所述MTD层接口,用于访问所述SPI Nand flash芯片时被调用;识别SPI Nand flash芯片的坏块并进行标记、存储;所存储的坏块标记,用于文件系统访问SPI Nand flash芯片时,对已标记的坏块进行排查;依据预设条件对所述SPI Nand flash芯片进行分区处理;文件处理过程中,在指定的分区对所述SPI Nand flash芯片进行访问,完成对文件的访问操作。

Description

基于新型存储器的嵌入式文件系统及其实现方法 技术领域
本发明涉及计算机存储领域,尤其涉及一种基于新型存储器的嵌入式文件系统及其实现方法。
背景技术
在嵌入式产品开发领域当中,要求整个芯片的尺寸越来越小、外部接口越来越少,且同时又要满足对数据的存储需求。要达到上述要求,对Flash存储器的选择就有了诸多限制,通常意义的Flash存储器的管脚设计与布局都很复杂,因此在这样的一款芯片上面集成一种新型的存储器同时实现文件系统的方法是一件非常有意义的事情。
在数据的存储系统中,文件系统都是基于与非(Not AND,Nand)Flash存储器实现的,它具备掉电数据不丢失、快速数据存取速度、电可擦除、容量大、在线可编程、价格低廉和较高的可靠性等诸多优点。
但是,基于Nand flash存储器实现文件系统时,由于使用复杂的输入/输出(I/O)接口串行存取数据,使得软件系统级实现(包括相关时序配置、I/O接口函数的实现)的复杂度大大提高,且芯片的尺寸较大,外部接口较多,不能很好的满足现有对芯片尺寸小、接口少的要求。
发明内容
为解决现有存在的技术问题,本发明实施例提供一种基于新型存储器的嵌入式文件系统及其实现方法。
本发明实施例的技术方案实现如下:
本发明实施例提供了一种基于新型存储器的嵌入式文件系统的实现方 法,所述系统中设有串行外设接口与非闪存SPI Nand flash芯片;该方法包括:
所述系统初始化后,确定所述系统支持所述SPI Nand flash芯片;
设置文件处理时对应的内存技术设备MTD层接口;所述MTD层接口,用于访问所述SPI Nand flash芯片时被调用;
识别所述SPI Nand flash芯片的坏块并进行标记、存储;所存储的坏块标记,用于文件系统访问SPI Nand flash芯片时,对已标记的坏块进行排查;
依据预设条件对所述SPI Nand flash芯片进行分区处理;
文件处理过程中,在指定的分区对所述SPI Nand flash芯片进行访问,完成对文件的访问操作。
本发明实施例中,所述确定所述系统支持所述SPI Nand flash芯片,包括:
检测所述芯片的类型以及所述芯片的ID信息,如果所述芯片的类型以及所述ID信息与预先存储的芯片类型以及ID信息相同,则确定所述系统支持所述SPI Nand flash芯片;否则,确定所述系统不支持所述SPI Nand flash芯片。
本发明实施例中,所述文件处理为读取文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
通过MTD层接口调用读数据接口函数,依据读取数据的地址范围以及数据写入缓冲器的地址执行读命令,最终将SPI Nand flash芯片中的数据读取到内存中;其中,所述数据读取过程中使用SPI对应的标准standard模式、或双线Dual模式、或四线Qual模式。
本发明实施例中,所述文件处理为更新文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
通过MTD层接口调用写数据接口函数,依据指定的缓冲器的地址执行 写命令,最终将内存中的数据写入SPI Nand flash芯片指定的地址中;其中,所述数据写过程中使用SPI对应的standard模式、或Dual模式、或Qual模式。
本发明实施例中,所述文件处理为删除文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
进行坏块检测,如果确定当前块为坏块,则结束当前块的擦除操作;否则,通过MTD层接口调用擦除erase接口函数,完成对当前块的擦除操作,并将结果返回给MTD层。
本发明实施例还提供了一种基于新型存储器的嵌入式文件系统,该系统包括:串行外设接口与非闪存SPI Nand flash芯片、初始化设置模块、坏块管理模块、文件处理模块;其中,
所述初始化设置模块,配置为所述系统初始化后,确定所述系统支持所述SPI Nand flash芯片;设置文件处理时对应的内存技术设备MTD层接口;所述MTD层接口,用于访问所述SPI Nand flash芯片时被调用;
还配置为依据预设条件对所述SPI Nand flash芯片进行分区处理;
所述坏块管理模块,配置为识别所述SPI Nand flash芯片的坏块并进行标记、存储;所存储的坏块标记,用于文件系统访问SPI Nand flash芯片时,对已标记的坏块进行排查;
所述文件处理模块,配置为文件处理过程中,在指定的分区对所述SPI Nand flash芯片进行访问,完成对文件的访问操作。
本发明实施例中,所述初始化设置模块确定所述系统支持所述SPI Nand flash芯片,包括:
检测所述芯片的类型以及所述芯片的ID信息,如果所述芯片的类型以及所述ID信息与预先存储的芯片类型以及ID信息相同,则确定所述系统支持所述SPI Nand flash芯片;否则,确定所述系统不支持所述SPI Nand  flash芯片。
本发明实施例中,所述文件处理模块读取文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
通过MTD层接口调用读数据接口函数,依据读取数据的地址范围以及数据写入缓冲器的地址执行读命令,最终将SPI Nand flash芯片中的数据读取到内存中;其中,所述数据读取过程中使用SPI对应的标准standard模式、或双线Dual模式、或四线Qual模式。
本发明实施例中,所述文件处理模块更新文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
通过MTD层接口调用写数据接口函数,依据指定的缓冲器的地址执行写命令,最终将内存中的数据写入SPI Nand flash芯片指定的地址中;其中,所述数据读写过程中使用SPI对应的standard模式、或Dual模式、或Qual模式。
本发明实施例中,所述文件处理模块删除文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
进行坏块检测,如果确定当前块为坏块,则结束当前块的擦除操作;否则,通过MTD层接口调用擦除erase接口函数,完成对当前块的擦除操作,并将结果返回给MTD层。
本发明实施例提供的基于新型存储器的嵌入式文件系统及其实现方法,所述系统中设有串行外设接口与非闪存(SPI Nand flash)芯片;所述方法包括:所述系统初始化后,确定所述系统支持所述SPI Nand flash芯片;设置文件处理时对应的内存技术设备(MTD)层接口;所述MTD层接口,用于访问所述SPI Nand flash芯片时被调用;识别所述SPI Nand flash芯片的坏块并进行标记、存储;所存储的坏块标记,用于文件系统访问SPI Nand flash芯片时,对已标记的坏块进行排查;依据预设条件对所述SPI Nand flash 芯片进行分区处理;文件处理过程中,在指定的分区对所述SPI Nand flash芯片进行访问,完成对文件的访问操作。
本发明实施例基于SPI Nand flash芯片实现文件系统的操作,与现有技术相比,由于芯片管脚只占用四根线,为PCB的布局节省了空间,满足芯片尺寸小、接口少的要求;而且,由于SPI标准接口是一种高速的,全双工、同步的通信总线,保证数据读写速度,满足文件访问的速度要求;此外,基于SPI标准接口的特点,本发明软件系统级实现复杂度低,设计简单。
附图说明
在附图(其不一定是按比例绘制的)中,相似的附图标记可在不同的视图中描述相似的部件。具有不同字母后缀的相似附图标记可表示相似部件的不同示例。附图以示例而非限制的方式大体示出了本文中所讨论的各个实施例。
图1为本发明实施例所述基于新型存储器的嵌入式文件系统实现方法流程示意图;
图2为本发明实施例所述基于新型存储器的嵌入式文件系统的结构示意图;
图3为本发明场景一所述基于SPI Nand flash芯片的嵌入式文件系统结构示意图;
图4为本发明场景二所述基于SPI Nand flash芯片的嵌入式文件系统启动流程示意图;
图5为本发明场景三所述基于SPI Nand flash芯片的嵌入式文件系统的坏块管理流程示意图;
图6为本发明场景四所述基于SPI Nand flash芯片的嵌入式文件系统的文件读取流程示意图;
图7为本发明场景五所述基于SPI Nand flash芯片的嵌入式文件系统的文件更新流程示意图;
图8为本发明场景六所述基于SPI Nand flash芯片的嵌入式文件系统的文件删除流程示意图。
具体实施方式
本发明的实施例中,所述系统中设有串行外设接口与非闪存(SPI Nand flash)芯片;所述方法包括:所述系统初始化后,确定所述系统支持所述SPI Nand flash芯片;设置文件处理时对应的内存技术设备(MTD)层接口;所述MTD层接口,用于访问所述SPI Nand flash芯片时被调用;识别所述SPI Nand flash芯片的坏块并进行标记、存储;所存储的坏块标记,用于文件系统访问SPI Nand flash芯片时,对已标记的坏块进行排查;依据预设条件对所述SPI Nand flash芯片进行分区处理;文件处理过程中,在指定的分区对所述SPI Nand flash芯片进行访问,完成对文件的访问操作。
下面结合附图及具体实施例对本发明作进一步详细说明。
图1为本发明实施例所述基于新型存储器的嵌入式文件系统实现方法流程示意图,如图1所示,该方法包括:
步骤101:所述系统初始化后,确定所述系统支持该SPI Nand flash芯片;
步骤102:设置文件处理时对应的MTD层接口;所述MTD层接口,用于访问所述SPI Nand flash芯片时被调用;
步骤103:识别所述SPI Nand flash芯片的坏块并进行标记、存储;所存储的坏块标记,用于文件系统访问SPI Nand flash芯片时,对已标记的坏块进行排查;
步骤104:依据预设条件对所述SPI Nand flash芯片进行分区处理;
步骤105:文件处理过程中,在指定的分区对所述SPI Nand flash芯片 进行访问,完成对文件的访问操作。
这里,所述对文件的访问操作至少包括:读取、更新和删除等。
本发明实施例中,所述确定所述系统支持所述SPI Nand flash芯片,包括:
检测所述芯片的类型以及所述芯片的标识(ID)信息,如:芯片的厂商ID,如果所述芯片的类型以及所述ID信息与预先存储的芯片类型以及ID信息相同,则确定所述系统支持所述SPI Nand flash芯片;否则,确定所述系统不支持所述SPI Nand flash芯片。
实际应用时,需首先注册这个SPI Nand flash芯片,该芯片对应的SPI Nand控制器(controller)在操作或者读写SPI Nand flash芯片时有独特的方式,会定义适用于SPI Nand controller的接口。本发明实施例中,这些与SPI Nand flash芯片相关的函数都在struct nand_chip结构体中定义,这些函数的实现就是给此结构体中的函数指针赋值。
设置好相关的nand_chip结构体中的指针函数后,要扫描当前SPI Nand flash芯片的类型以及芯片ID,如厂商ID。当SPI Nand驱动被加载的时候,该驱动会去读取具体SPI Nand flash芯片的ID,然后根据读取的内容到上述定义的结构体中去查找,以此判断该SPI Nand flash芯片是哪个厂商的芯片类型,不同的芯片特性设置不同。若查找不到,则SPI Nand驱动就会加载失败。因此,要在这个结构体中事先将SPI Nand flash芯片信息添加到这个结构体中。
本发明实施例中,通过调用add_mtd_device函数把整个SPI Nand flash注册进内存技术设备核(MTD Core),而add_mtd_partitions函数则是把SPI Nand flash的各个分区分别注册进MTD Core。在SPI Nand flash上可根据需要进行了boot分区、kernel分区以及其它的文件系统分区。
这里,要对该芯片进行坏块管理操作。由于SPI Nand flash都可能发生 比特位反转,所以必须进行错误检查和纠正(ECC)操作。SPI Nand flash芯片可能会有坏块(出厂时会对坏块做标记),在使用过程中也还有可能会出现新的坏块,因此SPI Nand驱动必须对坏块进行管理。本发明实施例为SPI Nand flash芯片实现特定坏块管理机制,实现SPI Nand flash芯片的坏块标记,并且存储于坏块表中,在文件系统通过内存技术设备(memory technology device,MTD)层进行调用时,可以用于判断当前块是否是坏块,如果是,就不能对当前块进行读写等操作。
本发明实施例中,通过调用add_mtd_device函数把整个SPI Nand flash注册进MTD Core,而add_mtd_partitions函数则是把SPI Nand flash的各个分区分别注册进MTD Core。在SPI Nand flash上可根据需要进行了boot分区、kernel分区以及其它的文件系统分区。
本发明实施例中,所述文件处理为读取文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
通过MTD层接口调用读数据接口函数,依据读取数据的地址范围以及数据写入缓冲器的地址执行读命令,最终将SPI Nand flash芯片中的数据读取到内存中;其中,所述数据读取过程中使用SPI对应的standard(标准)模式、或Dual(双线)模式、或Qual(四线)模式。
相应的,在实际应用时,对文件进行读操作的时候,会将命令传递到MTD层,MTD层会调用nand_read函数,接着nand_read函数会调用struct nand_chip中的cmdfunc函数,这个cmdfunc函数与具体的SPI Nand controller相关,它的作用是使SPI Nand controller向SPI Nand flash芯片发出读命令,SPI Nand flash芯片收到命令后,就会做好准备等待SPI Nand controller的下一步读取。
本发明实施例中,所述文件处理为更新文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
通过MTD层接口调用写数据接口函数,依据指定的缓冲器的地址执行写命令,最终将内存中的数据写入SPI Nand flash芯片指定的地址中;其中,所述数据写过程中使用SPI对应的standard模式、或Dual模式、或Qual模式。
相应的,在实际应用时,对文件进行更新数据的时候,就会对SPI Nand flash芯片里面的数据进行写操作,通过MTD层会调用到nand_write函数,接着会调用SPI Nand controller的相关cmdfunc函数,执行写命令,将数据更新到对应的block、page以及oob当中,实现SPI Nand flash数据的写入。
本发明实施例中,所述文件处理为删除文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
进行坏块检测,如果确定当前块为坏块,则结束当前块的擦除操作;否则,通过MTD层接口调用擦除erase接口函数,完成对当前块的擦除操作,并将结果返回给MTD层。
本发明实施例基于SPI Nand flash芯片实现文件系统的操作,与现有技术相比,由于芯片管脚只占用四根线,为印制电路板(PCB)的布局节省了空间,满足芯片尺寸小、接口少的要求;而且,由于SPI标准接口是一种高速的,全双工、同步的通信总线,保证数据读写速度,满足文件访问的速度要求;此外,基于SPI标准接口的特点,本发明软件系统级实现复杂度低,设计简单。
本发明实施例还提供了一种基于新型存储器的嵌入式文件系统,如图2所示,该系统包括:串行外设接口与非闪存(SPI Nand flash)芯片201、初始化设置模块202、坏块管理模块203、文件处理模块204;其中,
所述初始化设置模块202,配置为所述系统初始化后,确定所述系统支持所述SPI Nand flash芯片201;设置文件处理时对应的内存技术设备MTD层接口;所述MTD层接口,用于访问所述SPI Nand flash芯片201时被调 用;
还配置为依据预设条件对所述SPI Nand flash芯片201进行分区处理;
所述坏块管理模块203,配置为识别所述SPI Nand flash芯片201的坏块并进行标记、存储;所存储的坏块标记,用于文件系统访问SPI Nand flash芯片时,对已标记的坏块进行排查;
所述文件处理模块204,配置为文件处理过程中,在指定的分区对所述SPI Nand flash芯片201进行访问,完成对文件的访问操作。
这里,所述对文件的访问操作至少包括:读取、更新和删除等。
本发明实施例中,所述初始化设置模块202确定所述系统支持该SPI Nand flash芯片,包括:
检测所述芯片的类型以及所述芯片的ID信息,如果所述芯片的类型以及所述ID信息与预先存储的芯片类型以及ID信息相同,则确定所述系统支持所述SPI Nand flash芯片;否则,确定所述系统不支持所述SPI Nand flash芯片。
实际应用时,需首先注册这个SPI Nand flash芯片,该芯片对应的SPI Nand控制器(controller)在操作或者读写SPI Nand flash芯片时有独特的方式,会定义适用于SPI Nand controller的接口。本发明实施例中,这些与SPI Nand flash芯片相关的函数都在struct nand_chip结构体中定义,这些函数的实现就是给此结构体中的函数指针赋值。
设置好相关的nand_chip结构体中的指针函数后,要扫描当前SPI Nand flash芯片的类型以及芯片ID,如厂商ID。当SPI Nand驱动被加载的时候,该驱动会去读取具体SPI Nand flash芯片的ID,然后根据读取的内容到上述定义的结构体中去查找,以此判断该SPI Nand flash芯片是哪个厂商的芯片类型,不同的芯片特性设置不同。若查找不到,则SPI Nand驱动就会加载失败。因此,要在这个结构体中事先将SPI Nand flash芯片信息添加到这个 结构体中。
本发明实施例中,通过调用add_mtd_device函数把整个SPI Nand flash注册进MTD Core,而add_mtd_partitions函数则是把SPI Nand flash的各个分区分别注册进MTD Core。在SPI Nand flash上可根据需要进行了boot分区、kernel分区以及其它的文件系统分区。
这里,要对该芯片进行坏块管理操作。由于SPI Nand flash都可能发生比特位反转,所以必须进行错误检查和纠正(ECC)操作。SPI Nand flash芯片可能会有坏块(出厂时会对坏块做标记),在使用过程中也还有可能会出现新的坏块,因此SPI Nand驱动必须对坏块进行管理。本发明实施例为SPI Nand flash芯片实现特定坏块管理机制,实现SPI Nand flash芯片的坏块标记,且存储于坏块表中,在文件系统通过内存技术设备(memory technology device,MTD)层进行调用时,可以用于判断当前块是否是坏块,如果是,就不能对当前块进行读写等操作。
本发明实施例中,通过调用add_mtd_device函数把整个SPI Nand flash注册进MTD Core,而add_mtd_partitions函数则是把SPI Nand flash的各个分区分别注册进MTD Core。在SPI Nand flash上可根据需要进行了boot分区、kernel分区以及其它的文件系统分区。
本发明实施例中,所述文件处理模块204读取文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
通过MTD层接口调用读数据接口函数,依据读取数据的地址范围以及数据写入缓冲器的地址执行读命令,最终将SPI Nand flash芯片中的数据读取到内存中;其中,所述数据读写过程中使用SPI对应的standard模式、或Dual模式、或Qual模式。
相应的,在实际应用时,对文件进行读操作的时候,会将命令传递到MTD层,MTD层会调用nand_read函数,接着nand_read函数会调用struct  nand_chip中的cmdfunc函数,这个cmdfunc函数与具体的SPI Nand controller相关,它的作用是使SPI Nand controller向SPI Nand flash芯片发出读命令,SPI Nand flash芯片收到命令后,就会做好准备等待SPI Nand controller的下一步读取。
本发明实施例中,所述文件处理模块204更新文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
通过MTD层接口调用写数据接口函数,依据指定的缓冲器的地址执行写命令,最终将内存中的数据写入SPI Nand flash芯片指定的地址中;其中,所述数据读写过程中使用SPI对应的standard模式、或Dual模式、或Qual模式。
相应的,在实际应用时,对文件进行更新数据的时候,就会对SPI Nand flash芯片里面的数据进行写操作,通过MTD层会调用到nand_write函数,接着会调用SPI Nand controller的相关cmdfunc函数,执行写命令,将数据更新到对应的block、page以及oob当中,实现SPI Nand flash数据的写入。
本发明实施例中,所述文件处理模块204删除文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
进行坏块检测,如果确定当前块为坏块,则结束当前块的擦除操作;否则,通过MTD层接口调用擦除erase接口函数,完成对当前块的擦除操作,并将结果返回给MTD层。
实际应用时,文件删除操作会通过MTD层的nand_erase接口,再调用到本模块提供坏块信息表,根据信息表确定当前块是否是坏块,如果当前块标记为坏块,则结束对当前块的删除操作;否则对当前块执行擦除操作,调用本模块设计的erase接口,识别erase命令,对芯片完成擦除操作,将结果返回给MTD层。
为了便于理解本发明方案,下面对SPI Nand flash芯片进行简单描述。
SPI Nand flash芯片具备闪存(flash)的命令集以及串行外设接口(Serial Peripheral Interface,SPI),因此,SPI Nand flash芯片一方面拥有flash的特点,另一方面又具备了SPI标准接口的优点:
1)是一种高速的,全双工、同步的通信总线,保证数据读写速度,满足文件访问的速度要求;
2)在芯片的管脚上只占用四根线,节约了芯片的管脚,同时为PCB的布局节省空间;
3)芯片设计简单,复杂度低,降低软件与硬件涉及时序、I/O操作等系统级实现的隐患和风险。
下面结合具体应用场景对本发明进行详细描述。
场景一
本应用场景基于SPI Nand flash芯片的嵌入式文件系统如图3所示,包括:上层文件操作1、2、…、n;MTD层301、运行模块302和spi nand闪存(flash)芯片303,所述运行模块302中包括:初始化及坏块管理模块3021、写入模块3022、读取模块3023以及擦除模块3024;其中,
所述初始化及坏块管理模块3021,配置为进行文件系统的初始化、分区处理以及坏块的管理;
所述写入模块3022,配置为执行文件的写入操作;
所述读取模块3023,配置为执行文件的读取操作;
所述擦除模块3024,配置为执行文件的删除操作。
文件操作主要是嵌入式系统中对文件的添加、更改、删除的操作。嵌入式系统中,提供了MTD系统来建立flash针对嵌入式系统的统一、抽象的接口。文件操作系统通过MTD层的接口函数访问到底层SPI Nand的驱动,完成对flash上数据的访问操作。
场景二
图4是本应用场景基于SPI Nand flash芯片的嵌入式文件系统启动流程示意图,该流程如下:
步骤401:嵌入式文件系统上电后,调用到本模块;
所述本模块为场景一中所述运行模块302。
步骤402:申请资源并设置数据缓冲器(buffer),对SPI Nand flash芯片进行初始化;
步骤403:根据唯一的芯片类型以及厂商的ID信息,判断文件系统是否支持当前芯片,如果支持,则执行步骤404;否则,执行步骤407;
步骤404:为MTD层建立读、写、擦除的接口;
这里,对文件操作的时会调用到所述接口,以对SPI Nand flash芯片进行访问。
步骤405:建立SPI Nand的坏块表;
这里,所述坏块表用于管理(记录、或删除)坏块标记信息。
步骤406:建立分区,即:将SPI Nand flash划分成boot分区、kernel分区,以便于文件系统的操作;
步骤407:退出本发明系统,向MTD层返回结果。
场景三
图5为本应用场景基于SPI Nand flash芯片的嵌入式文件系统的坏块管理流程示意图,该流程如下:
步骤501:编写用于坏块标记的接口;
步骤502:建立SPI Nand flash的ECC在oob中布局的结构体,以用于保存坏块信息和ECC数据;
步骤503:通过读取SPI Nand flash每个block的坏块标记信息,并写入到坏块表中;
这里,所述坏块表中1可表示正常的块,0表示坏块。
步骤504:文件系统在某个分区地址范围内,对SPI Nand flash进行访问时,通过MTD层获取坏块表的信息;
步骤505:在当前分区地址范围内,根据坏块表的信息来判断当前block是否是坏块,如果是,则执行步骤506;否则,执行步骤507;
步骤506:查找下一个block是否是坏块;
这里,如果查找超出了本分区范围,就退出(步骤508)。
步骤507:继续执行访问操作;
步骤508:向MTD层返回结果。
场景四
图6为本应用场景基于SPI Nand flash芯片的嵌入式文件系统的文件读取流程示意图,该流程如下:
步骤601:挂载文件系统到指定的分区上;
步骤602:在本分区进行文件的内容显示、拷贝等文件操作;
步骤603:文件系统通过MTD层接口调用到读数据接口函数,并且指明从SPI Nand读数据的地址范围以及将数据写入的buffer的地址;
步骤604:执行读命令,将SPI Nand闪存中的数据读取到内存中;
这里,可使用standard、或dual、或qual的SPI模式,这几种模式中qual模式的传输速度最高,但将写保护以及hold线用于数据传输。
步骤605:向MTD层返回结果。
场景五
图7为本应用场景基于SPI Nand flash芯片的嵌入式文件系统的文件更新流程示意图,该流程如下:
步骤701:挂载文件系统到指定的分区上;
步骤702:在本分区上进行文件的新建、内容更新等文件操作;
步骤703:文件系统通过MTD层接口调用到写数据接口函数,并且指 明从buffer地址中将数据写入SPI Nand闪存的指定地址内;
步骤704:执行写命令操作,将内存中的数据写入到SPI Nand闪存的指定地址中;
这里,可选择使用standard、或dual、或qual的SPI模式。
步骤705:向MTD层返回结果。
场景六
图8为本应用场景基于SPI Nand flash芯片的嵌入式文件系统文件删除流程示意图,该流程包括:
步骤801:挂载文件系统到指定的分区上;
步骤802:在本分区上进行文件的删除等文件操作;
步骤803:文件系统通过MTD层接口调用到擦除(erase)接口函数,并进行坏块标记的检测,若当前块为坏块,则无法进行擦除操作,跳出擦除操作;若是正常的块,则执行块擦除操作;
步骤804:向MTD层返回结果。
可见,本发明实施例基于SPI Nand flash芯片实现文件系统的操作,与现有技术相比,由于芯片管脚只占用四根线,为PCB的布局节省了空间,满足芯片尺寸小、接口少的要求;而且,由于SPI标准接口是一种高速的,全双工、同步的通信总线,保证数据读写速度,满足文件访问的速度要求;此外,基于SPI标准接口的特点,本发明软件系统级实现复杂度低,设计简单。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。
工业实用性
本发明实施例基于SPI Nand flash芯片实现文件系统的操作,由于SPI标准接口是一种高速的,全双工、同步的通信总线,保证数据读写速度,满足文件访问的速度要求;而且与现有技术相比,由于芯片管脚只占用四根线,为PCB的布局节省了空间,满足芯片尺寸小、接口少的要求;此外,基于SPI标准接口的特点,本发明软件系统级实现复杂度低,设计简单。

Claims (10)

  1. 一种基于新型存储器的嵌入式文件系统的实现方法,所述系统中设有串行外设接口与非闪存SPI Nand flash芯片;该方法包括:
    所述系统初始化后,确定所述系统支持所述SPI Nand flash芯片;
    设置文件处理时对应的内存技术设备MTD层接口;所述MTD层接口,用于访问所述SPI Nand flash芯片时被调用;
    识别所述SPI Nand flash芯片的坏块并进行标记、存储;所存储的坏块标记,用于文件系统访问SPI Nand flash芯片时,对已标记的坏块进行排查;
    依据预设条件对所述SPI Nand flash芯片进行分区处理;
    文件处理过程中,在指定的分区对所述SPI Nand flash芯片进行访问,完成对文件的访问操作。
  2. 根据权利要求1所述的方法,其中,所述确定所述系统支持所述SPI Nand flash芯片,包括:
    检测所述芯片的类型以及所述芯片的标识ID信息,如果所述芯片的类型以及所述ID信息与预先存储的芯片类型以及ID信息相同,则确定所述系统支持所述SPI Nand flash芯片;否则,确定所述系统不支持所述SPI Nand flash芯片。
  3. 根据权利要求1所述的方法,其中,所述文件处理为读取文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
    通过MTD层接口调用读数据接口函数,依据读取数据的地址范围以及数据写入缓冲器的地址执行读命令,将SPI Nand flash芯片中的数据读取到内存中;其中,所述数据读取过程中使用SPI对应的标准standard模式、或双线Dual模式、或四线Qual模式。
  4. 根据权利要求1所述的方法,其中,所述文件处理为更新文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
    通过MTD层接口调用写数据接口函数,依据指定的缓冲器的地址执行写命令,将内存中的数据写入SPI Nand flash芯片指定的地址中;其中,所述数据写过程中使用SPI对应的standard模式、或Dual模式、或Qual模式。
  5. 根据权利要求1所述的方法,其中,所述文件处理为删除文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
    进行坏块检测,如果确定当前块为坏块,则结束当前块的擦除操作;否则,通过MTD层接口调用擦除erase接口函数,完成对当前块的擦除操作,并将结果返回给MTD层。
  6. 一种基于新型存储器的嵌入式文件系统,该系统包括:串行外设接口与非闪存SPI Nand flash芯片、初始化设置模块、坏块管理模块、文件处理模块;其中,
    所述初始化设置模块,配置为所述系统初始化后,确定所述系统支持所述SPI Nand flash芯片;设置文件处理时对应的内存技术设备MTD层接口;所述MTD层接口,用于访问所述SPI Nand flash芯片时被调用;
    还配置为依据预设条件对所述SPI Nand flash芯片进行分区处理;
    所述坏块管理模块,配置为识别所述SPI Nand flash芯片的坏块并进行标记、存储;所存储的坏块标记,用于文件系统访问SPI Nand flash芯片时,对已标记的坏块进行排查;
    所述文件处理模块,配置为文件处理过程中,在指定的分区对所述SPI Nand flash芯片进行访问,完成对文件的访问操作。
  7. 根据权利要求6所述的系统,其中,所述初始化设置模块确定所述系统支持所述SPI Nand flash芯片,包括:
    检测所述芯片的类型以及所述芯片的标识ID信息,如果所述芯片的类型以及所述ID信息与预先存储的芯片类型以及ID信息相同,则确定所述系统支持所述SPI Nand flash芯片;否则,确定所述系统不支持所述SPI Nand  flash芯片。
  8. 根据权利要求6所述的系统,其中,所述文件处理模块读取文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
    通过MTD层接口调用读数据接口函数,依据读取数据的地址范围以及数据写入缓冲器的地址执行读命令,最终将SPI Nand flash芯片中的数据读取到内存中;其中,所述数据读取过程中使用SPI对应的标准standard模式、或双线Dual模式、或四线Qual模式。
  9. 根据权利要求6所述的系统,其中,所述文件处理模块更新文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
    通过MTD层接口调用写数据接口函数,依据指定的缓冲器的地址执行写命令,最终将内存中的数据写入SPI Nand flash芯片指定的地址中;其中,所述数据读写过程中使用SPI对应的standard模式、或Dual模式、或Qual模式。
  10. 根据权利要求6所述的系统,其中,所述文件处理模块删除文件时,所述在指定的分区对所述SPI Nand flash芯片进行访问,包括:
    进行坏块检测,如果确定当前块为坏块,则结束当前块的擦除操作;否则,通过MTD层接口调用擦除erase接口函数,完成对当前块的擦除操作,并将结果返回给MTD层。
PCT/CN2016/084288 2015-08-04 2016-06-01 基于新型存储器的嵌入式文件系统及其实现方法 WO2017020647A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510472743.3A CN106445398B (zh) 2015-08-04 2015-08-04 一种基于新型存储器的嵌入式文件系统及其实现方法
CN201510472743.3 2015-08-04

Publications (1)

Publication Number Publication Date
WO2017020647A1 true WO2017020647A1 (zh) 2017-02-09

Family

ID=57942366

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/084288 WO2017020647A1 (zh) 2015-08-04 2016-06-01 基于新型存储器的嵌入式文件系统及其实现方法

Country Status (2)

Country Link
CN (1) CN106445398B (zh)
WO (1) WO2017020647A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108334453A (zh) * 2018-02-28 2018-07-27 深圳创维数字技术有限公司 一种文件调试方法、装置、终端设备及存储介质
CN111198843A (zh) * 2019-12-19 2020-05-26 西安交通大学 一种基于应用处理器片上总线控制的文件系统写加速方法

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107729067B (zh) * 2017-09-11 2021-04-20 北京东土科技股份有限公司 一种flash芯片驱动的注册方法及装置
CN109725939A (zh) * 2017-10-27 2019-05-07 深圳市中兴微电子技术有限公司 一种芯片启动方法、芯片和计算机可读存储介质
CN108038065B (zh) * 2017-12-22 2021-11-12 湖南国科微电子股份有限公司 一种提高Block使用率的方法、装置及系统
CN113424160B (zh) * 2019-03-30 2024-01-30 华为技术有限公司 一种处理方法、装置及相关设备
CN111949198A (zh) * 2019-05-16 2020-11-17 北京兆易创新科技股份有限公司 一种坏块管理方法、装置和存储设备
CN113312273A (zh) * 2020-02-26 2021-08-27 北京君正集成电路股份有限公司 一种基于nand flash的序列号和mac地址储存方法
CN113742283B (zh) * 2021-07-20 2023-11-24 电信科学技术第五研究所有限公司 一种基于linux操作系统的nandflash无文件系统的坏块管理方法
CN114546292B (zh) * 2022-02-28 2023-12-15 深圳市风云实业有限公司 一种nand flash坏块管理方法及系统

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102289397A (zh) * 2011-09-13 2011-12-21 全星科技(珠海)有限公司 一种机顶盒的嵌入式系统自动恢复方法及装置
CN103678030A (zh) * 2012-09-04 2014-03-26 杭州海康威视数字技术股份有限公司 多系统设备启动系统及其方法

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20140142960A (ko) * 2013-06-05 2014-12-15 중소기업은행 병렬 파이프라인 더블래치로 구동되는 spi 낸드 플래시 메모리
CN103577574B (zh) * 2013-11-05 2017-02-08 中船重工(武汉)凌久电子有限责任公司 一种基于nand flash的高可靠线性文件系统
CN103617124B (zh) * 2013-11-26 2017-01-25 北京创毅视讯科技有限公司 一种闪存管理方法和装置
CN104461379A (zh) * 2014-10-31 2015-03-25 上海华为技术有限公司 提高nand闪存的稳定性的方法和nand闪存

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102289397A (zh) * 2011-09-13 2011-12-21 全星科技(珠海)有限公司 一种机顶盒的嵌入式系统自动恢复方法及装置
CN103678030A (zh) * 2012-09-04 2014-03-26 杭州海康威视数字技术股份有限公司 多系统设备启动系统及其方法

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108334453A (zh) * 2018-02-28 2018-07-27 深圳创维数字技术有限公司 一种文件调试方法、装置、终端设备及存储介质
CN108334453B (zh) * 2018-02-28 2021-07-20 深圳创维数字技术有限公司 一种文件调试方法、装置、终端设备及存储介质
CN111198843A (zh) * 2019-12-19 2020-05-26 西安交通大学 一种基于应用处理器片上总线控制的文件系统写加速方法
CN111198843B (zh) * 2019-12-19 2023-03-28 西安交通大学 一种基于应用处理器片上总线控制的文件系统写加速方法

Also Published As

Publication number Publication date
CN106445398A (zh) 2017-02-22
CN106445398B (zh) 2019-05-31

Similar Documents

Publication Publication Date Title
WO2017020647A1 (zh) 基于新型存储器的嵌入式文件系统及其实现方法
CN109426619B (zh) 访问快闪存储器模块的方法及相关闪存控制器与电子装置
US8195845B2 (en) Memory system having high data transfer efficiency and host controller
US10379745B2 (en) Simultaneous kernel mode and user mode access to a device using the NVMe interface
US20150161040A1 (en) Data-storage device and data erasing method
US20190146908A1 (en) Method for accessing flash memory module and associated flash memory controller and electronic device
US20170371749A1 (en) Backup image restore
US20100169546A1 (en) Flash memory access circuit
EP4220419A1 (en) Modifying nvme physical region page list pointers and data pointers to facilitate routing of pcie memory requests
WO2013088818A1 (ja) 仮想計算機システム、仮想化機構、及びデータ管理方法
US8914602B2 (en) Display controller having an embedded non-volatile memory divided into a program code block and a data block and method for updating parameters of the same
US20130159604A1 (en) Memory storage device and memory controller and data writing method thereof
US9934100B2 (en) Method of controlling memory swap operation and data processing system using same
CN114942863A (zh) 一种级联快照处理方法、装置、设备及存储介质
CN110673795A (zh) 数据写入方法及装置、计算机装置及存储介质
CN103617135B (zh) 一种存储设备中数据读取的方法及装置
JP2009123191A (ja) Norインターフェイスフラッシュメモリ装置及びそのアクセス方法
US9223697B2 (en) Computer reprogramming method, data storage medium and motor vehicle computer
US20120303879A1 (en) Memory Device and Method for Programming Flash Memory Utilizing Spare Blocks
CN111694580A (zh) 存储设备升级及初始化的方法、装置、电子设备
US9864548B2 (en) Memory module, electronic device and method
US20170090947A1 (en) Electronic apparatus and booting method thereof
US20070208929A1 (en) Device information managements systems and methods
JP7274069B2 (ja) トレース制御装置、エミュレータ、トレース制御方法、および、トレース制御プログラム
CN111858406B (zh) 一种使SPI主控兼容flash芯片的方法、装置、设备和介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16832135

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16832135

Country of ref document: EP

Kind code of ref document: A1