[SOLVED ]VFS / vfs_fat, what is the difference between built-in SPI flash and SD card ?

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
shazz
Posts: 46
Joined: Tue Apr 30, 2019 6:35 pm
Contact:

[SOLVED ]VFS / vfs_fat, what is the difference between built-in SPI flash and SD card ?

Post by shazz » Wed May 15, 2019 5:18 pm

Hi,

I have a MicroPython module which uses

Code: Select all

#include "lib/oofatfs/ff.h"
#include "extmod/vfs.h"
#include "extmod/vfs_fat.h"
To read files on my Meowbit storage devices.

The call:

Code: Select all

extern fs_user_mount_t fs_user_mount_flash;
fs_user_mount_t *vfs_fat = &fs_user_mount_flash;
FIL fp;

FRESULT  res = f_open(&vfs_fat->fatfs, &fp, filename, FA_READ);
works perfectly well (res==FR_OK) when the file is located on the Meowbit default 2MB SPI Flash but returns an error (FR_NO_FILE or FR_NO_PATH) if the file is located on the SD card (which is properly mounted at /sd, REPL can access py files,...)

Anything specific thing I should do ?

Thanks !
8bits should be enough...

User avatar
shazz
Posts: 46
Joined: Tue Apr 30, 2019 6:35 pm
Contact:

Re: [SOLVED ]VFS / vfs_fat, what is the difference between built-in SPI flash and SD card ?

Post by shazz » Sat May 18, 2019 4:19 pm

Ok I found out I need to retrieve the mount point first using:

Code: Select all

    // retrieve VFS FAT mount
    mp_vfs_mount_t *vfs = mp_vfs_lookup_path(filename, &p_out);
    if (vfs != MP_VFS_NONE && vfs != MP_VFS_ROOT) {
        vfs_fat = MP_OBJ_TO_PTR(vfs->obj);
    }
    else {
        printf("Cannot find user mount for %s\n", filename);
        return mp_const_none;
    }   
Then it works fine... Good to know :)
8bits should be enough...

Post Reply