FATFS
Overview
This application is a comprehensive example using the WM_IoT_SDK
for the FATFS file system. It demonstrates how to use the FATFS API in the WM_IoT_SDK
for mounting an SD card and performing file read and write operations. The example includes:
SD Card Mounting: Mount the SD card to the file system.
File Creation and Writing: Create a file named test.txt and write the string “Hello, FatFs!”.
File Reading and Verification: Read the contents of the test.txt file and compare them with the written content to verify data consistency.
Requirements
The wm_drv_sdh_sdmmc driver needs to be correctly configured.
A hardware environment that supports SD cards is required, and an SD card should be inserted.
The SD card needs to be in FATFS format. If not, please format it in advance.
Building and flashing
Example Location: examples\storage\fatfs
compile, burn, and more, see: get started
Running result
Successfully running will output the following logs
D/dt [0.002] add device iflash
D/ptb [0.002] partition table base 0xe000
D/ft [0.002] ft_0 base 0, ft_1 base 1000
D/ft [0.002] ft init too
D/ft [0.004] ft init 1
D/main [0.004] boot reason 0
D/main [0.004] heap size 273360(266.95KB)
D/main [0.004] flash size 0x200000(2MB)
I/example [0.006] FATFS demo start.
I/example [0.006] SDMMC driver registered successfully.
I/diskio_sdmmc [0.006] Initializing sdmmc device...
D/dt [0.008] add device sdmmc
D/dt [0.026] add device rtc
I/example [0.056] write txt: Hello, FatFs!
I/example [0.056] read txt: Hello, FatFs!
I/example [0.056] This example succeeds in running.