new vfs_fat_spiflash library

andymakespasta
Posts: 1
Joined: Wed Apr 19, 2017 12:40 am

new vfs_fat_spiflash library

Postby andymakespasta » Fri Apr 28, 2017 5:20 am

Hello. Thanks for implementing the new wear leveling fatfs spiflash library.
It's exactly what I've been looking for.

Unfortunately,

When I compile and run the example code at (esp-idf/examples/storage/wear_levelling) on an ESP WROOM-32
It fails when trying to "Formatting FATFS partition"
, more specifically, it fails the MBR check at (esp-idf/components/fatfs/src/ff.c), function f_mkfs(), line 5267, 5268:

Code: Select all

if (disk_read(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR;	/* Load MBR */
if (ld_word(buf + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED;	/* Check if MBR is valid */
The memory there is empty 0x0000.
Has anyone gotten the new library to run?

Thanks!

A dump of my logs:

Code: Select all

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0008,len:8
load:0x3fff0010,len:4416
load:0x40078000,len:11080
load:0x40080000,len:252
0x40080000: _iram_start at ??:?

entry 0x40080034
0x40080034: _iram_start at ??:?

I (45) boot: ESP-IDF v2.0-rc1-666-g0fe765a-dirty 2nd stage bootloader
I (46) boot: compile time 22:08:22
I (48) boot: Enabling RNG early entropy source...
I (65) boot: SPI Speed      : 40MHz
I (78) boot: SPI Mode       : DIO
I (90) boot: SPI Flash Size : 4MB
I (102) boot: Partition Table:
I (114) boot: ## Label            Usage          Type ST Offset   Length
I (136) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (160) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (183) boot:  2 factory          factory app      00 00 00010000 00100000
I (206) boot:  3 storage          Unknown data     01 81 00110000 00100000
I (230) boot: End of partition table
I (242) boot: Disabling RNG early entropy source...
I (260) boot: Loading app partition at offset 00010000
I (815) boot: segment 0: paddr=0x00010018 vaddr=0x00000000 size=0x0ffe8 ( 65512) 
I (816) boot: segment 1: paddr=0x00020008 vaddr=0x3f400010 size=0x08850 ( 34896) map
I (832) boot: segment 2: paddr=0x00028860 vaddr=0x3ffb0000 size=0x02b1c ( 11036) load
I (863) boot: segment 3: paddr=0x0002b384 vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _iram_start at ??:?

I (885) boot: segment 4: paddr=0x0002b78c vaddr=0x40080400 size=0x12ba8 ( 76712) load
I (947) boot: segment 5: paddr=0x0003e33c vaddr=0x400c0000 size=0x00000 (     0) load
I (948) boot: segment 6: paddr=0x0003e344 vaddr=0x00000000 size=0x01cc4 (  7364) 
I (969) boot: segment 7: paddr=0x00040010 vaddr=0x400d0018 size=0x2dda4 (187812) map
0x400d0018: _flash_cache_start at ??:?

I (994) cpu_start: Pro cpu up.
I (1006) cpu_start: Starting app cpu, entry point is 0x40080efc
0x40080efc: call_start_cpu1 at //redacted

I (0) cpu_start: App cpu up.
I (1039) heap_alloc_caps: Initializing. RAM available for dynamic allocation:
I (1061) heap_alloc_caps: At 3FFAE2A0 len 00001D60 (7 KiB): DRAM
I (1081) heap_alloc_caps: At 3FFB6940 len 000296C0 (165 KiB): DRAM
I (1103) heap_alloc_caps: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (1124) heap_alloc_caps: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1146) heap_alloc_caps: At 40092FA8 len 0000D058 (52 KiB): IRAM
I (1166) cpu_start: Pro cpu start user code
D (1204) clk: RTC_SLOW_CLK calibration value: 3096512
V (1234) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (1234) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (1267) intr_alloc: Connected src 56 to int 2 (cpu 0)
V (1299) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (1337) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (1387) intr_alloc: Connected src 16 to int 3 (cpu 0)
V (1419) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (1458) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0x40E
D (1509) intr_alloc: Connected src 24 to int 12 (cpu 0)
I (1542) cpu_start: Starting scheduler on PRO CPU.
V (550) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): checking args
V (550) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): Args okay. Resulting flags 0x40E

[ (560) intr_alloc: Connected src 25 to int 2 (cpu 1)
I (560) cpu_start: Starting scheduler on APP CPU.
0;32mI (550) example: Mounting FAT filesystem
V (580) wl_flash: config start_addr=0x00000000, full_mem_size=0x00100000, page_size=0x00001000, sector_size=0x00001000, updaterate=0x00000010, wr_size=0x00000010, version=0x00000001, temp_buff_size=0x00000020
V (590) wl_flash: config - this->addr_state1=0x000fb000
V (600) wl_flash: config - this->addr_state2=0x000fd000
D (600) wl_flash: init - config ID=1, stored ID=1, access_count=0, block_size=4096, max_count=16, pos=0, move_count=0
D (610) wl_flash: init starts: crc1=1280242342, crc2 = 1280242342, this->state.crc=1280242342, state_copy->crc=1280242342
D (630) wl_flash: init: crc1=1280242342, crc2 = 1280242342, result=0
D (630) wl_flash: recoverPos - this->state.pos=0x00000000, result=00000000
I (640) vfs_fat_spiflash: pdrv=0

V (640) ff_diskio_spiflash: ff_wl_ioctl: cmd=2

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

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

V (680) ff_diskio_spiflash: ff_wl_ioctl: cmd=2

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

V (690) wl_flash: read - src_addr=0x00000000, size=0x00001000
V (700) wl_flash: calcAddr - addr=0x00000000 -> result=0x00001000
E (700) vfs_fat_spiflash: f_mkfs failed (14)
E (700) example: Failed to mount FATFS (0xffffffff)

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

Re: new vfs_fat_spiflash library

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

Hello,
I get the exact same problem.

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

Obviously it will be fixed or the example may be removed. It could be possible that it works if you manually flash a FAT partition as f_mkfs seems to fail when checking for a valid Master Boot Record. (MBR)
Row 5268 in file ff.c

/*-----------------------------------------------------------------------*/
/* Create FAT file system on the logical drive */
/*-----------------------------------------------------------------------*/

FRESULT f_mkfs (
const TCHAR* path, /* Logical drive number */
BYTE opt, /* Format option */
DWORD au, /* Size of allocation unit [byte] */
void* work, /* Pointer to working buffer */
UINT len /* Size of working buffer */
)
....
/* Determine where the volume to be located (b_vol, sz_vol) */
if (_MULTI_PARTITION && part != 0) {
/* Get partition information from partition table in the MBR */
if (disk_read(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Load MBR */

/Olof

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

Re: new vfs_fat_spiflash library

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

This has been fixed in 33b8b78, please pull the latest master.

Who is online

Users browsing this forum: No registered users and 120 guests