[转载]嵌入式文件系统uc/fs在Nios II上基于Nor Flash的移植

本文详细介绍了如何在Nios II处理器上移植uc/fs文件系统,针对Nor Flash存储介质进行适配,涵盖了从初始化、IO操作到API调用的全过程,为嵌入式系统开发者提供了实用的参考。
摘要由CSDN通过智能技术生成
写在前面:经过一个多星期的努力,今天终于把uc/fs在de2板上跑通了,现在能够对flash进行格式化,能够建立,读写,删除文件,能够建立目录,等等文件系统应该具备的基本功能都可以实现了,算是一个不小的进步。在这里先要感谢网友棉花糖糖主提供的uc/fs 1.34在lpc2210上的移植例子,里面的flash驱动给了我很大帮助(实际上,我只是在这个驱动的基础上做了一些修改,使之支持de2板上的flash罢了。呵呵,拿来主义,是我一向的主张!^_^)。下面简要说一下我的移植过程,以备查阅。
一、 uc/fs 简单介绍
uc/fs 是美国 micrium 公司研发的一个专门针对嵌入式应用的文件系统,支持 FAT12 FAT16 FAT32 ,可以用于大部分常见的存储器件,比如 RamDisk SMC/NAND Device MultiMedia & SD card Device CompactFlash card & IDE Device Nor Flash Device SerialFlash Device 等等。当然,要使用这些存储器件,就需要相应的驱动程序。我们的工作,实际上就是修改,并完善相应的驱动程序,使之适用于我们自己的系统。
现在网上的可以下载的源码是 2.0 版本的,不过好像大家用的比较多的是 1.34 版,而且我得到的例子也是 1.34 版的,所以就在此基础上进行我的工作。
二、 uc/fs 设备驱动结构
uc/fs 以一种宏定义的形式来管理设备,这些定义在 API 文件夹下的 fs_info.c 文件中可以找到,比如 flash 设备的定义如下:

#if FS_USE_FLASH_DRIVER
#define FS_DEVINFO_DEVFLASH  { "flash" ,   &FS__fat_functable, &FS__flashdevice_driver, FS_CACHEINFO_FLASH_DRIVER 0 },
#else
#define FS_DEVINFO_DEVFLASH

</

µC/FS µC/FS is a compact, reliable, high-performance file system. It offers full-featured file and directory access with flexible device and volume management including support for partitions. Source Code: µC/FS is provided in ANSI-C source to licensees. The source code is written to an exacting coding standard that emphasizes cleanness and readability. Moreover, extensive comments pepper the code to elucidate its logic and describe global variables and functions. Where appropriate, the code directly references standards and supporting documents. Device Drivers: Device drivers are available for most common media including SD/MMC cards, NAND flash, NOR flash. Each of these is written with a clear, layered structure so that it can easily be ported to your hardware. The device driver structure is simple—basically just initialization, read and write functions—so that µC/FS can easily be ported to a new medium. Devices and Volumes: Multiple media can be accessed simultaneously, including multiple instances of the same type of medium (since all drivers are re-entrant). DOS partitions are supported, so more than one volume can be located on a device. In addition, the logical device driver allows a single volume to span several (typically identical) devices, such as a bank of flash chips. FAT: All standard FAT variants and features are supported including FAT12/FAT16/FAT32 and long file names, which encompasses Unicode file names. Files can be up to 4-GB and volumes up to 8-TB (the standard maximum). An optional journaling module provides total power fail-safety to the FAT system driver. Application Programming Interface (API): µC/FS provides two APIs for file and directory access. A proprietary API with parallel argument placement and meaningful return error codes is provided, with functions like FSFile_Wr(), FSFile_Rd() and FSFile_PosSet(). Alternatively, a standard POSIX-like API is provided, including functions like fs_fwrite(), fs_fread() and fs_fsetpos
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值