Added "upload_resetmethod" option to Project Configuration File platformio.ini and allowed to change default upload reset method for Espressif development platform // Resolve #444

This commit is contained in:
Ivan Kravets
2016-01-14 01:07:57 +02:00
parent 1b85a3ddd3
commit 52ceb64758
7 changed files with 45 additions and 48 deletions

View File

@ -9,7 +9,8 @@ PlatformIO 2.0
* Added SPL-Framework support for Nucleo F401RE board
(`issue #453 <https://github.com/platformio/platformio/issues/453>`_)
* Explained in documentation how to `overwrite upload reset method <http://docs.platformio.org/en/latest/platforms/espressif.html#custom-reset-method>`_
* Added ``upload_resetmethod`` option to `Project Configuration File platformio.ini <http://docs.platformio.org/en/latest/projectconf.html>`__
and allowed to `change default upload reset method <http://docs.platformio.org/en/latest/platforms/espressif.html#custom-reset-method>`_
for Espressif development platform
(`issue #444 <https://github.com/platformio/platformio/issues/444>`_)
* Fixed builder for mbed framework and ST STM32 platform

View File

@ -23,6 +23,19 @@ from :ref:`projectconf`
upload_speed = 9600
Custom Reset Method
-------------------
See :ref:`projectconf_upload_resetmethod` option from :ref:`projectconf`
.. code-block:: ini
[env:esp12e]
platform = espressif
framework = arduino
board = esp12e
upload_resetmethod = ck
.. _platform_espressif_customflash:
Custom Flash Size
@ -53,34 +66,6 @@ To override default LD script please use :ref:`projectconf_build_flags` from
[env:myenv]
build_flags = -Wl,-Tesp8266.flash.4m.ld
Custom Reset Method
-------------------
To overwrite predefined reset method for uploading please use :ref:`projectconf_extra_script`.
For example, default reset method for ``esp12e`` board is ``nodemcu``. Let's
overwrite it to ``ck``:
* :ref:`projectconf`
.. code-block:: ini
[env:esp12e]
platform = espressif
framework = arduino
board = esp12e
extra_script = extra_script.py
* ``extra_script.py`` should be located on the same level as :ref:`projectconf`
.. code-block:: python
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
env['BOARD_OPTIONS']['upload']['resetmethod'] = 'ck'
.. _platform_espressif_uploadfs:
Uploading files to file system SPIFFS

View File

@ -445,6 +445,13 @@ which "uploader" tool uses when sending firmware to board.
Extra flags for uploader. Will be added to the end of uploader command. If you
need to override uploader command or base flags please use :ref:`projectconf_extra_script`.
.. _projectconf_upload_resetmethod:
``upload_resetmethod``
^^^^^^^^^^^^^^^^^^^^^^
Specify reset method for "uploader" tool. This option isn't available for all
development platforms. The only :ref:`platform_espressif` supports it.
Library options
~~~~~~~~~~~~~~~

View File

@ -14,7 +14,7 @@
import sys
VERSION = (2, 7, "2.dev0")
VERSION = (2, 7, "2.dev1")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@ -56,7 +56,8 @@ commonvars.AddVariables(
("UPLOAD_PORT",),
("UPLOAD_PROTOCOL",),
("UPLOAD_SPEED",),
("UPLOAD_FLAGS",)
("UPLOAD_FLAGS",),
("UPLOAD_RESETMETHOD",)
)
DefaultEnvironment(
@ -103,16 +104,16 @@ if "BOARD" in env:
except UnknownBoard as e:
env.Exit("Error: %s" % str(e))
if "BOARD_MCU" not in env:
env.Replace(BOARD_MCU="${BOARD_OPTIONS['build']['mcu']}")
if "BOARD_F_CPU" not in env:
env.Replace(BOARD_F_CPU="${BOARD_OPTIONS['build']['f_cpu']}")
if "UPLOAD_PROTOCOL" not in env:
env.Replace(
UPLOAD_PROTOCOL="${BOARD_OPTIONS['upload'].get('protocol', None)}")
if "UPLOAD_SPEED" not in env:
env.Replace(
UPLOAD_SPEED="${BOARD_OPTIONS['upload'].get('speed', None)}")
for k in commonvars.keys():
if (k in env or
not any([k.startswith("BOARD_"), k.startswith("UPLOAD_")])):
continue
_opt, _val = k.lower().split("_", 1)
if _opt == "board":
_opt = "build"
if _val in env['BOARD_OPTIONS'][_opt]:
env.Replace(**{k: "${BOARD_OPTIONS['%s']['%s']}" % (_opt, _val)})
if "ldscript" in env.get("BOARD_OPTIONS", {}).get("build", {}):
env.Replace(
LDSCRIPT_PATH="${BOARD_OPTIONS['build']['ldscript']}"

View File

@ -108,7 +108,7 @@ env.Replace(
UPLOADERFLAGS=[
"-vv",
"-cd", "${BOARD_OPTIONS['upload']['resetmethod']}",
"-cd", "$UPLOAD_RESETMETHOD",
"-cb", "$UPLOAD_SPEED",
"-cp", "$UPLOAD_PORT"
],

View File

@ -302,12 +302,15 @@ def on_exception(e):
def _finalize():
timeout = 1000 # msec
elapsed = 0
while elapsed < timeout:
if not MPDataPusher().in_wait():
break
sleep(0.2)
elapsed += 200
backup_reports(MPDataPusher().get_items())
try:
while elapsed < timeout:
if not MPDataPusher().in_wait():
break
sleep(0.2)
elapsed += 200
backup_reports(MPDataPusher().get_items())
except KeyboardInterrupt:
pass
def backup_reports(items):