virtual SPIFFS in APP partition

ghost07
Posts: 36
Joined: Mon Oct 03, 2022 11:47 am

virtual SPIFFS in APP partition

Postby ghost07 » Wed Apr 19, 2023 3:01 pm

Hi, is it possible to embed read-only SPIFFS into APP partition?
Unfortunately, the device has been already shipped to client, but there is a request for some updates, which can be solved by OTA update, but the device doesn't have SPIFFS partition created, only 3 APP partitions (factory, ota1, ota2). I need to embed some web files and it would be easier if I could access them by their names using fopen() rather than asm symbols. So I could edit just VFS path to read file from SD card, or embedded one.

ghost07
Posts: 36
Joined: Mon Oct 03, 2022 11:47 am

Re: virtual SPIFFS in APP partition

Postby ghost07 » Wed Apr 19, 2023 4:03 pm

I guess I'll try to embed files in tar archive, and register custom VFS to that tar data.

ghost07
Posts: 36
Joined: Mon Oct 03, 2022 11:47 am

Re: virtual SPIFFS in APP partition

Postby ghost07 » Mon May 15, 2023 3:34 pm

How I can check which mode was used in open() function?
So far I have following code:

Code: Select all

void register_webtar_vfs(void)
{
    esp_vfs_t webtar = {
        .flags = ESP_VFS_FLAG_DEFAULT,
        .write = NULL, // &webtar_write
        .open = &webtar_open,
        .fstat = NULL, // &webtar_fstat,
        .close = NULL, // &webtar_close,
        .read = &webtar_read,
    };

    ESP_ERROR_CHECK(esp_vfs_register("/webtar", &webtar, NULL));
}

Code: Select all

static int webtar_open(const char * path, int flags, int mode)
{
    ESP_LOGI(TAG, "open %s, flags: 0x%08X, mode: 0x%08X [RO: %d, WO: %d, RW: %d]", 
        path, flags, mode, mode & O_RDONLY, mode & O_WRONLY, mode & O_RDWR);

    // if (mode != O_RDONLY) return -1;
    // ...
}
And in URI handler I call open() like this:

Code: Select all

int fd = open(path, O_RDONLY);
However, in debug log I get 0 for each mode.
I (20057) WEBTAR_VFS: open /index.html, flags: 0x00000000, mode: 0x3F40B918 [RO: 0, WO: 0, RW: 0]

ESP_Sprite
Posts: 9745
Joined: Thu Nov 26, 2015 4:08 am

Re: virtual SPIFFS in APP partition

Postby ESP_Sprite » Tue May 16, 2023 8:29 am

That is odd... all I can say that 'mode' looks like a pointer here, while you'd simply expect the value of the mode argument (=O_RDONLY) to show up there.

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 89 guests