1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

examples/filesystem: Explain how to use fatfs

This commit is contained in:
chrysn 2021-09-02 17:45:54 +02:00
parent 2c84f997d9
commit deacdf130d

View File

@ -76,3 +76,47 @@ Hello World!
cat /const/hello-riot
Hello RIOT!
```
## Example on `native` with `fatfs`
- Unpack the provided image proviced in the `pkg_fatfs` test:
```
$ tar vxjf ../../tests/pkg_fatfs/riot_fatfs_disk.tar.bz2
riot_fatfs_disk.img
```
- Configure the application to use the file and the right geometry by adding
these to the Makefile:
```
CFLAGS += -DMTD_NATIVE_FILENAME=\"riot_fatfs_disk.img\"
CFLAGS += -DMTD_PAGE_SIZE=512
CFLAGS += -DMTD_SECTOR_SIZE=512
CFLAGS += -DMTD_SECTOR_NUM=262144
```
- In the Makefile, comment the `littlefs2` USEMODULE line, and enable the
`fatfs_vfs` line instead.
- Build and run the `filesystem` example application on the `native` target as above.
- Mount the external file system:
```
> mount
mount
/sda successfully mounted
```
- List the available files in the FAT partition:
```
> ls /sda
ls /sda
TEST.TXT
total 1 files
```
- You can also use the writing commands now to create and modify files; run
`vfs` for instructions.