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

Merge pull request #16800 from chrysn-pull-requests/vfs-fat-usability

Small fatfs usability fixes
This commit is contained in:
chrysn 2021-09-02 20:54:01 +02:00 committed by GitHub
commit 2bf1202fb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 3 deletions

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.

View File

@ -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

View File

@ -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