Write filesystem to spiffs <SOLVED>
Posted: Sun Dec 09, 2018 10:25 pm
I'm using mkspiffs to create a file system to write to a partition. Unfortunately when I try to open the single file stored on it (readme.txt), it fails to open the file. I can create the file, write to it, then read it back. But for some reason the file isn't recognized when written to the flash with esptool.
This is the version of mkspiffs.exe...
Build configuration name: esp-idf
SPIFFS ver. 0.3.7-5-gf5e26c4
Extra build flags: -DSPIFFS_OBJ_META_LEN=4
SPIFFS configuration:
SPIFFS_OBJ_NAME_LEN: 32
SPIFFS_OBJ_META_LEN: 4
SPIFFS_USE_MAGIC: 1
SPIFFS_USE_MAGIC_LENGTH: 1
SPIFFS_ALIGNED_OBJECT_INDEX_TABLES: 0
Using IDF 3.1.1 and this is in my sdkconfig file....
$ cat sdkconfig | grep SPIFFS
# SPIFFS Configuration
CONFIG_SPIFFS_MAX_PARTITIONS=3
# SPIFFS Cache Configuration
CONFIG_SPIFFS_CACHE=y
CONFIG_SPIFFS_CACHE_WR=y
CONFIG_SPIFFS_CACHE_STATS=
CONFIG_SPIFFS_PAGE_CHECK=y
CONFIG_SPIFFS_GC_MAX_RUNS=10
CONFIG_SPIFFS_GC_STATS=y
CONFIG_SPIFFS_PAGE_SIZE=256
CONFIG_SPIFFS_OBJ_NAME_LEN=32
CONFIG_SPIFFS_USE_MAGIC=y
CONFIG_SPIFFS_USE_MAGIC_LENGTH=y
CONFIG_SPIFFS_META_LENGTH=4
CONFIG_SPIFFS_USE_MTIME=y
CONFIG_SPIFFS_DBG=y
CONFIG_SPIFFS_API_DBG=
CONFIG_SPIFFS_GC_DBG=
CONFIG_SPIFFS_CACHE_DBG=
CONFIG_SPIFFS_CHECK_DBG=y
CONFIG_SPIFFS_TEST_VISUALISATION=
This my paritition table (I'm using the partition templates)...
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000,
ota_0, 0, ota_0, 0x10000, 0x200000
ota_1, 0, ota_1, 0x210000, 0x200000
storage, data, spiffs, , 0xF0000,
templates, data, spiffs, , 0x100000,
I'm creating the file as follows....
./mkspiffs.exe -c tcfs -b 4096 -p 256 -s 0x100000 tcfs.bin
And writing it like this....
python $IDF_PATH/components/esptool_py/esptool/esptool.py --chip esp32 --port com3 --baud 921600 write_flash -z 0x500000 tcfs.bin
I mount it with...
esp_vfs_fat_spiflash_mount(tcffs_base_path, "templates", &mount_config, &s_wl_handle)
However this command always return an error....
esp_spiffs_info("templates", &size_bytes, &used_bytes);
If using esptool I do a "read_flash" that writes to a file I can see the text from readme.txt in the file. I've been using spiffs for a while with no problems. But this is the first time I've tried preparing a file system and writing to flash.
John A
This is the version of mkspiffs.exe...
Build configuration name: esp-idf
SPIFFS ver. 0.3.7-5-gf5e26c4
Extra build flags: -DSPIFFS_OBJ_META_LEN=4
SPIFFS configuration:
SPIFFS_OBJ_NAME_LEN: 32
SPIFFS_OBJ_META_LEN: 4
SPIFFS_USE_MAGIC: 1
SPIFFS_USE_MAGIC_LENGTH: 1
SPIFFS_ALIGNED_OBJECT_INDEX_TABLES: 0
Using IDF 3.1.1 and this is in my sdkconfig file....
$ cat sdkconfig | grep SPIFFS
# SPIFFS Configuration
CONFIG_SPIFFS_MAX_PARTITIONS=3
# SPIFFS Cache Configuration
CONFIG_SPIFFS_CACHE=y
CONFIG_SPIFFS_CACHE_WR=y
CONFIG_SPIFFS_CACHE_STATS=
CONFIG_SPIFFS_PAGE_CHECK=y
CONFIG_SPIFFS_GC_MAX_RUNS=10
CONFIG_SPIFFS_GC_STATS=y
CONFIG_SPIFFS_PAGE_SIZE=256
CONFIG_SPIFFS_OBJ_NAME_LEN=32
CONFIG_SPIFFS_USE_MAGIC=y
CONFIG_SPIFFS_USE_MAGIC_LENGTH=y
CONFIG_SPIFFS_META_LENGTH=4
CONFIG_SPIFFS_USE_MTIME=y
CONFIG_SPIFFS_DBG=y
CONFIG_SPIFFS_API_DBG=
CONFIG_SPIFFS_GC_DBG=
CONFIG_SPIFFS_CACHE_DBG=
CONFIG_SPIFFS_CHECK_DBG=y
CONFIG_SPIFFS_TEST_VISUALISATION=
This my paritition table (I'm using the partition templates)...
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000,
ota_0, 0, ota_0, 0x10000, 0x200000
ota_1, 0, ota_1, 0x210000, 0x200000
storage, data, spiffs, , 0xF0000,
templates, data, spiffs, , 0x100000,
I'm creating the file as follows....
./mkspiffs.exe -c tcfs -b 4096 -p 256 -s 0x100000 tcfs.bin
And writing it like this....
python $IDF_PATH/components/esptool_py/esptool/esptool.py --chip esp32 --port com3 --baud 921600 write_flash -z 0x500000 tcfs.bin
I mount it with...
esp_vfs_fat_spiflash_mount(tcffs_base_path, "templates", &mount_config, &s_wl_handle)
However this command always return an error....
esp_spiffs_info("templates", &size_bytes, &used_bytes);
If using esptool I do a "read_flash" that writes to a file I can see the text from readme.txt in the file. I've been using spiffs for a while with no problems. But this is the first time I've tried preparing a file system and writing to flash.
John A