问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

sd卡怎么修改文件目录和分配表 fatfs

发布网友 发布时间:2022-04-22 11:37

我来回答

1个回答

热心网友 时间:2022-05-12 22:59

SD的优势之一是它的便携性,它可以自由插拔,可以在嵌入式设备和PC机之间交换数据。如果使用FAT(File Allocation Table)文件系统,它便可以方便在安装windows的PC和嵌入式设备之间交换数据。一个完整的FAT文件系统代码量非常庞大,不适合资源较少的嵌入式系统,于是就需要一个微型的FAT文件系统,FatFs就是基于这样的目的而开发的。
FatFS是一个专为小型嵌入式系统设计的通用FAT文件系统模块。FatFs具有较高的可配置性,最小配置仅使用1K的RAM空间,非常适用于嵌入式系统。FatFs 的编写遵循ANSI C,并且完全与磁盘I/O层分开。因此,它独立(不依赖)于硬件架构。它可以被嵌入到低成本的微控制器中,如AVR, 8051, PIC, ARM, Z80, 68K 等等,而不需要做任何修改。
特点
Windows兼容的FAT文件系统
不依赖于平台,易于移植
代码和工作区占用空间非常小
多种配置选项:
多卷(物理驱动器和分区)
多ANSI/OEM代码页,包括DBCS
在ANSI/OEM或Unicode中长文件名的支持
RTOS的支持
多扇区大小的支持
只读,最少API,I/O缓冲区等等

FatFs的源代码只有几个文件:diskio.c,ff.c,ff_util.c,tff.c及头文件。diskio.c是磁盘操作的代码文件(这个文件是移植时要实现的),ff.c是一般FatFs的代码文件,tff.c是微型FatFs的代码文件,ff_util.c是几个辅助函数。integer.h是内部基本类型的定义,ff.h是一般FatFs包含的头文件,tff.h是微型FatFs包含的头文件。
[cpp] view plaincopy在CODE上查看代码片派生到我的代码片
#if _FATFS_TINY != 1
#include <fatfs/src/ff.h>
#else
#include <fatfs/src/tff.h>
#endif
#include <fatfs/src/ff_util.h>

微型FatFs配置最小时仅占用内存1KB,但它是一个只读的FAT系统。
FatFs的配置文件是fatfs_config.h:
[cpp] view plaincopy在CODE上查看代码片派生到我的代码片
//------------------------------------------------------------------------------
// General Definitions (previously in ff.h)
//------------------------------------------------------------------------------

#define _FATFS_TINY 0
/* When _FATFS_TINY is set to 1, fatfs is compiled in Tiny mode
/ Else, it is compiled in normal mode
/ Tiny FatFs feature : Very low memory consumption, suitable for small memory
/ system. (1KB RAM) : Supports only single drive, no disk format,
/ only read functions, no write functions */

//------------------------------------------------------------------------------
// Definitions for normal FATFS (previously in ff.h)
//------------------------------------------------------------------------------

#if _FATFS_TINY == 0

#define _MCU_ENDIAN 2
/* The _MCU_ENDIAN defines which access method is used to the FAT structure.
/ 1: Enable word access.
/ 2: Disable word access and use byte-by-byte access instead.
/ When the architectural byte order of the MCU is big-endian and/or address
/ miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set to 2.
/ If it is not the case, it can also be set to 1 for good code efficiency. */

#define _FS_READONLY 0
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
/ f_truncate and useless f_getfree. */

#define _FS_MINIMIZE 0
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
/ 0: Full function.
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename are removed.
/ 2: f_opendir and f_readdir are removed in addition to level 1.
/ 3: f_lseek is removed in addition to level 2. */

#define _USE_STRFUNC 0
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */

#define _USE_FSINFO 1
/* To enable FSInfo support on FAT32 volume, set _USE_FSINFO to 1. */

#define _USE_SJIS 1
/* When _USE_SJIS is set to 1, Shift-JIS code transparency is enabled, otherwise
/ only US-ASCII(7bit) code can be accepted as file/directory name. */

#define _USE_NTFLAG 1
/* When _USE_NTFLAG is set to 1, upper/lower case of the file name is preserved.
/ Note that the files are always accessed in case insensitive. */

#define _USE_MKFS 1
/* When _USE_MKFS is set to 1 and _FS_READONLY is set to 0, f_mkfs function is
/ enabled. */

#define _DRIVES 2
/* Number of logical drives to be used. This affects the size of internal table. */

#define _MULTI_PARTITION 0
/* When _MULTI_PARTITION is set to 0, each logical drive is bound to same
/ physical drive number and can mount only 1st primaly partition. When it is
/ set to 1, each logical drive can mount a partition listed in Drives[]. */

