CN115525605A - Transmission system and method of file system - Google Patents

Transmission system and method of file system Download PDF

Info

Publication number
CN115525605A
CN115525605A CN202210959655.6A CN202210959655A CN115525605A CN 115525605 A CN115525605 A CN 115525605A CN 202210959655 A CN202210959655 A CN 202210959655A CN 115525605 A CN115525605 A CN 115525605A
Authority
CN
China
Prior art keywords
block
index
physical
log
page
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.)
Pending
Application number
CN202210959655.6A
Other languages
Chinese (zh)
Inventor
李勃燃
黄天翔
熊谱翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Rt Thread Electronic Technology Co ltd
Original Assignee
Shanghai Rt Thread Electronic Technology Co ltd
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 Shanghai Rt Thread Electronic Technology Co ltd filed Critical Shanghai Rt Thread Electronic Technology Co ltd
Priority to CN202210959655.6A priority Critical patent/CN115525605A/en
Publication of CN115525605A publication Critical patent/CN115525605A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems

Abstract

The invention provides a transmission system of a file system, which comprises: the transmission layer comprises a plurality of physical blocks, and the physical blocks correspond to unique serial number indexes; the file system storage partition is divided into a plurality of physical blocks by the transmission layer, and each physical block is independent; the NOR Flash chip is an erasable nonvolatile Flash memory, so that the problem of pain in service life reduction of the whole NOR Flash caused by frequent operation of a certain sector is solved, the service life of the NOR Flash can be effectively prolonged, and meanwhile, only some interfaces of a file system without a balanced erasing function need to be butted to a transmission layer, so that the time for re-transplanting the file system with the balanced erasing function can be greatly saved.

Description

