New LIbrary vfs_fat_spiflash not working

teckhaokoh
Posts: 34
Joined: Wed Sep 21, 2016 6:40 am

New LIbrary vfs_fat_spiflash not working

Postby teckhaokoh » Fri May 05, 2017 7:47 am

Hi All,

Anyone has tried the new library offering the FATFS with VFS interface, which mount into the spi flash?
I've tried with the convenient function " esp_vfs_fat_spiflash_mount", but always returned error.

I've tried to compile the example "wear_leveling", but the example itself not working too.

Anyone able to get it to work?

The same error message return when mounting the file system to spi flash, as below:

**********************************************************************************
W (1156) vfs_fat_spiflash: f_mount failed (13)
I (1156) vfs_fat_spiflash: Formatting FATFS partition
E (1156) vfs_fat_spiflash: f_mkfs failed (14)
E (1166) example: Failed to mount FATFS (0xffffffff)
**********************************************************************************

Olof Astrand
Posts: 27
Joined: Tue Jan 31, 2017 10:59 am

Re: New LIbrary vfs_fat_spiflash not working

Postby Olof Astrand » Fri May 05, 2017 8:31 am

Hello,
I get the same problem.

https://github.com/Ebiroll/qemu_esp32/b ... creenlog.0

Really nice if it did work.
Do you have any example on how to use VFS with some other filsystem? SPIFF?

/Olof

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: New LIbrary vfs_fat_spiflash not working

Postby WiFive » Fri May 05, 2017 9:04 am


ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: New LIbrary vfs_fat_spiflash not working

Postby ESP_igrr » Fri May 05, 2017 12:05 pm

Sorry about that issue. The PR and a bunch of other fixes related to FATFS and wear levelling are in the merge queue, should be in master soon.

Edit: fix has been released to Github in 33b8b78.

Olof Astrand
Posts: 27
Joined: Tue Jan 31, 2017 10:59 am

Re: New LIbrary vfs_fat_spiflash not working

Postby Olof Astrand » Fri May 05, 2017 1:23 pm

I tried the new esp-idf, formatting the disk seems to work OK but it fails on fopen() vfs_fat_open: fresult=13

Only tested in qemu so I think the error is in qemu .

Here is the MBR from the qemu-flash,

00111000: ebfe 904d 5344 4f53 352e 3000 1001 0100 ...MSDOS5.0.....
00111010: 0100 02fa 00f8 0100 3f00 ff00 0000 0000 ........?.......
00111020: 0000 0000 8000 2900 0021 004e 4f20 4e41 ......)..!.NO NA
00111030: 4d45 2020 2020 4641 5420 2020 2020 0000 ME FAT ..
00111040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111050: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111060: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111070: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111080: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111090: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001110a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001110b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001110c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001110d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001110e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001110f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111100: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111110: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111120: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111130: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111140: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111150: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111160: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111170: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111180: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00111190: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001111a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001111b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001111c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001111d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001111e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
001111f0: 0000 0000 0000 0000 0000 0000 0000 55aa ..............U.
00111200:


in qemu fopen fails becuse find_volume () that calls fmt = check_fs(fs, bsect); returns 3,
if (fmt >= 2) return FR_NO_FILESYSTEM; /* No FAT volume is found */

From qemu, SPI-flash log
written
0 esp32_spi_write: +0x04 = 0x111f8000
Address esp32_spi_write_address: TX 001f8000[17 reserved]
0 esp32_spi_write: +0x00 = 0x00040000
esp32_spi_cmd: TX 0003[7 bits]
SPI_READ 0x03. 001F8000

This is wrong should be 0x111f8000


/Olof





V (159) wl_flash: read - src_addr=0x00000000, size=0x00001000
V (159) wl_flash: calcAddr - addr=0x00000000 -> result=0x00001000
W (169) vfs_fat_spiflash: f_mount failed (13)
I (169) vfs_fat_spiflash: Formatting FATFS partition
V (169) ff_diskio_spiflash: ff_wl_ioctl: cmd=3

V (169) ff_diskio_spiflash: ff_wl_ioctl: cmd=2

V (169) ff_diskio_spiflash: ff_wl_ioctl: cmd=1

V (169) ff_diskio_spiflash: ff_wl_write - pdrv=0, sector=0, count=1

V (169) wl_flash: erase_range - start_address=0x00000000, size=0x00001000
V (169) wl_flash: erase_sector - sector=0x00000000
V (169) wl_flash: calcAddr - addr=0x00000000 -> result=0x00001000
V (169) wl_partition: erase_range - start_address=0x00001000, size=0x00001000, result=0x00000000
V (169) wl_flash: erase_range - result=00000000
V (169) wl_flash: write - dest_addr=0x00000000, size=0x00001000
V (169) wl_flash: calcAddr - addr=0x00000000 -> result=0x00001000
V (179) ff_diskio_spiflash: ff_wl_write - pdrv=0, sector=1, count=1

V (179) wl_flash: erase_range - start_address=0x00001000, size=0x00001000
V (179) wl_flash: erase_sector - sector=0x00000001
V (179) wl_flash: calcAddr - addr=0x00001000 -> result=0x00002000
V (179) wl_partition: erase_range - start_address=0x00002000, size=0x00001000, result=0x00000000
V (179) wl_flash: erase_range - result=00000000
V (179) wl_flash: write - dest_addr=0x00001000, size=0x00001000
V (179) wl_flash: calcAddr - addr=0x00001000 -> result=0x00002000
V (179) ff_diskio_spiflash: ff_wl_write - pdrv=0, sector=2, count=1

