FileSystem AT Commands
AT+FS: Filesystem Operations.
AT+FSMOUNT: Mount/Unmount Filesystem.
Introduction
Important
The default AT firmware does not support the AT commands listed on this page. If you need ESP32-C6 to support FileSystem commands, you can compile the ESP-AT project by following the steps in Compile ESP-AT Project Locally documentation. In the project configuration during the fifth step, make the following selections:
Enable
Component config
->AT
->AT FS command support
AT+FS: Filesystem Operations
Set Command
Command:
AT+FS=<type>,<operation>,<filename>,<offset>,<length>
Response:
OK
Parameters
<type>: only FATFS is currently supported.
0: FATFS
<operation>:
0: delete file.
1: write file.
2: read file.
3: query the size of the file.
4: list files in a specific directory. Only root directory is currently supported.
<offset>: apply to writing and reading operations only.
<length>: data length, applying to writing and reading operations only.
Notes
This command will automatically mount the filesystem. After the AT+FS filesystem operation is all done, it is strongly recommended to use the AT+FSMOUNT=0 command to unmount the filesystem to free a large amount of RAM space.
Please make sure that you have downloaded at_customize.bin before using this command. For more details, refer to ESP-IDF Partition Tables and How to Customize Partitions.
If the length of the read data is greater than the actual file length, only the actual data length of the file will be returned.
If the operator is
write
, wrap return>
after the write command, then you can send the data that you want to write. The length should be parameter<length>
.
Example
// delete a file.
AT+FS=0,0,"filename"
// write 10 bytes to offset 100 of a file.
AT+FS=0,1,"filename",100,10
// read 100 bytes from offset 0 of a file.
AT+FS=0,2,"filename",0,100
// list all files in the root directory.
AT+FS=0,4,"."
AT+FSMOUNT: Mount/Unmount Filesystem
Set Command
Command:
AT+FSMOUNT=<mount>
Response:
OK
Parameters
<mount>:
0: Unmount filesystem
1: Mount filesystem
Notes
After the AT+FS filesystem operation is all done, it is strongly recommended to use the AT+FSMOUNT=0 command to unmount the filesystem to free a large amount of RAM space.
Example
// unmount the filesystem manually
AT+FSMOUNT=0
// mount the filesystem manually
AT+FSMOUNT=1