Transmission system and method of file system
Technical Field
The invention relates to a read-write system of a file system in the field of embedded equipment, in particular to a transmission system and a transmission method of the file system.
Background
With the continuous development of semiconductor technology, NOR Flash has been widely applied to embedded devices. The application code can be directly executed In a NOR Flash chip (XIP, eXecute In Place), the code does not need to be read into a RAM for execution, and the capacity of the SRAM can be reduced, so that the cost is saved.
The write operation of any Flash device can only be performed in an empty or erased unit, so in most cases, the write unit must be erased once before the write operation is performed, however, the erase times of each unit of NOR Flash are limited, generally 10-100 ten thousand times, and NOR Flash charges a floating gate in a hot electron injection mode, so after NOR Flash is erased, corresponding bits are all 1, the minimum erase size of NOR Flash is 4KB in one sector, and the larger the erase area is, the longer the time is consumed.
The erase frequency of each sector of the NOR Flash has an upper limit, and the NOR Flash does not have a balanced erase scheme, so that the service life of the whole NOR Flash is reduced due to frequent operation of a certain sector.
At present, operating systems applied to NOR Flash mainly comprise JFFS, elm-Fatfs and Littefs, wherein the JFFS belongs to a log type file system and has a balanced erasing function, but the starting initialization time is long, and the memory consumption is large; the time consumed by the Littlefs for modifying the file in the large file scene is long, the efficiency is not high, and both the JFFS and the Littlefs are not general file systems, so that the compatibility is poor; the elm-Fatfs is a general file system, but does not have the balanced erasing function and the power failure safety protection, so the elm-Fatfs is not suitable for some embedded devices which need high-reliability storage schemes.
Disclosure of Invention
In order to solve the technical problem, the invention provides a transmission system of a file system.
The invention is realized by the following technical scheme.
The invention provides a transmission system of a file system, which comprises:
the transmission layer comprises a plurality of physical blocks, and the physical blocks correspond to the unique serial number indexes; the file system storage partition is divided into a plurality of physical blocks by the transmission layer, and each physical block is independent; the NOR Flash chip is an erasable nonvolatile Flash memory;
further, the transmission layer connects the file system and the NOR Flash chip.
Furthermore, the plurality of physical blocks can be divided into management blocks, log blocks, data blocks and mapping blocks according to different functions, the different function blocks are independent from each other, and the physical blocks can serve as different function blocks according to transmission layer instructions.
A method of transferring a file system, comprising the steps of:
writing data, wherein a file system generates a position index (POS) during writing and transmits the position index (POS) to a transmission layer, and the transmission layer calculates a logic block index and a logic page index by taking the position index (POS) as a logic address;
data recording, wherein a transmission layer searches a corresponding log block according to the logical block index value, if no corresponding log block exists, an available physical block with the least erasing times is distributed as the log block, and the log block stores the logical block index and the physical block index of the log block;
recording a mapping relation, wherein the log block records the mapping relation between a logical page index and a physical page index and the mapping relation between a logical fast index and a physical block index respectively;
calculating offset, calculating an actual Flash offset address according to the physical block index and the physical page index, and writing the offset address data into Flash.
Further, the data recording comprises the following steps:
the transmission layer searches for a corresponding log block according to the logical block index value, and if no corresponding log block exists, the transmission layer traverses all log blocks and searches whether an idle log block exists;
if there is a corresponding log block, it is checked whether there is a free page in the log block.
Further, traversing all log blocks, and searching whether there is a free log block includes the following steps:
if no idle log block exists, merging the log blocks;
and if the free log blocks exist, searching the log block with the minimum erasing times from the physical block, and distributing the log blocks after distribution.
Further, checking whether there is a free page in the log block comprises the following steps:
if the log block has a free page, allocating an unused page from the free page as a physical page index;
the log block is merged if there are no free pages in the log block.
Further, the log block allocation comprises the following steps:
finding a corresponding page in the logic block according to the logic page index, and calculating the offset if the corresponding page is available; and if the corresponding page is not available, performing log block merging.
Further, the method for calculating the logical block index and the logical page index by the transport layer by using the position index (POS) as the logical index is as follows:
logical address/number of pages per block = logical block index;
logical address% pages per block = logical page index;
further, the method for calculating the actual Flash offset address according to the physical block index and the physical page index comprises the following steps:
flah real offset address = (physical fast index x number of pages per block + physical page index) × size per page.
The invention has the beneficial effects that: the method solves the pain point that the service life of the whole NOR Flash is reduced due to frequent operation of a certain sector, can effectively prolong the service life of the NOR Flash, and can greatly save the time for re-transplanting the file system with the balanced erasing function only by butting some interfaces of the file system without the balanced erasing function to a transmission layer.
Drawings
FIG. 1 is a diagram of the method steps of the present invention;
FIG. 2 is a system relationship diagram according to an embodiment of the present invention;
fig. 3 is a schematic diagram of the interior of the file system according to the embodiment of the present invention.
Detailed Description
The technical solution of the present invention is further described below, but the scope of the claimed invention is not limited to the described.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
The embodiment is as follows:
in this embodiment, the physical block size (4K as the minimum unit) set by the user divides the entire file system 100 into n physical blocks, the 0 th block, the 1 st block, and the nth block, and each physical block has a unique index, each physical block may actually include a plurality of sectors, each sector is a page, page 1, page 2 \8230, and page n, so how many physical blocks are calculated in the entire file system 100:
Figure BDA0003792401670000051
the sector size in the above formula is 4k,
when the file system 100 has write operation, the most direct contact is the log block, and the log block stores the mapping relation between the logical block and the physical block and the mapping table between the logical page and the physical page;
when the file system 100 performs a write operation, an address index, called a logical address index, is generated, and the transport layer converts the logical address index into a logical block index and a logical page index according to the following formulas:
logical address/number of pages per block = logical block index;
logical address% pages per block = logical page index;
calculating a logical block index and a logical page index according to the formula, searching whether a log block has a corresponding log block according to the logical block index, if no corresponding log block exists, allocating an available physical block with the minimum erasing times as the log block for storing the mapping relation between the logical block index and the physical block index and the mapping relation between the logical page index and the physical page index, wherein the mapping relation between the logical block and the physical block can be the following scheme, and calculating the logical block index to be 1, and calculating the available physical block index with the minimum erasing times to be 5 at the moment, wherein the mapping relation between the logical block index and the physical block index is that the logical block 1 is mapped to the physical block 5;
similarly, the mapping relationship between the logical page index and the physical page index may be as follows: the logical page index is represented by a number, the physical page index is represented by an letter, and the index values of the two indexes are unequal roughly, for example, if page 1 is represented by 0 x, page 2 is represented by 1 y \8230, page n is represented by n: z, the logical page index is 5, and the physical page index is 3, the mapping relationship is that the logical page 5 is mapped to the physical page 3.
After a log block exists or a log block with the minimum erasing times is distributed, detecting whether pages in the log block are completely used up or not, if the pages in the log block are completely used up and no idle page exists, combining the log blocks, and transferring information in the log block to a data block; if the log block has free pages, a free page is allocated from the log block, the Flash actual offset address is calculated according to a formula, data is written into a NOR Flash chip, the writing is finished, and the balanced erasing process is finished.
In this embodiment, the NOR Flash is characterized by an on-chip execution (XIP eXecute In Place), a program can be directly run In the NOR Flash without reading a code into a RAM, the NOR Flash has high transmission efficiency, and has high cost efficiency at a small capacity of 1 to 4MB, but the performance of the NOR Flash is greatly affected by low writing and erasing speeds. NOR Flash minimum erase size is one sector size of 4KB, the larger the erase area, the longer it takes. NOR Flash charges the floating gate by hot electron injection, so that the data in the area where NOR Flash is cleared is all 1. The NOR Flash must perform an erase operation before writing data, however, the NOR Flash has a limit of erase times per unit, generally 10-100 ten thousand times, and if the number of times exceeds the upper limit, a bad block is generated, resulting in inconsistency between data storage and data writing.

