ESP8266 Filesystem upload issues

I’m having some trouble trying to do a filesystem upload for my ESP8266 (nodemcuv2) project that I could use some help with. In particular, I’m seeing that whenever I upload any filesystem image, it is deleting the application firmware. My guess is that that may be somehow related to partitioning, but I’m not quite sure where to look. In addition, attempting to send the filesystem image using OTA always ends up using the serial port anyway. It is almost like it is ignoring the request to use OTA. Again, I’m not quite sure where to look.

Below are my configuration file contents. I can also post the full results of envdump if that would be helpful. Given the size of that output, I didn’t know if I should drop the whole output in here or not. Instead, I just grabbed the version information from the start of the output.

Thanks!
Craig

I’d appreciate any suggestion.

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

; =================================================
; Set the default environment
; =================================================
[platformio]
  default_envs = nodemcuv2_serial
  extra_configs = config.ini
  
; =================================================
; Serial-based non-debug uploads
; =================================================
[env:nodemcuv2_serial]
  platform = espressif8266
  board = nodemcuv2
  framework = arduino
  board_build.filesystem = littlefs

  extra_scripts =
    ./scripts/build_webapp.py
    ./scripts/websocket_serial.py

  lib_deps =
    densaugeo/base64 @ ^1.4.0                             ; https://github.com/Densaugeo/base64_arduino
    crankyoldgit/IRremoteESP8266 @ ^2.8.6                 ; https://github.com/crankyoldgit/IRremoteESP8266
    esphome/AsyncTCP-esphome@^2.1.3                       ; https://github.com/esphome/AsyncTCP
    ; esphome/ESPAsyncWebServer-esphome @ ^3.2.2          ; https://github.com/esphome/ESPAsyncWebServer
    me-no-dev/ESP Async WebServer @ ^1.2.4
    bblanchon/ArduinoJson @ ^6.19.4                       ; https://arduinojson.org/
    ESPAsyncWiFiManager                                   ; https://github.com/alanswx/ESPAsyncWiFiManager
    WiFi

  build_flags =
    -DBUILD_TIMESTAMP=$UNIX_TIME
    -DSENDER
    -DDISABLE_AC_HANDLING
    -DLOG_IR_DECODE
    -DMDNS_NAME='"${wifi.mdns_name}"'
    -DOTA_PASSWORD='"${ota.password}"'
 
  ; Set monitor configuration for Serial requests
  monitor_speed = 115200
  monitor_dtr = 0
  monitor_rts = 0

; =================================================
; Serial-based uploads with GDB setup
; =================================================
[env:nodemcuv2_serial_gdb]
  extends = env:nodemcuv2_serial
  build_type = debug
  build_flags =
    -DBUILD_TIMESTAMP=$UNIX_TIME
    -DGDB_DEBUG

; =================================================
; OTA-based non-debug uploads
; =================================================
[env:nodemcuv2_ota]
  extends = env:nodemcuv2_serial

  upload_protocol = espota
  upload_port = '${ota.port}'
  upload_flags = --auth='${ota.password}'

Processing nodemcuv2_ota (platform: espressif8266; board: nodemcuv2; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html
PLATFORM: Espressif 8266 (4.2.1) > NodeMCU 1.0 (ESP-12E Module)
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 @ 3.30102.0 (3.1.2) 
 - tool-esptool @ 1.413.0 (4.13) 
 - tool-esptoolpy @ 1.30000.201119 (3.0.0) 
 - toolchain-xtensa @ 2.100300.220621 (10.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 44 compatible libraries
Scanning dependencies...
Dependency Graph
|-- base64 @ 1.4.0
|-- IRremoteESP8266 @ 2.8.6
|-- ESP Async WebServer @ 1.2.4
|-- ArduinoJson @ 6.21.5
|-- ESPAsyncWiFiManager @ 0.31.0
|-- WiFi @ 1.2.7
|-- ESP8266WiFi @ 1.0
|-- LittleFS @ 0.1.0
|-- ArduinoOTA @ 1.0
|-- ESP8266mDNS @ 1.2
|-- DNSServer @ 1.1.1
|-- ESPAsyncTCP @ 1.2.2

Can you reproduce the error of a filesystem upload overwriting the firmware in the simplest possible project?

Upload filesystem via OTA should work, too. There is a distinct “Upload Filesystem Image OTA” platform task.

I will see if I can come up with something simple. I’m aware of the separate task and I’ve tried it both via the PlatformIO project tasks as well as programmatically from a extra script. In fact, it was while I was testing my script that I noticed the behavior.

Thanks @maxgerhardt for your thoughts.

At this point, I’m not entirely sure what was happening, but I can’t recreate the behavior anymore. I did find some issues with my custom script that were likely related.

I am seeing a different issue with filesystem upload via OTA that I don’t see via Serial. For OTA, I see:

Uploading .pio/build/nodemcuv2_ota/littlefs.bin
19:58:23 [DEBUG]: Options: {'esp_ip': 'esp8266-7225cf.local', 'host_ip': '0.0.0.0', 'esp_port': 8266, 'host_port': 36033, 'auth': 'xxxx', 'image': '.pio/build/nodemcuv2_ota/littlefs.bin', 'spiffs': False, 'debug': True, 'progress': True}
19:58:23 [INFO]: Starting on 0.0.0.0:36033
19:58:23 [INFO]: Upload size: 1024000
19:58:23 [INFO]: Sending invitation to: esp8266-7225cf.local
19:58:26 [INFO]: Waiting for device...

Uploading: [                                                            ] 0% 
Uploading: [======                                                      ] 10% 
Uploading: [============                                                ] 20% 
Uploading: [==================                                          ] 30% 
Uploading: [========================                                    ] 40% 
Uploading: [==============================                              ] 50% 
Uploading: [====================================                        ] 60% 
Uploading: [==========================================                  ] 70% 
Uploading: [================================================            ] 80% 
Uploading: [======================================================      ] 90% 
Uploading: [============================================================] 100% Done...

19:58:46 [INFO]: Waiting for result...

19:58:46 [ERROR]: 0xE9

*** [uploadfsota] Error 1
===
========================================================================== [FAILED] Took 23.50 seconds 

However, serial is fine:

Configuring flash size...
Compressed 1024000 bytes to 42473...
Writing at 0x00300000... (33 %)
Writing at 0x00304000... (66 %)
Writing at 0x00308000... (100 %)
Wrote 1024000 bytes (42473 compressed) at 0x00300000 in 4.6 seconds (effective 1763.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

A Google search turns up a few similar errors, but not seeing anything that matches my circumstances. Any suggestions?

Thanks,
Craig