fatFSDemo
This example (fatFSDemo directory) demonstrates the implementation of the FatFS File System with a Command Line Interface (CLI) for interaction. The disk IO layer is ported to the SD Host Controller.
Upon execution, the example initializes the SD Host Controller and the FAT File System automatically. Additionally, the FatFSDemo is integrated with the Real-Time Clock (RTC) available on board. You can configure the RTC using the rtcDemo provided within the BSP.
***FatFs File System Demo***
Initialize...
Filesystem found in SD card ..
[Buffer controls]
bd <ofs> - Dump working buffer
be <ofs> [<data>] ... - Edit working buffer
br <pd#> <lba> [<count>] - Read disk into working buffer
bw <pd#> <lba> [<count>] - Write working buffer into disk
bf <val> - Fill working buffer
[File system controls]
fi <ld#> [<mount>]- Force initialized the volume
fs [<path>] - Show volume status
fl [<path>] - Show a directory
fo <mode> <file> - Open a file
mode 0 => Open existing file
mode 1 => Open as read file
mode 2 => Open as write file
mode 4 => Create new file
mode 8 => Create new file always
mode 16 => Open a file always
mode 48 => Open a file append
fc - Close the file
fe <ofs> - Move fp in normal seek
fd <len> - Read and dump the file
fr <len> - Read the file
fw <len> <val> - Write to the file
fn <org.name> <new.name> - Rename an object
fu <name> - Unlink an object
fv - Truncate the file at current fp
fk <name> - Create a directory
fa <atrr> <mask> <object name> - Change attribute of an object
ft <year> <month> <day> <hour> <min> <sec> <name> - Change timestamp of an object
fx <src.file> <dst.file> - Copy a file
fg <path> - Change current directory
fq - Show current directory
fb <name> - Set volume label
fm <ld#> <type> <csize> - Create file system
fz [<len>] - Change/Show R/W length for fr/fw/fx command
[Misc commands]
md[b|h|w] <addr> [<count>] - Dump memory
mf <addr> <value> <count> - Fill memory
me[b|h|w] <addr> [<value> ...] - Edit memory
t [<year> <mon> <mday> <hour> <min> <sec>] - Set/Show RTC
The following table lists the common features used for file systems along with the corresponding commands and examples to use them:
| Feature | Command | Example |
|---|---|---|
| Initialize file system | fi <ld#> [<mount>] | fi 0 1 |
| Show volume status | fs [<path>] | fs |
| Show directory | fl [<path>] | fl |
| Create directory | fk <name> | fk test |
| Unlink/ Delete file or directory | fu <name> | fu test |
| Open a new file | fo 4 <file> | fo 4 test.txt |
| Open a file to write | fo 2 <file> | fo 2 test.txt |
| Open a file to read | fo 1 <file> | fo 1 test.txt |
| Write a number of data to file | fw <len> <value> | Write 55 times of decimal 55(ASCII:7) fw 55 55 |
| Dump a number of data from opened file | fd <len> | Dump 100 data from opened file fd 100 |
| Close the opened file | fc | fc |
| Create file system | fm <type> | Format as FAT32 fm 2 |
| Change the timestamp of an object | ft <year> <month> <day> <hour> <min> <sec> <name> | Change test folder time and date to 2024/05/06 10:33:10 ft 2024
05 06 10 33 10 test |
| Change current path | fg <path> | fg test |
The SD Host Controller (SDHC) example supports both PIO and ADMA accesses. To enable ADMA
mode, uncomment the #define DMA_MODE preprocessor directive in the
userDef.h file. Otherwise, comment it out to use the PIO
mode.
To enable debug messages, set the DEBUG_PRINTF_EN directive to 1. This
is beneficial for debugging during the development stage.