Integrate VFS interface to external other file system

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
bhcuong2008
Posts: 14
Joined: Sun May 30, 2021 7:38 am

Integrate VFS interface to external other file system

Post by bhcuong2008 » Mon Jun 07, 2021 8:38 am

Hi,

I integrate MPY as a library to my main program in Arduino ESP32. On ESP32, it already has VFS implementation. So I want to integrate it into MPY VFS.

I look at the code of MPY vfs, vfs fat, found that the module is integrated tightly with library oofatfs.

Please guide me how to integrate ESP32 Arduino VFS into MPY VFS, discard oofatfs. So that MPY has features of file io, doing import, run .py, .mpy from the file system, open/write/find/close file,...

I mean I want to keep all MPY io APIs, but I will make glue code to ESP32 Arduino VFS (to support SPIFFS too).

Thank you so so much.

bhcuong2008
Posts: 14
Joined: Sun May 30, 2021 7:38 am

Re: Integrate VFS interface to external other file system

Post by bhcuong2008 » Mon Jun 07, 2021 10:37 am

In file vfs_fat_file.c, MPY 1.15, I really dont understand why.

line 217, it calls file_open with NULL as 1st argument.

Code: Select all

STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
    mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS];
    mp_arg_parse_all_kw_array(n_args, n_kw, args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals);
    return file_open(NULL, type, arg_vals);
}
But, in function file_open, at line 199, it checks

Code: Select all

assert(vfs != NULL);
So FileIO class could not be created!

Please help me explain the reason.
Thanks.

Post Reply