V (179) wl_flash: erase_range - start_address=0x00002000, size=0x00001000
V (179) wl_flash: erase_sector - sector=0x00000002
V (179) wl_flash: calcAddr - addr=0x00002000 -> result=0x00003000
V (189) wl_partition: erase_range - start_address=0x00003000, size=0x00001000, result=0x00000000
V (189) wl_flash: erase_range - result=00000000
V (189) wl_flash: write - dest_addr=0x00002000, size=0x00001000
V (189) wl_flash: calcAddr - addr=0x00002000 -> result=0x00003000
V (199) ff_diskio_spiflash: ff_wl_write - pdrv=0, sector=3, count=1

V (199) wl_flash: erase_range - start_address=0x00003000, size=0x00001000
V (199) wl_flash: erase_sector - sector=0x00000003
V (199) wl_flash: calcAddr - addr=0x00003000 -> result=0x00004000
V (209) wl_partition: erase_range - start_address=0x00004000, size=0x00001000, result=0x00000000
V (209) wl_flash: erase_range - result=00000000
V (209) wl_flash: write - dest_addr=0x00003000, size=0x00001000
V (209) wl_flash: calcAddr - addr=0x00003000 -> result=0x00004000
V (219) ff_diskio_spiflash: ff_wl_write - pdrv=0, sector=4, count=1

V (219) wl_flash: erase_range - start_address=0x00004000, size=0x00001000
V (219) wl_flash: erase_sector - sector=0x00000004
V (219) wl_flash: calcAddr - addr=0x00004000 -> result=0x00005000
V (229) wl_partition: erase_range - start_address=0x00005000, size=0x00001000, result=0x00000000
V (229) wl_flash: erase_range - result=00000000
V (229) wl_flash: write - dest_addr=0x00004000, size=0x00001000
V (229) wl_flash: calcAddr - addr=0x00004000 -> result=0x00005000
V (239) ff_diskio_spiflash: ff_wl_write - pdrv=0, sector=5, count=1

V (239) wl_flash: erase_range - start_address=0x00005000, size=0x00001000
V (239) wl_flash: erase_sector - sector=0x00000005
V (239) wl_flash: calcAddr - addr=0x00005000 -> result=0x00006000
V (239) wl_partition: erase_range - start_address=0x00006000, size=0x00001000, result=0x00000000
V (239) wl_flash: erase_range - result=00000000
V (239) wl_flash: write - dest_addr=0x00005000, size=0x00001000
V (239) wl_flash: calcAddr - addr=0x00005000 -> result=0x00006000
V (249) ff_diskio_spiflash: ff_wl_ioctl: cmd=0

I (249) vfs_fat_spiflash: Mounting again
I (249) example: Opening file
V (249) vfs_fat: vfs_fat_open: path="/hello.txt", flags=601, mode=1b6
V (249) ff_diskio_spiflash: ff_wl_ioctl: cmd=2

V (249) ff_diskio_spiflash: ff_wl_read - pdrv=0, sector=0, count=1

V (249) wl_flash: read - src_addr=0x00000000, size=0x00001000
V (249) wl_flash: calcAddr - addr=0x00000000 -> result=0x00001000
D (259) vfs_fat: vfs_fat_open: fresult=13
E (259) example: Failed to open file for writing

Olof Astrand
Posts: 27
Joined: Tue Jan 31, 2017 10:59 am

Re: New LIbrary vfs_fat_spiflash not working

Postby Olof Astrand » Mon May 08, 2017 10:10 am

For the record. It was an error in QEMU, now it works fine.

You can also mount the FAT image,

mkdir fat_partition
sudo mount -o loop,offset=0x110000 esp32flash.bin fat_partition
ls fat_partition
????? hello.txt
However reading the file did not work.
od -h fat_partition/hello.txt
0000000 0000 0000 0000 0000 0000 0000 0000 0000

Maybe it works better with an actual dump of the flash.
To make a dump of flash try,
~/esp/esp-idf/components/esptool_py/esptool/esptool.py --baud 920600 read_flash 0 0x400000 esp32flash.bin

teckhaokoh
Posts: 34
Joined: Wed Sep 21, 2016 6:40 am

Re: New LIbrary vfs_fat_spiflash not working

Postby teckhaokoh » Tue May 09, 2017 6:55 am

Thanks all for the info!!!
After updated the esp-idf, it's working now! :)

But another thing to double check, I found that the file extension has some limitation right?
From what I tested, the file name extension can only be "name.ext".
1. file extension (the ".ext") can't go for more than 3 characters
2. you can't create a file as "name.ext.ext"

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: New LIbrary vfs_fat_spiflash not working

Postby WiFive » Tue May 09, 2017 7:33 am


teckhaokoh
Posts: 34
Joined: Wed Sep 21, 2016 6:40 am

Re: New LIbrary vfs_fat_spiflash not working

Postby teckhaokoh » Tue May 09, 2017 8:31 am

Thanks for the info!! :D

Who is online

Users browsing this forum: No registered users and 115 guests