How to generate SPIFFS image externally?

Hi @nliviu,

I have tried your example above, but the html content in the “extra-fs” never get to the esp8266 after flash.

Here are the step that I did with some modification from your exmaple.

  1. Create a folder “chi” in esp8266 project, add html files to the “chi” folder
  2. Execute docker to create bin image
docker run -v $(pwd):$(pwd) -t mgos/esp8266-build:2.2.1-1.5.0-r5 mkspiffs -s 524288 $(pwd)/chi -f $(pwd)/src/chi.bin

Output from docker

     FS params: size=524288, bs=4096, ps=256, es=4096
       Adding a.png: 12038
       Adding b.ico: 2238
       Adding c.png: 12785
       Adding index.html: 33285
     FS stats : space total=474641, used=61746, free=412895
  1. add the following from your mos.yml with some modification
config_schema:
  - ["devtab.dev0.name", "data"]
  - ["devtab.dev0.type", "part"]
  - ["devtab.dev0.opts", '{"dev": "sfl0", "offset": 0x300000, "size": 0x80000}']
  - ["fstab.fs0.dev", "data"]
  - ["fstab.fs0.type", "SPIFFS"]
  - ["fstab.fs0.opts", '{"bs": 4096, "ps": 128, "es": 4096}']
  - ["fstab.fs0.path", "/chi"]
  - ["fstab.fs0.create", true]

libs:
  - origin: https://github.com/mongoose-os-libs/fstab
  - origin: https://github.com/mongoose-os-libs/vfs-dev-part

build_vars:
  APP_EXTRA_FW_PARTS: fs_data:type=fs,src=src/chi.bin,addr=0x300000

  • build and flash via uart

Output :

mgos_vfs_dev.c:73       data: part ({"dev": "sfl0", "offset": 0x300000, "size": 0x80000}), size 524288
mgos_vfs.c:147          /chi: SPIFFS @ data, opts {"bs": 4096, "ps": 128, "es": 4096}
mgos_vfs.c:320          /chi: size 480561, used: 0, free: 480561

Obeservation:

  • The “used” is 0 byte!
  • Using ’ mos --port ws://ip/rpc ls chi’, the folder return empty.
  • Using mos put/get command to put some file in the chi folder and read back work ok.

System info:

esp_main.c:174          Mongoose OS 2.16.0 (20191204-145848/2.16.0-g9b779cd)
esp_main.c:178          CPU: ESP8266EX, 160 MHz, RAM: 50720 total, 48084 free
esp_main.c:180          SDK 2.2.1(1247cc5); flash: 4M
esp_exc.c:211           Reset cause: 4 (soft reset)
mg_lwip_ev_mgr.c:93     Mongoose 6.15, LwIP 1.4.1
mg_ssl_if_mbedtls.c:57  mbed TLS 2.16.3-cesanta2
mgos_vfs_dev.c:73       sfl0: sysflash (), size 4194304
mgos_vfs_dev.c:73       root: part ({"dev": "sfl0", "offset": 32768, "size": 262144}), size 262144

Did I miss any steps?