From 044486d46ff4b31dda54225e8b35b1c5a22fecad Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 30 Dec 2015 14:14:36 +0200 Subject: [PATCH] Allow to upload SPIFFS image using OTA // Issue #382 --- docs/platforms/espressif_extra.rst | 7 +++++ platformio/__init__.py | 2 +- platformio/builder/scripts/espressif.py | 38 +++++++++++-------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/docs/platforms/espressif_extra.rst b/docs/platforms/espressif_extra.rst index 08168967..3e7649fd 100644 --- a/docs/platforms/espressif_extra.rst +++ b/docs/platforms/espressif_extra.rst @@ -65,10 +65,17 @@ Uploading files to file system SPIFFS 1. Create :ref:`projectconf_pio_data_dir` and put files here 2. Run target ``uploadfs`` via :option:`platformio run --target` command. +To upload SPIFFS image using OTA update please specify ``upload_port`` / +``--upload-port`` as IP address. For the details please follow to +:ref:`platform_espressif_ota`. For example, ``platformio run -t uploadfs +--upload_port 192.168.0.255``. + By default, will be used default LD Script for the board where is specified SPIFFS offsets (start, end, page, block). You can override it using :ref:`platform_espressif_customflash`. +.. _platform_espressif_ota: + Over-the-Air (OTA) update ------------------------- diff --git a/platformio/__init__.py b/platformio/__init__.py index 382a9f6e..a5ce8056 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (2, 7, "0.dev8") +VERSION = (2, 7, "0.dev9") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index ea6cd75c..7f0389a7 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -113,11 +113,6 @@ env.Replace( "-cb", "$UPLOAD_SPEED", "-cp", "$UPLOAD_PORT" ], - UPLOADERFSFLAGS=[ - "$UPLOADERFLAGS", - "$UPLOAD_FLAGS", - "-ca", "$SPIFFS_START" - ], UPLOADEROTAFLAGS=[ "--debug", "--progress", @@ -126,7 +121,6 @@ env.Replace( ], UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -cf $SOURCE', - UPLOADFSCMD='"$UPLOADER" $UPLOADERFSFLAGS -cf $SOURCE', UPLOADOTACMD='"$UPLOADEROTA" $UPLOADEROTAFLAGS -f $SOURCE', # @@ -217,6 +211,13 @@ env.Append( ) ) +if "uploadfs" in COMMAND_LINE_TARGETS: + env.Append( + UPLOADERFLAGS=[ + "-ca", "$SPIFFS_START" + ] + ) + # # Framework and SDK specific configuration # @@ -291,10 +292,15 @@ else: target_elf = env.BuildProgram() # -# Target: Build the .hex +# Target: Build the .hex or SPIFFS image # -if "uploadlazy" in COMMAND_LINE_TARGETS: +if set(["uploadfs", "uploadfsota"]) & set(COMMAND_LINE_TARGETS): + target_firm = env.DataToBin( + join("$BUILD_DIR", "spiffs"), "$PROJECTDATA_DIR") + AlwaysBuild(target_firm) + +elif "uploadlazy" in COMMAND_LINE_TARGETS: if "FRAMEWORK" not in env: target_firm = [ join("$BUILD_DIR", "firmware_00000.bin"), @@ -318,26 +324,14 @@ target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") AlwaysBuild(target_size) # -# Target: Upload firmware +# Target: Upload firmware or SPIFFS image # target_upload = env.Alias( - ["upload", "uploadlazy"], target_firm, + ["upload", "uploadlazy", "uploadfs"], target_firm, [lambda target, source, env: env.AutodetectUploadPort(), "$UPLOADCMD"]) env.AlwaysBuild(target_upload) -# -# Target: Upload SPIFFS image -# - -target_mkspiffs = None -if "uploadfs" in COMMAND_LINE_TARGETS: - target_mkspiffs = env.DataToBin(join("$BUILD_DIR", "spiffs_image"), - "$PROJECTDATA_DIR") -target_uploadfs = env.Alias( - "uploadfs", target_mkspiffs, - [lambda target, source, env: env.AutodetectUploadPort(), "$UPLOADFSCMD"]) -env.AlwaysBuild(target_mkspiffs, target_uploadfs) # # Target: Define targets