FAT 文件系统

概述

WQSDK 使用 FatFs 开源库来实现对 FAT/exFAT 文件系统的支持,新增 adaptor 适配层动态注册磁盘 io,允许应用在运行时将 FatFs 映射到物理磁盘。

功能特性

  • 支持两种物理磁盘格式:片上 flash(仅 WQ7036AX 支持),片外 sd/mmc 卡(当前仅支持 spi 外接 sd/mmc 卡)。

  • 支持文件系统常用 API,详见 FatFs 官方文档(http://elm-chan.org/fsw/ff/00index_e.html)。

资源依赖

  • flash

  • spi,dma,sd_card 组件

配置选项

  • CONFIG_FATFS_LIB_ENABLE 使能 Fatfs 文件系统

  • CONFIG_FLASH_DISK 使能片上 flash 文件系统支持

  • CONFIG_MMC_DISK 使能片外 sd/mmc 卡文件系统支持

  • CONFIG_FATFS_CODE_PAGE 配置文件系统支持的编码格式,默认为 U.S

  • CONFIG_FATFS_VOLUMES 配置文件系统支持的卷数量,有效值(1-10)

  • CONFIG_FATFS_MIN_SS 配置文件系统的最小 sector size,有效值(512,1024,2048,4096)

  • CONFIG_FATFS_MAX_SS 配置文件系统的最大 sector size,有效值(512,1024,2048,4096)

  • CONFIG_FATFS_EXFAT 配置文件系统是否支持 exFAT 格式

  • CONFIG_FATFS_LOCK 配置文件系统可以同时操作的文件或文件夹数量

  • CONFIG_FATFS_TIMEOUT 配置文件系统互斥信号量的超时时间

  • CONFIG_FATFS_USE_LFN 使能文件系统长文件名支持

  • CONFIG_FATFS_MAX_LFN 配置文件系统长文件名的最大长度

用法流程--以 spi 外接 sd/mmc 卡为例

参考示例

examples/fatfs/flash, examples/fatfs/sd

API 介绍

Functions

WQ_RET diskio_install_flash_driver(BYTE *pdrv)

install flash diskio driver, afer call this api, application can operate filesystem on this flash disk, the allocated pdrv will use in the following filesystem operation api.

参数:

pdrv -- pointer to drive number to be set if successful

返回:

WR_RET_OK for success, others are fail

WQ_RET diskio_uninstall_flash_driver(void)

uninstall registered flash diskio driver.

返回:

WR_RET_OK for success, others are fail

Functions

WQ_RET diskio_install_mmc_driver(BYTE *pdrv, sd_card_io_interface_t *intf)

install sd/mmc diskio driver, afer call this api, application can operate filesystem on this sd/mmc disk, the allocated pdrv will use in the following filesystem operation api.

参数:
  • pdrv -- pointer to drive number to be set if successful

  • intf -- pointer to sd card io interface

返回:

WR_RET_OK for success, others are fail

WQ_RET diskio_uninstall_mmc_driver(void)

uninstall registered sd/mmc diskio driver.

返回:

WR_RET_OK for success, others are fail