Skip to content

Commit

Permalink
Merge pull request RIOT-OS#16800 from chrysn-pull-requests/vfs-fat-us…
Browse files Browse the repository at this point in the history
…ability

Small fatfs usability fixes
  • Loading branch information
chrysn authored Sep 2, 2021
2 parents a59974c + deacdf1 commit 2bf1202
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
44 changes: 44 additions & 0 deletions examples/filesystem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
5 changes: 3 additions & 2 deletions tests/pkg_fatfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ USEMODULE += mtd_sdcard
endif

image:
@tar -xjf riot_fatfs_disk.tar.gz -C ./bin/
${Q}mkdir -p bin
${Q}tar -xjf riot_fatfs_disk.tar.bz2 -C ./bin/

#this generates a compressed fat image file that can be used by the fat driver on native
compressed-image:
@./create_fat_image_file.sh $(FATFS_IMAGE_FILE_SIZE_MIB)
${Q}./create_fat_image_file.sh $(FATFS_IMAGE_FILE_SIZE_MIB)

include $(RIOTBASE)/Makefile.include
2 changes: 1 addition & 1 deletion tests/pkg_fatfs/create_fat_image_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ sudo mount -o loop,umask=000 riot_fatfs_disk.img /media/riot_fatfs_disk
touch /media/riot_fatfs_disk/test.txt
echo "the test file content 123 abc" | tr '\n' '\0' >> /media/riot_fatfs_disk/test.txt
sudo umount /media/riot_fatfs_disk
tar -cjf riot_fatfs_disk.tar.gz riot_fatfs_disk.img
tar -cjf riot_fatfs_disk.tar.bz2 riot_fatfs_disk.img
rm riot_fatfs_disk.img
File renamed without changes.

0 comments on commit 2bf1202

Please sign in to comment.