Claims (9)

1. A transmission system of a file system, comprising:
the transmission layer comprises a plurality of physical blocks, and the physical blocks correspond to unique serial number indexes;
the file system storage partition is divided into a plurality of physical blocks by the transmission layer, and each physical block is mutually independent;
the NOR Flash chip is an erasable nonvolatile Flash memory;
the transmission layer is connected with the file system and the NOR Flash chip.
2. A transmission system of a file system as claimed in claim 1, characterized in that: the physical blocks can be divided into management blocks, log blocks, data blocks and mapping blocks according to different functions, the different functional blocks are independent from each other, and the physical blocks can serve as different functional blocks according to transmission layer instructions.
3. A transmission method of a file system is characterized by comprising the following steps:
writing data, wherein a file system generates a position index (POS) during writing and transmits the position index (POS) to a transmission layer, and the transmission layer calculates a logical block index and a logical page index by taking the position index (POS) as a logical address;
data recording, wherein a transmission layer searches for a corresponding log block according to the logical block index value, if no corresponding log block exists, an available physical block with the least erasing times is distributed as the log block, and the log block stores the logical block index and the physical block index of the log block;
recording a mapping relation, wherein the log block records the mapping relation between a logical page index and a physical page index and the mapping relation between a logical fast index and a physical block index respectively;
calculating offset, calculating an actual Flash offset address according to the physical block index and the physical page index, and writing the offset address data into Flash.
4. A transmission method of a file system according to claim 3, characterized in that said data record comprises the steps of:
the transmission layer searches for a corresponding log block according to the logical block index value, and if no corresponding log block exists, the transmission layer traverses all log blocks and searches whether an idle log block exists;
if there is a corresponding log block, it is checked whether there is a free page in the log block.
5. The file system transmission method as claimed in claim 4, wherein said step of traversing all log blocks and finding whether there is a free log block comprises the steps of:
if no idle log block exists, merging the log blocks;
and if the free log blocks exist, searching the log block with the least erasing times from the physical block, and distributing the log block after distribution.
6. The transmission method of a file system according to claim 4, wherein said checking whether there is a free page in the log block comprises the steps of:
if the log block has a free page, allocating an unused page from the free page as a physical page index;
the log block is merged if there are no free pages in the log block.
7. A transmission method of a file system according to claim 3, wherein said log block allocation comprises the steps of:
finding a corresponding page in the logic block according to the logic page index, and calculating the offset if the corresponding page is available; and if the corresponding page is not available, performing log block merging.
8. A method for transferring a file system according to claim 3, characterized in that: the calculation method of the transmission layer for calculating the logical block index and the logical page index by taking the position index (POS) as the logical address is as follows:
logical address/number of pages per block = logical block index;
logical address% number of pages per block = logical page index.
9. A transmission method of a file system according to claim 6, characterized in that: the method for calculating the actual Flash offset address according to the physical block index and the physical page index comprises the following steps:
flash actual offset address = (physical fast index x number of pages per block + physical page index) × size per page.
CN202210959655.6A 2022-08-11 2022-08-11 Transmission system and method of file system Pending CN115525605A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210959655.6A CN115525605A (en) 2022-08-11 2022-08-11 Transmission system and method of file system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210959655.6A CN115525605A (en) 2022-08-11 2022-08-11 Transmission system and method of file system

