Write filesystem to spiffs <SOLVED>

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Write filesystem to spiffs <SOLVED>

Postby fly135 » 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
Last edited by fly135 on Fri Dec 14, 2018 6:35 pm, edited 1 time in total.

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Write filesystem to spiffs

Postby PeterR » Tue Dec 11, 2018 4:13 pm

Hi,
I used https://github.com/loboris/ESP32_spiffs_example.git because it has directory support.

I only added a few large Gutenbergs to the example (no code or build changes) but seemed to serve them up well enough.
& I also believe that IDF CAN should be fixed.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Write filesystem to spiffs

Postby fly135 » Tue Dec 11, 2018 4:59 pm

PeterR wrote:
Tue Dec 11, 2018 4:13 pm
Hi,
I used https://github.com/loboris/ESP32_spiffs_example.git because it has directory support.

I only added a few large Gutenbergs to the example (no code or build changes) but seemed to serve them up well enough.
I'm not really interested in viewing directories. Were you able to burn a file system to a partition and read it after boot? I'm using the most recent pre-built version of mkspiffs for the ESP IDF. The IDF docs describe using mkspiffs to create and burn a file system. It would be nice if someone could confirm that it actually works on IDF release 3.1.1.

John A

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Write filesystem to spiffs

Postby fly135 » Wed Dec 12, 2018 12:19 am

So now I've downloaded the file via HTTP and wrote it to the file system. I can read it back in my application. But if I use esptool to read the partition into a bin file, mkspiffss fails to mount the FS.

I am using the latest mkspiffs build and the version info verifies it's built for the ESP32....

"Build configuration name: esp-idf"

But it doesn't seem compatible with IDF release v3.1.1

John A

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Write filesystem to spiffs

Postby PeterR » Wed Dec 12, 2018 12:48 pm

Were you able to burn a file system to a partition and read it after boot? I'm using the most recent pre-built version of mkspiffs for the ESP IDF. The IDF docs describe using mkspiffs to create and burn a file system. It would be nice if someone could confirm that it actually works on IDF release 3.1.1.
Yes. I added a couple of .txt books to the referenced example. As I recall the example contains a webserver and you could see all in the browser - the browser being feed by a file system.

My CM was a bit sloppy at the time (surveying/prototyping).
I doubt that I was on 3.1.1.
Its most likely that I was on ESP-IDF v3.2-dev-760-ga0d2dd03 but have since moved on to v3.2-beta1-34-gfb7ba1baa
Hope that helps.
I will be picking SPIFFS up early January as I need to add the webserver. Be keen to hear how you get on.
& I also believe that IDF CAN should be fixed.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Write filesystem to spiffs

Postby fly135 » Thu Dec 13, 2018 4:54 pm

Can we not get an Espressif engineer to comment on this? I ask because it's part of the official v3.1.1 documentation posted on the Espressif site that this is supported, and it does not work.

John A

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Write filesystem to spiffs

Postby ESP_igrr » Fri Dec 14, 2018 4:01 am

Hi John,
I was able to generate a SPIFFS image using mkspiffs, upload it to flash, and get the slightly modified spiffs example from IDF 3.1.1 to read it. The modification was to disable creating, removing, and renaming parts of the example, and keep only reading from foo.txt.

My commands on the host side:

cd $IDF_PATH/examples/storage/spiffs
rm -rf build sdkconfig
(modify example code as explained above)
idf.py flash

(download mkspiffs release)
unzip ~/Downloads/mkspiffs-0.2.3-esp-idf-win32.zip
cd mkspiffs-0.2.3-esp-idf-win32
mkdir data
echo "Hello from mkspiffs" > data/foo.txt
./mkspiffs.exe -c data -s 0xF0000 spiffs.bin
$IDF_PATH/components/esptool_py/esptool/esptool.py --port COM9 --baud 921600 write_flash 0x110000 spiffs.bin
cd -

idf.py monitor

After this, example runs and prints "Hello from mkspiffs".


Edit:
esp_vfs_fat_spiflash_mount(tcffs_base_path, "templates", &mount_config, &s_wl_handle)
FAT?..
https://docs.espressif.com/projects/esp ... l_handle_t

esp_vfs_spiffs_register may work better if you are preparing a SPIFFS partition.
https://docs.espressif.com/projects/esp ... ffs_conf_t

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Write filesystem to spiffs

Postby fly135 » Fri Dec 14, 2018 6:35 pm

ESP_igrr wrote:
Fri Dec 14, 2018 4:01 am
esp_vfs_fat_spiflash_mount(tcffs_base_path, "templates", &mount_config, &s_wl_handle)
FAT?..
https://docs.espressif.com/projects/esp ... l_handle_t

esp_vfs_spiffs_register may work better if you are preparing a SPIFFS partition.
https://docs.espressif.com/projects/esp ... ffs_conf_t
Thank you so much! The call to esp_vfs_spiffs_register was the solution! :D

John A

Who is online

Users browsing this forum: Bing [Bot] and 110 guests