Set up the method for file system in the embedded system on the NAND Flash storer
Technical field
The present invention relates to the technical field of Flash storer, be specifically related to set up on the NAND Flash storer in the embedded system method of file system.
Background technology
Embedded system is used erasable non-volatile Flash memory stores code and data.File system has shielded the ins and outs of physical storage, institute's information of managing is organized into document form, thereby increased the portable and maintainable of program, be convenient to the user and effectively manage lot of data, had common and practical so set up file system on the Flash storer.On multi-purpose computer, have many ripe file system at present, as the FAT file system under the Dos, new technology file system under the Windows NT and Unix, Linux file system, but above-mentioned file system is not suitable for being directly used in embedded system, subject matter has: at first the applied environment of embedded system is abominable more than computing machine, and universal document system is considered not enough for Design in Reliability; Secondly universal document system is based on resourceful computer platform and disc driver at a slow speed, and often use expends the technology such as buffer memory of ample resources, this with embedded system in the situation of resource-constrained different fully; Thirdly be derived from the inherent characteristic of NAND Flash, NAND Flash storer is formed by some, and piece is formed by some pages, and page or leaf then comprises some bytes of memory unit and some redundancy bytes.The read operation of Flash storer is consistent with disk, but write operation is different with disk, and universal document system does not have corresponding specialized designs to this.The shared storage space base unit of Flash memory file is a piece, data write operation must or be wiped in the block of back and carry out at blank block, wiping requirement is that unit carries out (it is fast that OXFF is write storer to be wiped) with piece Block, write operation carries out (once must write a Page) by page or leaf Page mode, the erasing times of Flash storer is limited (100000 times), must consider the inherent characteristic of Flash storer when setting up file system on the Flash storer, avoid some piece over-erasure to cause the wear out failure of storage medium.
At present, the file system on the high capacity Flash storer has three kinds of JFFS2, YAFFS and TyueFFs, and these three kinds need take more resource based on log-structured file system.DOS FAT file system is with a long history, technology maturation, reliable in structure, system resource overhead are little, is easy to realize on the Flash storer of middle-size and small-size, low and middle-end embedded system.Characteristics at the embedded system working environment, inherent characteristic based on the Flash storer, the present invention improves accordingly to DOS FAT file system, the file system of NAND Flash storer in a kind of embedded system is proposed, except data management function is provided, pay attention to improving the reliability of file system, and prolong storage life by the abrasion equilibrium mechanism of FRT, FAT table memory block.
Summary of the invention
The purpose of this invention is to provide the method for setting up file system in a kind of embedded system on the NAND Flash storer.
It is the single level directory file system that adopts url page management by methods storage space, the list of document of single level directory file system, file allocation table are used the floating address method storage, list of document in the memory ram and file allocation table change, and real-time online writes Flash storer delta file registration form and delta file allocation table with incremental form; The relevant information of list of document and file allocation table writes in the redundancy bytes of the relevant Flash block page, as the backup of single level directory file system simultaneously in the single level directory file system.
Described single level directory file system is made up of floating address pointer gauge, list of document, delta file registration form, file allocation table, delta file allocation table and data field that system information and boot district, sensing FRT show; List of document, delta file registration form, file allocation table, delta file allocation table are with movably data mode storage, by the floating address pointer gauge addressing of system information and boot district and sensing list of document; When list of document, delta file registration form, file allocation table, the change of delta file allocation table memory address, new address is write the floating address pointer gauge that points to list of document, according to list of document, delta file registration form, file allocation table, delta file allocation table four table erasing times, move above-mentioned four tables to new Flash storage block, discharge the four former storage blocks of showing as DSB data store block, and no longer bear four table storage block functions.
Described single level directory file system copies to when moving the RAM from Flash, not only revise list of document and file allocation table in the memory ram, content be will revise simultaneously and delta file registration form and delta file allocation table in the Flash storer write with incremental form, recover list of document and file allocation table in the Flash storer with this increment information during fault, when list of document and file allocation table are upgraded, follow to write earlier and afterwards wipe principle.
Described single level directory file system is utilized the byte of each page redundancy of Flash storer, write reference number of a document, filename, generation or the last modification time of file system, a last block address of this document, the relevant information of next block address, as the redundancy backup of Flash memory file system list of document and file allocation table.
The present invention compares with background technology, and the beneficial effect that has is:
DOS FAT file system is with a long history, technology maturation, simple in structure, system resource overhead is little, improved DOS FAT file system migrates on the Flash storer, more existing JFFS2, YAFFS and TYUEFFS file system have tangible economic technology advantage, and its economic technology advantage is particularly evident in middle-size and small-size, low and middle-end embedded system.The FRT and the FAT of fixed storage address are modified into movably memory address, for the Flash storer has been set up a kind of abrasion equilibrium mechanism, solved traditional F RT and FAT fixed storage address, frequently erasable because of this memory block causes the difficult problem of the too early wear out failure of storer.In the delta file registration form Δ FRT and delta file allocation table Δ FAT of Flash storer, the FRT of real time record memory ram and FAT change, and the recovery mechanism of file system is provided; Utilize the byte of each page redundancy of Flash storer, write the relevant information of file system,, further improved the reliability of file system as the redundancy backup of Flash memory file registration form FRT and file allocation table FAT.
Description of drawings
Fig. 1 is a single level directory file system structure synoptic diagram of the present invention;
Fig. 2 is a list of document of the present invention, file allocation table mobile storage synoptic diagram (omitting delta file registration form, delta file allocation table among the figure);
Fig. 3 is a K9F6408UOM Flash memory construction synoptic diagram;
Fig. 4 is single level directory file system operation logic figure of the present invention.
Embodiment
As shown in Figure 1, the method of setting up file system in the embedded system on the NAND Flash storer is to adopt the single level directory file system of url page management by methods storage space, the list of document FRT 3 of single level directory file system, file allocation table FAT 5 use the floating address method storage, list of document FRT 3 in the memory ram and file allocation table FAT 5 change, and real-time online writes Flash storer delta file registration form Δ FRT 4 and delta file allocation table Δ FAT 6 with incremental form; The relevant information of list of document FRT 3 and file allocation table FAT 5 writes in the redundancy bytes of the relevant Flash block page, as the backup of single level directory file system simultaneously in the single level directory file system.
The single level directory file system is made up of system information and boot district, floating address pointer gauge PFRT, list of document FRT (1-N), delta file registration form Δ FRT (1-N), file allocation table FAT (1-N), delta file allocation table Δ FAT (1-N) and data field seven parts of pointing to FRT.System information and boot occupy Flash first block, important informations such as record storage type, capacity, structure (as comprise how many pieces, every comprise how many pages or leaves, every page memory capacity and redundancy capacity) version number; Boot is loaded into memory ram as required with FRT, FAT; Flash first block writes the first address of floating address pointer gauge PFRT, and floating address pointer gauge PFRT writes the first address of FRT and Δ FRT one by one.FRT deposits the storage chains of short title, filename, file size, file attribute and this document of each file at inlet of FAT etc.FAT deposits the storage organization with idle condition and each file of taking of all blocks on the Flash storer.The data field is used for store data.
As shown in Figure 2, described single level directory file system is made up of system information and boot district 1, floating address pointer gauge PFRT 2, list of document FRT 3, delta file registration form Δ FRT 4, file allocation table FAT 5, delta file allocation table Δ FAT 6 and the data field 7 of pointing to list of document FRT 3; List of document FRT 3, delta file registration form Δ FRT 4, file allocation table FAT 5, delta file allocation table Δ FAT 6 are with movably data mode storage, by floating address pointer gauge PFRT 2 addressing of system information and boot district 1 and sensing list of document FRT 3; When list of document FRT 3, delta file registration form Δ FRT 4, file allocation table FAT 5, the change of delta file allocation table Δ FAT 6 memory addresss, new address is write the floating address pointer gauge PFRT 2 that points to list of document FRT 3, according to list of document FRT 3, delta file registration form Δ FRT 4, file allocation table FAT 5, delta file allocation table Δ FAT 6 four table erasing times, move above-mentioned four tables to new Flash storage block, discharge the four former storage blocks of showing as DSB data store block, and no longer bear four table storage block functions.
In file system when operation, need the content of revised file registration form FRT (1-N) and file allocation table FAT (1-N) constantly, if FRT, FAT are fixed on the Flash storage block, this storage block certainly will too early wear out failure, and causes the collapse of file system.Therefore, when the erasing times of two table place storage blocks reach a certain threshold values, FRT and FAT are copied to free memory blocks, carry out data check simultaneously; After the verification succeeds, in the first location of the file pointer page or leaf that floating address pointer gauge PFRT reserves, write new FRT and Δ FRT first address.
As shown in Figure 3, K9F6408UOM is a NAND Flash memory chip that Samsung releases.Chip has 1024, and every is divided into 16 pages, and every page of 528 bytes, wherein 16 byte redundancies, so capacity are the byte of 1024*16* (512+16) byte=(8M+256K).In 16 bytes of each page redundancy of data area stores piece, write reference number of a document, filename, information such as the address of a piece, next block address on generation or last modification time, this document are as the redundancy backup of FRT and FAT.In case when the FRT of Flash storer and FAT broke down, scanning was dispersed in the FRT and the FAT redundant information recovery file system of data field.
As shown in Figure 4, described single level directory file system copies to when moving the RAM from Flash, not only revise list of document FRT 3 and file allocation table FAT 5 in the memory ram, content be will revise simultaneously and delta file registration form Δ FRT4 and delta file allocation table Δ FAT 6 in the Flash storer write with incremental form, recover list of document FRT 3 and file allocation table FAT 5 in the Flash storer with this increment information during fault, when list of document FRT 3 and file allocation table FAT 5 upgrade, follow to write earlier and afterwards wipe principle.Described single level directory file system is utilized the byte of each page redundancy of Flash storer, write reference number of a document, filename, generation or the last modification time of file system, a last block address of this document, the relevant information of next block address, as the redundancy backup of Flash memory file system list of document FRT 3 and file allocation table FAT 5.
Boot is loaded on file system the memory ram of embedded system.During operation for embedded system, FRT in the memory ram and FAT revise content and write Flash storer Δ FRT and Δ FAT blank page in real time.During unexpected the generation, according to the increment information recovery FRT and the FAT of Flash storer.During the system normal termination, FRT in the memory ram and FAT table are write FRT and the FAT table scratch block that file system keeps, after the verification succeeds, wipe the FRT and the FAT scratch list of file system, the FRT and the FAT of copy two table scratch block, and record FRT and FAT table memory block erasing times, wipe scratch block at last again; Again FRT and FAT information are write in the redundancy bytes of each page of data area stores piece at last.