From 61ef27c345842cccc16d51581e8a98388bab64fe Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 10 Sep 2015 16:43:09 +0300 Subject: [PATCH] Allow to use ST-Link uploader for mbed-based projects --- HISTORY.rst | 1 + docs/projectconf.rst | 81 +++++---------------------- platformio/__init__.py | 2 +- platformio/builder/scripts/ststm32.py | 10 ++-- 4 files changed, 23 insertions(+), 71 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 6572ee96..378e03bc 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,7 @@ PlatformIO 2.0 2.3.2 (2015-09-??) ~~~~~~~~~~~~~~~~~~ +* Allowed to use ST-Link uploader for mbed-based projects * Fixed `SConsNotInstalled` error for Linux Debian-based distributives 2.3.1 (2015-09-06) diff --git a/docs/projectconf.rst b/docs/projectconf.rst index a3641e5c..da5fb058 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -475,39 +475,7 @@ Examples targets = upload -2. :ref:`platform_atmelavr`: Microduino Core (ATmega168P, 3.3V) board with - auto pre-configured ``board_*`` and ``upload_*`` options (use only - ``board`` option) and Arduino Wiring-based Framework - -.. code-block:: ini - - [env:atmelavr_microduino_core_board] - platform = atmelavr - framework = arduino - board = 168pa8m - - # enable auto-uploading - targets = upload - - -3. :ref:`platform_atmelavr`: Raspduino board with - auto pre-configured ``board_*`` and ``upload_*`` options (use only - ``board`` option) and Arduino Wiring-based Framework - -.. code-block:: ini - - [env:atmelavr_raspduino_board] - platform = atmelavr - framework = arduino - board = raspduino - - upload_port = /dev/ttyS0 - - # enable auto-uploading - targets = upload - - -4. :ref:`platform_atmelavr`: Embedded board that is based on ATmega168 MCU with +2. :ref:`platform_atmelavr`: Embedded board that is based on ATmega168 MCU with "arduino" bootloader .. code-block:: ini @@ -527,7 +495,7 @@ Examples targets = upload -5. Upload firmware via USB programmer (USBasp) to :ref:`platform_atmelavr` +3. Upload firmware via USB programmer (USBasp) to :ref:`platform_atmelavr` microcontrollers .. code-block:: ini @@ -536,44 +504,25 @@ Examples platform = atmelavr framework = arduino board = pro8MHzatmega328 - upload_protocol = usbasp -B5 + upload_protocol = usbasp - B5 -6. :ref:`platform_timsp430`: TI MSP430G2553 LaunchPad with auto pre-configured - ``board_*`` and ``upload_*`` options (use only ``board`` option) and Energia - Wiring-based Framework +4. :ref:`platform_ststm32`: Upload firmware using GDB script ``upload.gdb``, + `issue #175 `_ .. code-block:: ini - [env:timsp430_g2553_launchpad] - platform = timsp430 - framework = energia - board = lpmsp430g2553 + [env:st_via_gdb] + platform = ststm32 + board = armstrap_eagle512 + upload_protocol = gdb - -7. :ref:`platform_timsp430`: Embedded board that is based on MSP430G2553 MCU +5. :ref:`platform_ststm32`: Upload firmware using ST-Link instead mbed's media + disk .. code-block:: ini - [env:timsp430_g2553_board] - platform = timsp430 - board_mcu = msp430g2553 - board_f_cpu = 16000000L - - upload_protocol = rf2500 - - # enable auto-uploading - targets = upload - - -8. :ref:`platform_titiva`: TI Tiva C ARM Series TM4C123G LaunchPad with auto - pre-configured ``board_*`` and ``upload_*`` options (use only ``board`` - option) and Energia Wiring-based Framework - -.. code-block:: ini - - [env:titiva_tm4c1230c3pm_launchpad] - platform = titiva - framework = energia - board = lptm4c1230c3pm - + [env:stlink_for_mbed] + platform = ststm32 + board = disco_f100rb + upload_protocol = stlink diff --git a/platformio/__init__.py b/platformio/__init__.py index 8be279ed..9a611cc9 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 3, "2.dev1") +VERSION = (2, 3, "2.dev2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/scripts/ststm32.py b/platformio/builder/scripts/ststm32.py index aeff2818..cc0adfe6 100644 --- a/platformio/builder/scripts/ststm32.py +++ b/platformio/builder/scripts/ststm32.py @@ -15,7 +15,7 @@ env = DefaultEnvironment() SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) -if env['UPLOAD_PROTOCOL'] == "gdb": +if env.get("UPLOAD_PROTOCOL") == "gdb": if not isfile(join(env.subst("$PROJECT_DIR"), "upload.gdb")): Exit( "You are using GDB as firmware uploader. " @@ -50,7 +50,8 @@ else: env.Append( CPPDEFINES=[ - "${BOARD_OPTIONS['build']['variant'].upper()}" + env.get("BOARD_OPTIONS", {}).get( + "build", {}).get("variant", "").upper() ], LIBS=["stdc++", "nosys"], @@ -87,8 +88,9 @@ AlwaysBuild(target_size) # Target: Upload by default .bin file # -disable_msd = (platform.system() == "Darwin" and - platform.release().startswith("14.")) +disable_msd = ( + (platform.system() == "Darwin" and platform.release().startswith("14.")) or + "UPLOAD_PROTOCOL" in env) if "mbed" in env.subst("$FRAMEWORK") and not disable_msd: upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk)