新闻  |   论坛  |   博客  |   在线研讨会
STM32 SD卡FATFS移植
0750long | 2010-02-11 23:17:06    阅读:6375   发布文章

 

最近试玩了STM32用SPI方式操作SD卡,这样就涉及到文件系统,搜索到几种支持FAT16/32的文件,综合考虑,最后选择了完全开源、免费的FATFS,版本是R0.07e,该版本支持长文件名:

  • Windows compatible FAT12/16/32 file system.
  • Platform independent. Easy to port.
  • Very small footprint for code and work area.
  • Various configuration options:
    • Multiple volumes (physical drives and partitions).
    • Multiple OEM code pages including DBCS.
    • Long file name (LFN) support in OEM code or Unicode.
    • RTOS support.
    • Multiple sector size support.
    • Read-only, minimized API, I/O buffer and etc...

官网地址:http://elm-chan.org
下载地址:http://elm-chan.org/fsw/ff/ff007e.zip
本地下载:FATFS R007e

(786.01 K) 该附件被下载次数 99


感受就是FATFS十分容易移植,同时对资源不是要求很高,网上对FATFS的移植也比较多。
要点是:
1:SD底层驱动
2:Disk I/O Interface
Since the FatFs module is completely separated from disk I/O layer, it requires following functions to lower layer to read/write the physical disk and to get current time. The low level disk I/O module is not a part of FatFs module so that it must be provided by user. The sample drivers are also available in the resources.
  • disk_initialize - Initialize disk drive
  • disk_status - Get disk status
  • disk_read - Read sector(s)
  • disk_write - Write sector(s)
  • disk_ioctl - Control device dependent features
  • get_fattime - Get current time
以下是512M SD1.0卡和4G SDHC卡的测试结果:
**************************************************
Card Type                     : SD V1
File System Sub Type          : FAT16
Total space (Bytes)           : 511574016
Available space (Bytes)       : 511369216
Physical drive number         : 0
Maximum cluster               : 62450
Number of free clusters       : 62423
Last allocated cluster        : 0
Maximum sector size           : 512
Number of sectors per cluster : 16
Number of FAT copies          : 2
Sectors per fat               : 244
File system info sector       : 0
Root directory start sector   : 729
FAT start sector              : 241
Data start sector             : 761
**************************************************
Write File Successed: 0:CardInfo.txt, 64:64
Write File Successed: 0:ffext2.ini, 13312:13312
Read File Successed: 0:ffext2.ini, 13312:13312
Write File Successed: 0:ffext1.txt, 13312:13312

**************************************************
Card Type                     : SD V2HC
File System Sub Type          : FAT32
Total space (Bytes)           : 3949592576
Available space (Bytes)       : 3949588480
Physical drive number         : 0
Maximum cluster               : 964258
Number of free clusters       : 964255
Last allocated cluster        : 3
Maximum sector size           : 512
Number of sectors per cluster : 8
Number of FAT copies          : 2
Sectors per fat               : 7534
File system info sector       : 1
Root directory start sector   : 2
FAT start sector              : 36
Data start sector             : 15104
**************************************************
Write File Successed: 0:CardInfo.txt, 64:64
Write File Successed: 0:ffext2.ini, 13312:13312
Read File Successed: 0:ffext2.ini, 13312:13312
Write File Successed: 0:ffext1.txt, 13312:13312

以下是移植文件:

(601.38 K) 该附件被下载次数 126

*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
推荐文章
最近访客