From 2c53bd49f287a41be7d0aa54e9797829e436610c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 2 Nov 2015 22:36:49 +0200 Subject: [PATCH] =?UTF-8?q?Upload=20firmware=20using=20external=20programm?= =?UTF-8?q?er=20via=20"platformio=20run=20=E2=80=93target=20program"=20//?= =?UTF-8?q?=20Resolve=20#311?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HISTORY.rst | 3 +++ docs/projectconf.rst | 4 +++- docs/userguide/cmd_run.rst | 5 +++-- platformio/builder/scripts/atmelavr.py | 21 ++++++++++++--------- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index aa9d6867..50a7cea1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,6 +12,9 @@ PlatformIO 2.0 (`issue #309 `_) * Added support for Espressif ESP8266 ESP-12E board (NodeMCU) (`issue #310 `_) +* Upload firmware using external programmer via `platformio run --target program `__ + target + (`issue #311 `_) * Fixed handling of upload port when ``board`` option is not specified in `platformio.ini `__ (`issue #313 `_) diff --git a/docs/projectconf.rst b/docs/projectconf.rst index da5fb058..8d44c860 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -504,7 +504,9 @@ Examples platform = atmelavr framework = arduino board = pro8MHzatmega328 - upload_protocol = usbasp - B5 + upload_protocol = usbasp -B5 + +Then upload firmware using :option:`platformio run --target program` 4. :ref:`platform_ststm32`: Upload firmware using GDB script ``upload.gdb``, diff --git a/docs/userguide/cmd_run.rst b/docs/userguide/cmd_run.rst index d1a52aa7..5d4d8baa 100644 --- a/docs/userguide/cmd_run.rst +++ b/docs/userguide/cmd_run.rst @@ -38,8 +38,9 @@ Process specified targets. Pre-built targets: * ``clean`` delete compiled object files, libraries and firmware/program binaries -* ``upload`` enable "auto-uploading" for embedded platforms after building - operation +* ``upload`` firmware "auto-uploading" for embedded platforms +* ``program`` firmware "auto-uploading" for embedded platforms using external + programmer (available only for :ref:`platform_atmelavr`) * ``uploadlazy`` upload existing firmware without project rebuilding * ``envdump`` dump current build environment * ``size`` print the size of the sections in a firmware/program diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index 604e9b70..7e3bba2c 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -26,10 +26,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 env.Replace(UPLOAD_SPEED=None) if env.subst("$UPLOAD_SPEED"): - env.Append(UPLOADERFLAGS=[ - "-b", "$UPLOAD_SPEED", - "-D" - ]) + env.Append(UPLOADERFLAGS=["-b", "$UPLOAD_SPEED"]) if upload_options and not upload_options.get("require_upload_port", False): return @@ -87,9 +84,9 @@ else: '"%s"' % join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude.conf"), "-c", "$UPLOAD_PROTOCOL" ], - - UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i', - UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i' + UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -D -U flash:w:$SOURCES:i', + UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i', + PROGRAMHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i' ) # @@ -133,10 +130,16 @@ AlwaysBuild(upload) # Target: Upload .eep file # -uploadeep = env.Alias("uploadeep", target_eep, [ - BeforeUpload, "$UPLOADEEPCMD"]) +uploadeep = env.Alias("uploadeep", target_eep, [BeforeUpload, "$UPLOADEEPCMD"]) AlwaysBuild(uploadeep) +# +# Target: Upload firmware using external programmer +# + +program = env.Alias("program", target_firm, [BeforeUpload, "$PROGRAMHEXCMD"]) +AlwaysBuild(program) + # # Setup default targets #