//------------------------------------------------------------------------------
// Definitions for normal FATFS TINY (previously in tff.h)
//------------------------------------------------------------------------------

#else

#define _MCU_ENDIAN 2
/* The _MCU_ENDIAN defines which access method is used to the FAT structure.
/ 1: Enable word access.
/ 2: Disable word access and use byte-by-byte access instead.
/ When the architectural byte order of the MCU is big-endian and/or address
/ miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set to 2.
/ If it is not the case, it can also be set to 1 for good code efficiency. */

#define _FS_READONLY 1
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
/ f_truncate, f_getfree and internal writing codes. */

#define _FS_MINIMIZE 0
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
/ 0: Full function.
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename are removed.
/ 2: f_opendir and f_readdir are removed in addition to level 1.
/ 3: f_lseek is removed in addition to level 2. */

#define _USE_STRFUNC 0
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */

#define _USE_FSINFO 1
/* To enable FSInfo support on FAT32 volume, set _USE_FSINFO to 1. */

#define _USE_SJIS 1
/* When _USE_SJIS is set to 1, Shift-JIS code transparency is enabled, otherwise
/ only US-ASCII(7bit) code can be accepted as file/directory name. */

#define _USE_NTFLAG 1
/* When _USE_NTFLAG is set to 1, upper/lower case of the file name is preserved.
/ Note that the files are always accessed in case insensitive. */

#define _USE_FORWARD 0
/* To enable f_forward function, set _USE_FORWARD to 1. */

#define _FAT32 1
/* To enable FAT32 support in addition of FAT12/16, set _FAT32 to 1. */

#endif

//------------------------------------------------------------------------------
// Other definitions
//------------------------------------------------------------------------------

/*-----------------------------------------------------------------------*/
/* Correspondence between drive number and physical drive */
/* Note that Tiny-FatFs supports only single drive and always */
/* accesses drive number 0. */

#define DRV_MMC 0
#define DRV_SDRAM 1
#define DRV_ATA 2
#define DRV_USB 3

#define SECTOR_SIZE_SDRAM 512
#define SECTOR_SIZE_SDCARD 512
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
为什么来大姨妈胸会胀 少儿学什么舞蹈 青年学什么舞蹈好 成年人学什么舞蹈 福州企业最低工资标准 2013年厦门的底薪是多少 生产要素的需求有哪些性质 生产要素的需求有何特点? 什么是生产要素需求 微观经济学要素需求什么是条件要素需求?它和要素需求有什么不同?_百度... 核桃能和莲子百合栗子红枣花生能一起熬粥吃吗? 莲子,核桃,枸杞能一起煮吗 核桃可以和莲子花生红枣一起煮吗 linux里的mkfs命令后面跟.vfat是什么意思? 核桃和莲子熬粥的好处? 求高手指点:在arm7上跑了个fatfs系统 ,格式化TF卡的时候,8G卡,格成了3个多G?? f_mkfs(0, 0, 4096) 核桃桂圆莲子能一起吃吗 红枣,莲子,核桃一起煮可以吃吗 核桃跟莲子可以煮粥吗 核桃 莲子可以一起吃吗 核桃和莲子可以一起吃吗 核桃,莲子相克吗 为什么电脑里有些东西不能剪切或者复制到U盘里? U盘内文件无法删除怎么办? 电脑不能删除和剪切U盘的东西了,只能复制! 不能删除u盘上的文件,因为没有删除的选项 为何我的电脑无法从U盘上复制或剪切文件? u盘中的文件无法删除该怎么办? 你的脸型到底适合佩戴什么首饰 你的脸型适合什么样的鼻型 莲子可以和核桃一起煮粥吗能不能吃 STM32的FATFS文件系统出现“无法建立文件 res返回值不为0”是怎么回事? 莲子核桃红枣一起煮吃了会胖吗? mkfs.ext2和mke2fs命令有什么区别 新鲜的莲子核桃还有枸杞可以一起煮吗 莲子红罗卜核桃能一起吃吗 STM32的FATFS文件系统出现“无法建立文件 res返回值不为0”是怎么回事? 莲子核桃桂圆一起熬汤会有什么作用 如何交叉编译mkfs.jffs2等工具链mtd-utils 核桃枸杞莲子桂圆 能放一起煲粥吃吗? 在Linux操作系统中磁盘是如何命名的 核桃仁与莲子心可以共食吗? 我想单独格式化F盘 linux用户家目录在哪linux用户家目录 在Aras Innovator系统中是如何实现排序的 在Ubuntu上如何使用mkfs命令将新建硬盘分区格式化成xfs文件系统 linux下mkfs.ext3不能格式化硬盘 vmware9.0中怎样让部分USB设备连接到虚拟机? VM虚拟机应该如何来设置才能连接USB? VMware虚拟机如何连接USB加密狗?