1 #ifndef FFCONF_H 2 #define FFCONF_H 3 4 /*---------------------------------------------------------------------------/ 5 / Configurations of FatFs Module 6 /---------------------------------------------------------------------------*/ 7 8 #ifndef __LITEOS_M__ 9 #include "los_mux.h" 10 #include "los_config.h" 11 #else 12 #include "fs_config.h" 13 #include "vfs_config.h" 14 #endif 15 16 #ifdef __cplusplus 17 #if __cplusplus 18 extern "C" { 19 #endif /* __cplusplus */ 20 #endif /* __cplusplus */ 21 22 #define FFCONF_DEF 80286 /* Revision ID */ 23 24 /*---------------------------------------------------------------------------/ 25 / Function Configurations 26 /---------------------------------------------------------------------------*/ 27 28 #define FF_FS_READONLY 0 29 /* This option switches read-only configuration. (0:Read/Write or 1:Read-only) 30 / Read-only configuration removes writing API functions, f_write(), f_sync(), 31 / f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree() 32 / and optional writing functions as well. */ 33 34 35 #define FF_FS_MINIMIZE 0 36 /* This option defines minimization level to remove some basic API functions. 37 / 38 / 0: Basic functions are fully enabled. 39 / 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename() 40 / are removed. 41 / 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1. 42 / 3: f_lseek() function is removed in addition to 2. */ 43 44 45 #define FF_USE_FIND 0 46 /* This option switches filtered directory read functions, f_findfirst() and 47 / f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */ 48 49 50 #define FF_USE_MKFS 1 51 /* This option switches f_mkfs() function. (0:Disable or 1:Enable) */ 52 53 54 #define FF_USE_FASTSEEK 0 55 /* This option switches fast seek function. (0:Disable or 1:Enable) */ 56 57 #ifndef __LITEOS_M__ 58 #define FF_USE_EXPAND 1 59 #else 60 #define FF_USE_EXPAND 0 61 #endif 62 /* This option switches f_expand function. (0:Disable or 1:Enable) */ 63 64 65 #ifndef __LITEOS_M__ 66 #define FF_USE_CHMOD 1 67 #else 68 #define FF_USE_CHMOD 0 69 #endif 70 /* This option switches attribute manipulation functions, f_chmod() and f_utime(). 71 / (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */ 72 73 74 #ifndef __LITEOS_M__ 75 #define FF_USE_LABEL 1 76 #else 77 #define FF_USE_LABEL 0 78 #endif 79 /* This option switches volume label functions, f_getlabel() and f_setlabel(). 80 / (0:Disable or 1:Enable) */ 81 82 83 #define FF_USE_FORWARD 0 84 /* This option switches f_forward() function. (0:Disable or 1:Enable) */ 85 86 87 /*---------------------------------------------------------------------------/ 88 / Locale and Namespace Configurations 89 /---------------------------------------------------------------------------*/ 90 91 #ifdef LOSCFG_FS_FAT_CHINESE 92 #define FF_CODE_PAGE 936 93 #else 94 #define FF_CODE_PAGE 437 95 #endif 96 97 /* This option specifies the OEM code page to be used on the target system. 98 / Incorrect code page setting can cause a file open failure. 99 / 100 / 437 - U.S. 101 / 720 - Arabic 102 / 737 - Greek 103 / 771 - KBL 104 / 775 - Baltic 105 / 850 - Latin 1 106 / 852 - Latin 2 107 / 855 - Cyrillic 108 / 857 - Turkish 109 / 860 - Portuguese 110 / 861 - Icelandic 111 / 862 - Hebrew 112 / 863 - Canadian French 113 / 864 - Arabic 114 / 865 - Nordic 115 / 866 - Russian 116 / 869 - Greek 2 117 / 932 - Japanese (DBCS) 118 / 936 - Simplified Chinese (DBCS) 119 / 949 - Korean (DBCS) 120 / 950 - Traditional Chinese (DBCS) 121 / 0 - Include all code pages above and configured by f_setcp() 122 */ 123 124 #ifndef __LITEOS_M__ 125 #define MMC0_DEVNAME "mmcblk0" 126 #define MMC1_DEVNAME "mmcblk1" 127 #define USB_DEVNAME "sda" 128 #define MMC_LENGTH 7 /* mmcblk0 */ 129 enum STORAGE { 130 MMC0, 131 MMC1, 132 }; 133 #endif 134 135 #define FF_USE_LFN 2 136 #define FF_MAX_LFN 255 137 /* The FF_USE_LFN switches the support for LFN (long file name). 138 / 139 / 0: Disable LFN. FF_MAX_LFN has no effect. 140 / 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe. 141 / 2: Enable LFN with dynamic working buffer on the STACK. 142 / 3: Enable LFN with dynamic working buffer on the HEAP. 143 / 144 / To enable the LFN, ffunicode.c needs to be added to the project. The LFN function 145 / requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and 146 / additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled. 147 / The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can 148 / be in range of 12 to 255. It is recommended to be set it 255 to fully support LFN 149 / specification. 150 / When use stack for the working buffer, take care on stack overflow. When use heap 151 / memory for the working buffer, memory management functions, ff_memalloc() and 152 / ff_memfree() exemplified in ffsystem.c, need to be added to the project. */ 153 154 #ifndef __LITEOS_M__ 155 #define FF_LFN_UNICODE 0 156 #else 157 #define FF_LFN_UNICODE 2 158 #endif 159 /* This option switches the character encoding on the API when LFN is enabled. 160 / 161 / 0: ANSI/OEM in current CP (TCHAR = char) 162 / 1: Unicode in UTF-16 (TCHAR = WCHAR) 163 / 2: Unicode in UTF-8 (TCHAR = char) 164 / 3: Unicode in UTF-32 (TCHAR = DWORD) 165 / 166 / Also behavior of string I/O functions will be affected by this option. 167 / When LFN is not enabled, this option has no effect. */ 168 169 170 #define FF_LFN_BUF 255 171 #define FF_SFN_BUF 12 172 /* This set of options defines size of file name members in the FILINFO structure 173 / which is used to read out directory items. These values should be suffcient for 174 / the file names to read. The maximum possible length of the read file name depends 175 / on character encoding. When LFN is not enabled, these options have no effect. */ 176 177 178 #define FF_STRF_ENCODE 3 179 /* When FF_LFN_UNICODE >= 1 with LFN enabled, string I/O functions, f_gets(), 180 / f_putc(), f_puts and f_printf() convert the character encoding in it. 181 / This option selects assumption of character encoding ON THE FILE to be 182 / read/written via those functions. 183 / 184 / 0: ANSI/OEM in current CP 185 / 1: Unicode in UTF-16LE 186 / 2: Unicode in UTF-16BE 187 / 3: Unicode in UTF-8 188 */ 189 190 #ifndef __LITEOS_M__ 191 #define FF_FS_RPATH 0 192 #else 193 #define FF_FS_RPATH 1 194 #endif 195 /* This option configures support for relative path. 196 / 197 / 0: Disable relative path and remove related functions. 198 / 1: Enable relative path. f_chdir() and f_chdrive() are available. 199 / 2: f_getcwd() function is available in addition to 1. 200 */ 201 202 203 /*---------------------------------------------------------------------------/ 204 / Drive/Volume Configurations 205 /---------------------------------------------------------------------------*/ 206 207 #ifndef __LITEOS_M__ 208 #define FF_VOLUMES LOSCFG_FS_FAT_VOLUMES 209 #else 210 #define FF_VOLUMES 4 211 #endif 212 /* Number of volumes (logical drives) to be used. (1-10) */ 213 214 #ifdef LOSCFG_FS_FAT_VIRTUAL_PARTITION 215 #define _DEFAULT_VIRVOLUEMS 4 216 #define _MIN_CLST 0x4000 217 #define _FLOAT_ACC 0.00000001 218 #endif 219 220 #ifndef __LITEOS_M__ 221 #define FF_STR_VOLUME_ID 0 222 #define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3" 223 #else 224 #define FF_STR_VOLUME_ID 2 225 #endif 226 /* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings. 227 / When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive 228 / number in the path name. FF_VOLUME_STRS defines the volume ID strings for each 229 / logical drives. Number of items must not be less than FF_VOLUMES. Valid 230 / characters for the volume ID strings are A-Z, a-z and 0-9, however, they are 231 / compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is 232 / not defined, a user defined volume string table needs to be defined as: 233 / 234 / const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",... 235 */ 236 237 238 #define FF_MULTI_PARTITION 1 239 /* This option switches support for multiple volumes on the physical drive. 240 / By default (0), each logical drive number is bound to the same physical drive 241 / number and only an FAT volume found on the physical drive will be mounted. 242 / When this function is enabled (1), each logical drive number can be bound to 243 / arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk() 244 / funciton will be available. */ 245 246 247 #define FF_MIN_SS 512 248 #ifndef __LITEOS_M__ 249 #define FF_MAX_SS 4096 250 #else 251 #define FF_MAX_SS FS_MAX_SS 252 #endif 253 /* This set of options configures the range of sector size to be supported. (512, 254 / 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and 255 / harddisk. But a larger value may be required for on-board flash memory and some 256 / type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured 257 / for variable sector size mode and disk_ioctl() function needs to implement 258 / GET_SECTOR_SIZE command. */ 259 260 261 #ifndef __LITEOS_M__ 262 #define FF_USE_TRIM 0 263 #else 264 #define FF_USE_TRIM 1 265 #endif 266 /* This option switches support for ATA-TRIM. (0:Disable or 1:Enable) 267 / To enable Trim function, also CTRL_TRIM command should be implemented to the 268 / disk_ioctl() function. */ 269 270 271 272 /*---------------------------------------------------------------------------/ 273 / System Configurations 274 /---------------------------------------------------------------------------*/ 275 276 #define FF_FS_TINY 0 277 /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny) 278 / At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes. 279 / Instead of private sector buffer eliminated from the file object, common sector 280 / buffer in the filesystem object (FATFS) is used for the file data transfer. */ 281 282 283 #define FF_FS_NORTC 0 284 #define FF_NORTC_MON 1 285 #define FF_NORTC_MDAY 1 286 #define FF_NORTC_YEAR 2020 287 /* The option FF_FS_NORTC switches timestamp functiton. If the system does not have 288 / any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable 289 / the timestamp function. Every object modified by FatFs will have a fixed timestamp 290 / defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time. 291 / To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be 292 / added to the project to read current time form real-time clock. FF_NORTC_MON, 293 / FF_NORTC_MDAY and FF_NORTC_YEAR have no effect. 294 / These options have no effect in read-only configuration (FF_FS_READONLY = 1). */ 295 296 297 #define FF_FS_NOFSINFO 0 298 /* If you need to know correct free space on the FAT32 volume, set bit 0 of this 299 / option, and f_getfree() function at first time after volume mount will force 300 / a full FAT scan. Bit 1 controls the use of last allocated cluster number. 301 / 302 / bit0=0: Use free cluster count in the FSINFO if available. 303 / bit0=1: Do not trust free cluster count in the FSINFO. 304 / bit1=0: Use last allocated cluster number in the FSINFO if available. 305 / bit1=1: Do not trust last allocated cluster number in the FSINFO. 306 */ 307 308 #ifndef __LITEOS_M__ 309 #define FF_FS_LOCK CONFIG_NFILE_DESCRIPTORS 310 #else 311 #define FF_FS_LOCK (CONFIG_NFILE_DESCRIPTORS + LOSCFG_MAX_OPEN_DIRS - MIN_START_FD) 312 #endif 313 /* The option FF_FS_LOCK switches file lock function to control duplicated file open 314 / and illegal operation to open objects. This option must be 0 when FF_FS_READONLY 315 / is 1. 316 / 317 / 0: Disable file lock function. To avoid volume corruption, application program 318 / should avoid illegal open, remove and rename to the open objects. 319 / >0: Enable file lock function. The value defines how many files/sub-directories 320 / can be opened simultaneously under file lock control. Note that the file 321 / lock control is independent of re-entrancy. */ 322 323 324 #ifndef __LITEOS_M__ 325 #define FF_FS_REENTRANT 1 326 #define FF_FS_TIMEOUT LOS_WAIT_FOREVER 327 #define FF_SYNC_t LosMux 328 #else 329 #define FF_FS_REENTRANT 0 330 #define FF_FS_TIMEOUT 1000 331 #define FF_SYNC_t HANDLE 332 #endif 333 /* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs 334 / module itself. Note that regardless of this option, file access to different 335 / volume is always re-entrant and volume control functions, f_mount(), f_mkfs() 336 / and f_fdisk() function, are always not re-entrant. Only file/directory access 337 / to the same volume is under control of this function. 338 / 339 / 0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect. 340 / 1: Enable re-entrancy. Also user provided synchronization handlers, 341 / ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj() 342 / function, must be added to the project. Samples are available in 343 / option/syscall.c. 344 / 345 / The FF_FS_TIMEOUT defines timeout period in unit of time tick. 346 / The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*, 347 / SemaphoreHandle_t and etc. A header file for O/S definitions needs to be 348 / included somewhere in the scope of ff.h. */ 349 350 351 352 /*--- End of configuration options ---*/ 353 354 #ifdef __cplusplus 355 #if __cplusplus 356 } 357 #endif /* __cplusplus */ 358 #endif /* __cplusplus */ 359 360 #endif 361 362