Publications (1)

Publication Number Publication Date
CN115525605A true CN115525605A (en) 2022-12-27

Family

ID=84696583

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210959655.6A Pending CN115525605A (en) 2022-08-11 2022-08-11 Transmission system and method of file system

Country Status (1)

Country Link
CN (1) CN115525605A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117271440A (en) * 2023-11-21 2023-12-22 深圳市云希谷科技有限公司 File information storage method, reading method and related equipment based on freeRTOS

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117271440A (en) * 2023-11-21 2023-12-22 深圳市云希谷科技有限公司 File information storage method, reading method and related equipment based on freeRTOS
CN117271440B (en) * 2023-11-21 2024-02-06 深圳市云希谷科技有限公司 File information storage method, reading method and related equipment based on freeRTOS

Similar Documents

Publication Publication Date Title
US10564690B2 (en) Power interrupt management
CN102292711B (en) Solid state memory formatting
EP2646919B1 (en) Transaction log recovery
US8332576B2 (en) Data reading method for flash memory and controller and storage system using the same
US8683173B2 (en) Logical address offset in response to detecting a memory formatting operation
CN102549554B (en) Stripe-based memory operation
US20200151110A1 (en) Memory addressing
CN102841851B (en) Flash memory management method and flash memory device
US8214578B2 (en) Method of storing data into flash memory according to usage patterns of addresses and data storage system using the same
WO2014074449A2 (en) Wear leveling in flash memory devices with trim commands
CN102193869B (en) Memory management and write-in method, memory controller and storage system
CN107423231B (en) Method for managing a memory device, memory device and controller
US8037236B2 (en) Flash memory writing method and storage system and controller using the same
CN102890655A (en) Memory storage device, memory controller and valid data recognition method thereof
CN102880432B (en) Method and system for increasing writing speeds of flash memory chips by aid of limited lives of data and controller of system
CN115525605A (en) Transmission system and method of file system
CN102543184B (en) Memorizer memory devices, its Memory Controller and method for writing data
CN102841853B (en) Memory management table disposal route, Memory Controller and memorizer memory devices
KR100780963B1 (en) Memory card and driving method thereof
CN113138720A (en) Data storage method, memory control circuit unit and memory storage device
CN102456401B (en) Block management method, memory controller and memory storage device
CN114968067A (en) Data sorting method using persistent memory and memory storage system
CN117632018A (en) Mixed storage system of persistent memory and flash memory and data writing method
CN110609817A (en) File storage system capable of preventing file fragmentation

Legal Events

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