我想将 index.html 这个文件烧录到 vfs分区,应该如何做?

Mars.CN
Posts: 44
Joined: Tue Jan 11, 2022 1:36 am

我想将 index.html 这个文件烧录到 vfs分区,应该如何做?

Postby Mars.CN » Thu Jun 15, 2023 1:50 am

我用的模组是 ESP32-S3-WROOM-2,ESP32-S3-N32R8V
正在做一个WiFi的项目,其中有一个配置页面,是用html写的,放在了 /main/spiffs/ 下
/main/spiffs/index.html
/main/spiffs/index.css
我的分区表格式如下:

Code: Select all

# Notes: the offset of the partition table itself is set in
# $IDF_PATH/components/partition_table/Kconfig.projbuild.
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x6000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000, 0x1F0000,
vfs,      data, fat,     0x200000, 0x1E00000,
我想在烧录固件的时候就把这两个文件写入到 vfs 分区中,这样就可以在项目中直接打开使用了

请问我应该如何操作才能在烧录固件的时候把文件也一并烧录进去?

Mars.CN
Posts: 44
Joined: Tue Jan 11, 2022 1:36 am

Re: 我想将 index.html 这个文件烧录到 vfs分区,应该如何做?

Postby Mars.CN » Thu Jun 15, 2023 2:00 am

补充一下,我这个分区是 FAT格式的,使用以下代码加载:

Code: Select all

esp_vfs_spiffs_conf_t conf = {
        .base_path = base_path,
        .partition_label = NULL,
        .max_files = 5,   // This sets the maximum number of files that can be open at the same time
        .format_if_mount_failed = true
    };

    esp_err_t ret = esp_vfs_spiffs_register(&conf);
    FILE* f = fopen("/flash/index.html", "r");

ESP_WangYX
Posts: 93
Joined: Mon Jun 28, 2021 12:48 pm

Re: 我想将 index.html 这个文件烧录到 vfs分区,应该如何做?

Postby ESP_WangYX » Thu Jun 15, 2023 5:21 am

您可以参考这里的描述:https://docs.espressif.com/projects/esp ... -generator
将 html 文件预先烧录到 flash 的方法有多种,您还可以参考:
1)https://github.com/espressif/esp-idf/bl ... sts.txt#L8
2)https://docs.espressif.com/projects/esp ... inary-data

Who is online

Users browsing this forum: No registered users and 70 guests