Merge branch 'release/v1.1.0'

This commit is contained in:
Ivan Kravets
2015-03-05 15:05:40 +02:00
28 changed files with 666 additions and 197 deletions

View File

@@ -1,7 +1,25 @@
Release History Release History
=============== ===============
1.0.0 (2015-02-27) 1.1.0 (2015-03-05)
------------------
* Implemented ``PLATFORMIO_*`` environment variables
(`issue #102 <https://github.com/ivankravets/platformio/issues/102>`_)
* Added support for *SainSmart* boards to
`atmelsam <http://docs.platformio.org/en/latest/platforms/atmelsam.html#boards>`__
development platform
* Added
`Project Configuration <http://docs.platformio.org/en/latest/projectconf.html>`__
option named `envs_dir <http://docs.platformio.org/en/latest/projectconf.html#envs-dir>`__
* Disabled "prompts" automatically for *Continuous Integration* systems
(`issue #103 <https://github.com/ivankravets/platformio/issues/103>`_)
* Fixed firmware uploading for
`atmelavr <http://docs.platformio.org/en/latest/platforms/atmelavr.html#boards>`__
boards which work within ``usbtiny`` protocol
* Fixed uploading for *Digispark* board (`issue #106 <https://github.com/ivankravets/platformio/issues/106>`_)
1.0.1 (2015-02-27)
------------------ ------------------
**PlatformIO 1.0 - recommended for production** **PlatformIO 1.0 - recommended for production**
@@ -219,7 +237,7 @@ Release History
`srcbuild_flags <http://docs.platformio.org/en/latest/projectconf.html#srcbuild-flags>`_ `srcbuild_flags <http://docs.platformio.org/en/latest/projectconf.html#srcbuild-flags>`_
environment option environment option
* Allowed to override some of settings via system environment variables * Allowed to override some of settings via system environment variables
such as: ``$PIOSRCBUILD_FLAGS`` and ``$PIOENVS_DIR`` such as: ``PLATFORMIO_SRCBUILD_FLAGS`` and ``PLATFORMIO_ENVS_DIR``
* Added ``--upload-port`` option for `platformio run <http://docs.platformio.org/en/latest/userguide/cmd_run.html#cmdoption--upload-port>`__ command * Added ``--upload-port`` option for `platformio run <http://docs.platformio.org/en/latest/userguide/cmd_run.html#cmdoption--upload-port>`__ command
* Implemented (especially for `SmartAnthill <http://docs.smartanthill.ikravets.com/>`_) * Implemented (especially for `SmartAnthill <http://docs.smartanthill.ikravets.com/>`_)
`platformio run -t uploadlazy <http://docs.platformio.org/en/latest/userguide/cmd_run.html>`_ `platformio run -t uploadlazy <http://docs.platformio.org/en/latest/userguide/cmd_run.html>`_

120
docs/envvars.rst Normal file
View File

@@ -0,0 +1,120 @@
.. _envvars:
Environment variables
=====================
`Environment variables <http://en.wikipedia.org/wiki/Environment_variable>`_
are a set of dynamic named values that can affect the way running processes
will behave on a computer.
*PlatformIO* handles variables which start with ``PLATFORMIO_`` prefix. They
have the **HIGHEST PRIORITY**.
.. contents::
General
-------
PlatformIO uses *General* environment variables for the common
operations/commands.
.. _envvar_CI:
CI
~~
PlatformIO handles ``CI`` variable which is setup by
`Continuous Integration <http://en.wikipedia.org/wiki/Continuous_integration>`_
(Travis, Circle and etc.) systems.
Currently, PlatformIO uses it to disable prompts.
In other words, ``CI=true`` automatically setup
:ref:`PLATFORMIO_SETTING_ENABLE_PROMPTS=false <envvar_PLATFORMIO_SETTING_ENABLE_PROMPTS>`.
.. _envvar_PLATFORMIO_HOME_DIR:
PLATFORMIO_HOME_DIR
~~~~~~~~~~~~~~~~~~~
Allows to override :ref:`projectconf` option
:ref:`projectconf_pio_home_dir`.
.. _envvar_PLATFORMIO_LIB_DIR:
PLATFORMIO_LIB_DIR
~~~~~~~~~~~~~~~~~~
Allows to override :ref:`projectconf` option
:ref:`projectconf_pio_lib_dir`.
.. _envvar_PLATFORMIO_SRC_DIR:
PLATFORMIO_SRC_DIR
~~~~~~~~~~~~~~~~~~
Allows to override :ref:`projectconf` option
:ref:`projectconf_pio_src_dir`.
.. _envvar_PLATFORMIO_ENVS_DIR:
PLATFORMIO_ENVS_DIR
~~~~~~~~~~~~~~~~~~~
Allows to override :ref:`projectconf` option
:ref:`projectconf_pio_envs_dir`.
Builder
-------
.. _envvar_PLATFORMIO_SRCBUILD_FLAGS:
PLATFORMIO_SRCBUILD_FLAGS
~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to override :ref:`projectconf` option
:ref:`projectconf_srcbuild_flags`.
Settings
--------
Allows to override PlatformIO settings. You can manage them via
:ref:`cmd_settings` command.
PLATFORMIO_SETTING_AUTO_UPDATE_LIBRARIES
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to override setting :option:`auto_update_libraries`.
PLATFORMIO_SETTING_AUTO_UPDATE_PLATFORMS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to override setting :option:`auto_update_platforms`.
PLATFORMIO_SETTING_CHECK_LIBRARIES_INTERVAL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to override setting :option:`check_libraries_interval`.
PLATFORMIO_SETTING_CHECK_PLATFORMIO_INTERVAL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to override setting :option:`check_platformio_interval`.
PLATFORMIO_SETTING_CHECK_PLATFORMS_INTERVAL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to override setting :option:`check_platforms_interval`.
.. _envvar_PLATFORMIO_SETTING_ENABLE_PROMPTS:
PLATFORMIO_SETTING_ENABLE_PROMPTS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to override setting :option:`enable_prompts`.
PLATFORMIO_SETTING_ENABLE_TELEMETRY
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to override setting :option:`enable_telemetry`.

View File

@@ -57,6 +57,7 @@ Contents
quickstart quickstart
installation installation
projectconf projectconf
envvars
platforms/index platforms/index
librarymanager/index librarymanager/index
userguide/index userguide/index

View File

@@ -30,9 +30,14 @@ application:
application. application.
.. warning:: .. warning::
If you are going to use *PlatformIO* for "*Cloud Compiling*", please If you are going to run *PlatformIO* from **subprocess**, you **MUST
don't forget to turn off :ref:`enable_prompts <cmd_settings>` setting. It DISABLE** all prompts. It will allow you to avoid blocking.
will allow you to avoid blocking when call ``platformio`` like subprocess. There are a few options:
- using environment variable :ref:`PLATFORMIO_SETTING_ENABLE_PROMPTS=No <envvar_PLATFORMIO_SETTING_ENABLE_PROMPTS>`
- disable global setting ``enable_prompts`` via :ref:`cmd_settings` command
- masking under Continuous Integration system via environment variable
:ref:`CI=true <envvar_CI>`.
Please *choose one of* the following: Please *choose one of* the following:

View File

@@ -70,7 +70,13 @@ Boards
- Flash - Flash
- RAM - RAM
* - ``due`` * - ``due``
- `Arduino Due <http://arduino.cc/en/Main/arduinoBoardDue>`_ - `Arduino Due (Programming Port) <http://arduino.cc/en/Main/arduinoBoardDue>`_
- at91sam3x8e ``cortex-m3``
- 84 MHz ``84000000L``
- 512 Kb
- 32 Kb
* - ``dueUSB``
- `Arduino Due (USB Native Port) <http://arduino.cc/en/Main/arduinoBoardDue>`_
- at91sam3x8e ``cortex-m3`` - at91sam3x8e ``cortex-m3``
- 84 MHz ``84000000L`` - 84 MHz ``84000000L``
- 512 Kb - 512 Kb
@@ -81,6 +87,18 @@ Boards
- 84 MHz ``84000000L`` - 84 MHz ``84000000L``
- 512 kb - 512 kb
- 32 Kb - 32 Kb
* - ``sainSmartDue``
- `SainSmart Due (Programming Port) <http://www.sainsmart.com/arduino/control-boards/sainsmart-due-atmel-sam3x8e-arm-cortex-m3-board-black.html>`_
- at91sam3x8e ``cortex-m3``
- 84 MHz ``84000000L``
- 512 Kb
- 32 Kb
* - ``sainSmartDueUSB``
- `SainSmart Due (USB Native Port) <http://www.sainsmart.com/arduino/control-boards/sainsmart-due-atmel-sam3x8e-arm-cortex-m3-board-black.html>`_
- at91sam3x8e ``cortex-m3``
- 84 MHz ``84000000L``
- 512 Kb
- 32 Kb
More detailed information you can find here More detailed information you can find here
`Atmel SMART ARM-based MCUs <http://www.atmel.com/products/microcontrollers/arm/default.aspx>`_. `Atmel SMART ARM-based MCUs <http://www.atmel.com/products/microcontrollers/arm/default.aspx>`_.

View File

@@ -17,7 +17,7 @@ MCU, upload protocol or etc. Please use ``board`` option.
atmelavr atmelavr
atmelsam atmelsam
stm32 stm32
teensy
timsp430 timsp430
titiva titiva
teensy
creating_platform creating_platform

View File

@@ -1,7 +1,7 @@
.. _projectconf: .. _projectconf:
Project Configuration File Project Configuration File ``platformio.ini``
========================== =============================================
The Project configuration file is named ``platformio.ini``. This is a The Project configuration file is named ``platformio.ini``. This is a
`INI-style <http://en.wikipedia.org/wiki/INI_file>`_ file. `INI-style <http://en.wikipedia.org/wiki/INI_file>`_ file.
@@ -33,11 +33,18 @@ Options
``home_dir`` ``home_dir``
^^^^^^^^^^^^ ^^^^^^^^^^^^
A ``$PIO_HOME_DIR`` is used to store platform tool chains, frameworks, Is used to store platform tool chains, frameworks, external libraries,
external libraries, service data and etc. service data and etc.
A default value is user's home directory: *Unix* - ``~/.platformio``, A default value is User's home directory:
Windows - ``%HOMEPATH%\.platformio``.
* Unix ``~/.platformio``
* Windows ``%HOMEPATH%\.platformio``
This option can be overridden by global environment variable
:ref:`envvar_PLATFORMIO_HOME_DIR`.
.. _projectconf_pio_lib_dir:
``lib_dir`` ``lib_dir``
^^^^^^^^^^^ ^^^^^^^^^^^
@@ -45,21 +52,53 @@ Windows - ``%HOMEPATH%\.platformio``.
This directory is used to store external libraries downloaded by This directory is used to store external libraries downloaded by
:ref:`librarymanager`. :ref:`librarymanager`.
A default value is ``$PIO_HOME_DIR/lib``. A default value is ``%home_dir%/lib``.
This option can be overridden by global environment variable
:ref:`envvar_PLATFORMIO_LIB_DIR`.
.. _projectconf_pio_src_dir:
``src_dir`` ``src_dir``
^^^^^^^^^^^ ^^^^^^^^^^^
The path to project's source directory. PlatformIO uses it for :ref:`cmd_run` A path to project's source directory. PlatformIO uses it for :ref:`cmd_run`
command. command.
A default value is ``$PROJECT_DIR/src``. A default value is ``%project_dir%/src``.
This option can be overridden by global environment variable
:ref:`envvar_PLATFORMIO_SRC_DIR`.
.. note:: .. note::
This option is useful for people who migrate from Arduino/Energia IDEs where This option is useful for people who migrate from Arduino/Energia IDEs where
source directory should have the same name like the main source file. source directory should have the same name like the main source file.
See `example <https://github.com/ivankravets/platformio/tree/develop/examples/atmelavr-and-arduino/arduino-own-src_dir>`__ project with own source directory. See `example <https://github.com/ivankravets/platformio/tree/develop/examples/atmelavr-and-arduino/arduino-own-src_dir>`__ project with own source directory.
.. _projectconf_pio_envs_dir:
``envs_dir``
^^^^^^^^^^^^
*PlatformIO Builder* within :ref:`cmd_run` command uses this folder for project
environments to store compiled object files, static libraries, firmwares and
other cached information. It allows PlatformIO to build source code extremely
fast!
*You can delete this folder without any risk!* If you modify :ref:`projectconf`,
then PlatformIO will remove this folder automatically. It will be created on the
next build operation.
A default value is ``%project_dir%/.pioenvs``.
This option can be overridden by global environment variable
:ref:`envvar_PLATFORMIO_ENVS_DIR`.
.. note::
If you have any problems with building your Project environmets which
are defined in :ref:`projectconf`, then **TRY TO DELETE** this folder. In
this situation you will remove all cached files without any risk.
[env:NAME] [env:NAME]
---------- ----------
@@ -99,7 +138,7 @@ See ``framework`` type in *Frameworks* section of :ref:`platforms`
``board`` ``board``
^^^^^^^^^ ^^^^^^^^^
*PlatformIO* has pre-configured settings for most popular boards. You don't *PlatformIO* has pre-configured settings for the most popular boards. You don't
need to specify ``board_mcu``, ``board_f_cpu``, ``upload_protocol`` or need to specify ``board_mcu``, ``board_f_cpu``, ``upload_protocol`` or
``upload_speed`` options. Just define a ``board`` type and *PlatformIO* will ``upload_speed`` options. Just define a ``board`` type and *PlatformIO* will
pre-fill options described above with appropriate values. pre-fill options described above with appropriate values.
@@ -115,8 +154,8 @@ recognize MCU architecture. The correct type of ``board_mcu`` depends on
platform library. For example, the list of ``board_mcu`` for "megaAVR Devices" platform library. For example, the list of ``board_mcu`` for "megaAVR Devices"
is described `here <http://www.nongnu.org/avr-libc/user-manual/>`_. is described `here <http://www.nongnu.org/avr-libc/user-manual/>`_.
The full list of ``board_mcu`` for popular embedded platforms you can find in The full list of ``board_mcu`` for the popular embedded platforms you can find
*Boards* section of :ref:`platforms`. See "Microcontroller" column. in *Boards* section of :ref:`platforms`. See "Microcontroller" column.
``board_f_cpu`` ``board_f_cpu``
@@ -126,21 +165,21 @@ An option ``board_f_cpu`` is used to define MCU frequency (Hertz, Clock). A
format of this option is ``C-like long integer`` value with ``L`` suffix. The format of this option is ``C-like long integer`` value with ``L`` suffix. The
1 Hertz is equal to ``1L``, then 16 Mhz (Mega Hertz) is equal to ``16000000L``. 1 Hertz is equal to ``1L``, then 16 Mhz (Mega Hertz) is equal to ``16000000L``.
The full list of ``board_f_cpu`` for popular embedded platforms you can find in The full list of ``board_f_cpu`` for the popular embedded platforms you can
*Boards* section of :ref:`platforms`. See "Frequency" column. find in *Boards* section of :ref:`platforms`. See "Frequency" column.
``upload_port`` ``upload_port``
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
This option is used by "uploader" tool to send firmware to the board via This option is used by "uploader" tool when sending firmware to board via
``upload_port``. For example, ``upload_port``. For example,
* ``/dev/ttyUSB0`` - Unix-based OS * ``/dev/ttyUSB0`` - Unix-based OS
* ``COM3`` - Windows OS * ``COM3`` - Windows OS
If ``upload_port`` isn't specified, then *PlatformIO* will try to detect If ``upload_port`` isn't specified, then *PlatformIO* will try to detect it
``upload_port`` automatically. automatically.
To print all available serial ports use :ref:`cmd_serialports` command. To print all available serial ports use :ref:`cmd_serialports` command.
@@ -155,7 +194,7 @@ A protocol that "uploader" tool uses to talk to the board.
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
A connection speed (`baud rate <http://en.wikipedia.org/wiki/Baud>`_) A connection speed (`baud rate <http://en.wikipedia.org/wiki/Baud>`_)
which "uploader" tool uses when sending firmware to the board. which "uploader" tool uses when sending firmware to board.
``targets`` ``targets``
@@ -256,12 +295,17 @@ For more detailed information about available flags/options go to:
* `Options for Directory Search * `Options for Directory Search
<https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html>`_ <https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html>`_
.. _projectconf_srcbuild_flags:
``srcbuild_flags`` ``srcbuild_flags``
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
This is option ``srcbuild_flags`` has the same behaviour like ``build_flags`` An option ``srcbuild_flags`` has the same behaviour like ``build_flags``
but will be applied only for project source code from ``src`` directory. but will be applied only for the project source code from
:ref:`projectconf_pio_src_dir` directory.
This option can be overridden by global environment variable
:ref:`envvar_PLATFORMIO_SRCBUILD_FLAGS`.
``ignore_libs`` ``ignore_libs``
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
@@ -281,6 +325,10 @@ Example:
Examples Examples
-------- --------
.. note::
A full list with project examples can be found in
`PlatformIO Repository <https://github.com/ivankravets/platformio/tree/develop/examples>`_.
1. :ref:`platform_atmelavr`: Arduino UNO board with auto pre-configured 1. :ref:`platform_atmelavr`: Arduino UNO board with auto pre-configured
``board_*`` and ``upload_*`` options (use only ``board`` option) and Arduino ``board_*`` and ``upload_*`` options (use only ``board`` option) and Arduino
Wiring-based Framework Wiring-based Framework

View File

@@ -58,8 +58,7 @@ Change working directory to the project's root where is located
If you don't have installed required platforms, then *PlatformIO* will propose If you don't have installed required platforms, then *PlatformIO* will propose
you to install them automatically. you to install them automatically.
Further examples can be found in the ``examples/`` directory in the source Further examples can be found in `PlatformIO Repository <https://github.com/ivankravets/platformio/tree/develop/examples>`_.
distribution or `on the web <https://github.com/ivankravets/platformio/tree/develop/examples>`_.
Also, for more detailed information as for commands please go to Also, for more detailed information as for commands please go to
:ref:`userguide` sections. :ref:`userguide` sections.

View File

@@ -23,6 +23,72 @@ Description
Get/List existing settings Get/List existing settings
Options
~~~~~~~
.. option:: auto_update_libraries
:Default: Yes
:Values: Yes/No
Automatically update libraries.
.. option:: auto_update_platforms
:Default: Yes
:Values: Yes/No
Automatically update platforms.
.. option:: check_libraries_interval
:Default: 7
:Values: Days (Number)
Check for the library updates interval.
.. option:: check_platformio_interval
:Default: 3
:Values: Days (Number)
Check for the new PlatformIO interval.
.. option:: check_platforms_interval
:Default: 7
:Values: Days (Number)
Check for the platform updates interval.
.. option:: enable_prompts
:Default: Yes
:Values: Yes/No
Can PlatformIO communicate with you via prompts?
* propose to install platforms which aren't installed yet
* paginate over library search results
* and etc.
.. warning::
If you are going to run *PlatformIO* from **subprocess**, you **MUST
DISABLE** all prompts. It will allow you to avoid blocking.
.. option:: enable_telemetry
:Default: Yes
:Values: Yes/No
Shares commands, platforms and libraries usage to help us make PlatformIO
better.
.. note::
* The ``Yes`` value is equl to: ``True``, ``Y``, ``1``.
The value is not case sensetive.
* You can override these settings using :ref:`envvars`.
Examples Examples
~~~~~~~~ ~~~~~~~~

View File

@@ -32,10 +32,10 @@ platform = atmelavr
framework = arduino framework = arduino
board = leonardo board = leonardo
[env:arduino_pro16MHzatmega168] [env:arduino_pro16MHzatmega328]
platform = atmelavr platform = atmelavr
framework = arduino framework = arduino
board = pro16MHzatmega168 board = pro16MHzatmega328
[env:arduino_megaatmega1280] [env:arduino_megaatmega1280]
platform = atmelavr platform = atmelavr

View File

@@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com> # Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details. # See LICENSE for details.
VERSION = (1, 0, 0) VERSION = (1, 1, 0)
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio" __title__ = "platformio"

View File

@@ -2,6 +2,7 @@
# See LICENSE for details. # See LICENSE for details.
import json import json
from os import environ, getenv
from os.path import isfile, join from os.path import isfile, join
from platformio import __version__ from platformio import __version__
@@ -71,6 +72,24 @@ class State(object):
json.dump(self._state, fp) json.dump(self._state, fp)
def sanitize_setting(name, value):
if name not in DEFAULT_SETTINGS:
raise InvalidSettingName(name)
defdata = DEFAULT_SETTINGS[name]
try:
if "validator" in defdata:
value = defdata['validator']()
elif isinstance(defdata['value'], bool):
if not isinstance(value, bool):
value = str(value).lower() in ("true", "yes", "y", "1")
elif isinstance(defdata['value'], int):
value = int(value)
except Exception:
raise InvalidSettingValue(value, name)
return value
def get_state_item(name, default=None): def get_state_item(name, default=None):
with State() as data: with State() as data:
return data.get(name, default) return data.get(name, default)
@@ -82,8 +101,13 @@ def set_state_item(name, value):
def get_setting(name): def get_setting(name):
if name not in DEFAULT_SETTINGS: # disable prompts for Continuous Integration systems
raise InvalidSettingName(name) if name == "enable_prompts" and getenv("CI", "").lower() == "true":
return False
_env_name = "PLATFORMIO_SETTING_%s" % name.upper()
if _env_name in environ:
return sanitize_setting(name, getenv(_env_name))
with State() as data: with State() as data:
if "settings" in data and name in data['settings']: if "settings" in data and name in data['settings']:
@@ -93,25 +117,10 @@ def get_setting(name):
def set_setting(name, value): def set_setting(name, value):
if name not in DEFAULT_SETTINGS:
raise InvalidSettingName(name)
defdata = DEFAULT_SETTINGS[name]
try:
if "validator" in defdata:
value = defdata['validator']()
elif isinstance(defdata['value'], bool):
if not isinstance(value, bool):
value = str(value).lower() in ("yes", "y", "1")
elif isinstance(defdata['value'], int):
value = int(value)
except Exception:
raise InvalidSettingValue(value, name)
with State() as data: with State() as data:
if "settings" not in data: if "settings" not in data:
data['settings'] = {} data['settings'] = {}
data['settings'][name] = value data['settings'][name] = sanitize_setting(name, value)
def reset_settings(): def reset_settings():

View File

@@ -18,6 +18,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": false "wait_for_upload_port": false
@@ -55,8 +56,8 @@
"platform": "atmelavr", "platform": "atmelavr",
"upload": { "upload": {
"maximum_ram_size": 512, "maximum_ram_size": 512,
"protocol": "usbtiny", "maximum_size": 8192,
"maximum_size": 8192 "protocol": "usbtiny"
} }
}, },
@@ -74,8 +75,7 @@
"upload": { "upload": {
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "usbtiny", "protocol": "usbtiny"
"speed": 115200
} }
}, },
@@ -93,8 +93,7 @@
"upload": { "upload": {
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "usbtiny", "protocol": "usbtiny"
"speed": 115200
} }
}, },
"protrinket3ftdi": { "protrinket3ftdi": {
@@ -112,6 +111,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
}, },
@@ -130,6 +130,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
} }

View File

@@ -18,6 +18,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true
@@ -38,6 +39,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 14336, "maximum_size": 14336,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 19200 "speed": 19200
} }
}, },
@@ -56,6 +58,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 7168, "maximum_size": 7168,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 19200 "speed": 19200
} }
}, },
@@ -75,6 +78,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 14336, "maximum_size": 14336,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 19200 "speed": 19200
} }
}, },
@@ -94,6 +98,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 19200 "speed": 19200
} }
}, },
@@ -112,6 +117,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 14336, "maximum_size": 14336,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 19200 "speed": 19200
} }
}, },
@@ -130,6 +136,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 30720, "maximum_size": 30720,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
}, },
@@ -152,6 +159,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true
@@ -172,6 +180,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 32256, "maximum_size": 32256,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
}, },
@@ -190,6 +199,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 30720, "maximum_size": 30720,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
}, },
@@ -212,6 +222,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true
@@ -232,6 +243,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 14336, "maximum_size": 14336,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 19200 "speed": 19200
} }
}, },
@@ -250,6 +262,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 30720, "maximum_size": 30720,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
}, },
@@ -268,6 +281,7 @@
"maximum_ram_size": 8192, "maximum_ram_size": 8192,
"maximum_size": 253952, "maximum_size": 253952,
"protocol": "wiring", "protocol": "wiring",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
}, },
@@ -286,6 +300,7 @@
"maximum_ram_size": 8192, "maximum_ram_size": 8192,
"maximum_size": 126976, "maximum_size": 126976,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
}, },
@@ -304,6 +319,7 @@
"maximum_ram_size": 8192, "maximum_ram_size": 8192,
"maximum_size": 253952, "maximum_size": 253952,
"protocol": "wiring", "protocol": "wiring",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
}, },
@@ -326,6 +342,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true
@@ -346,6 +363,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 14336, "maximum_size": 14336,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 19200 "speed": 19200
} }
}, },
@@ -364,6 +382,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
}, },
@@ -382,6 +401,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 14336, "maximum_size": 14336,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 19200 "speed": 19200
} }
}, },
@@ -400,6 +420,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 30720, "maximum_size": 30720,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
}, },
@@ -418,6 +439,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 14336, "maximum_size": 14336,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 19200 "speed": 19200
} }
}, },
@@ -436,6 +458,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 30720, "maximum_size": 30720,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
}, },
@@ -454,6 +477,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 14336, "maximum_size": 14336,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 19200 "speed": 19200
} }
}, },
@@ -472,6 +496,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 30720, "maximum_size": 30720,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
}, },
@@ -494,6 +519,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true
@@ -518,6 +544,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true
@@ -538,6 +565,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 32256, "maximum_size": 32256,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
}, },
@@ -560,6 +588,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"via_ssh": true, "via_ssh": true,
@@ -587,9 +616,35 @@
"maximum_ram_size": 28672, "maximum_ram_size": 28672,
"maximum_size": 524288, "maximum_size": 524288,
"protocol": "sam-ba", "protocol": "sam-ba",
"speed": 57600, "require_upload_port" : true,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": false "wait_for_upload_port": true
}
},
"dueUSB": {
"build": {
"core": "arduino",
"extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM",
"f_cpu": "84000000L",
"mcu": "at91sam3x8e",
"cpu": "cortex-m3",
"pid": "0x003e",
"usb_product": "Arduino Due",
"variant": "arduino_due_x",
"vid": "0x2341",
"ldscript": "sam3x8e.ld"
},
"framework": "arduino",
"name": "Arduino Due (USB Native Port)",
"platform": "atmelsam",
"upload": {
"disable_flushing": true,
"maximum_ram_size": 28672,
"maximum_size": 524288,
"protocol": "sam-ba",
"require_upload_port" : true,
"use_1200bps_touch": true,
"wait_for_upload_port": true
} }
} }
} }

View File

@@ -8,15 +8,12 @@
"variant": "digispark_tiny" "variant": "digispark_tiny"
}, },
"framework": "arduino", "framework": "arduino",
"name": "Digispark (Default - 16.5mhz)", "name": "Digispark (Default - 16 MHz)",
"platform": "atmelavr", "platform": "atmelavr",
"upload": { "upload": {
"disable_flushing": false,
"maximum_ram_size": 512, "maximum_ram_size": 512,
"maximum_size": 6012, "maximum_size": 6012,
"protocol": "digispark", "protocol": "digispark"
"use_1200bps_touch": false,
"wait_for_upload_port": false
} }
}, },
"digispark-pro": { "digispark-pro": {
@@ -28,15 +25,12 @@
"variant": "digispark_pro" "variant": "digispark_pro"
}, },
"framework": "arduino", "framework": "arduino",
"name": "Digispark Pro (Default 16 Mhz)", "name": "Digispark Pro (Default 16 MHz)",
"platform": "atmelavr", "platform": "atmelavr",
"upload": { "upload": {
"disable_flushing": false,
"maximum_ram_size": 512, "maximum_ram_size": 512,
"maximum_size": 14844, "maximum_size": 14844,
"protocol": "digispark", "protocol": "digispark"
"use_1200bps_touch": false,
"wait_for_upload_port": false
} }
}, },
"digispark-pro32": { "digispark-pro32": {
@@ -48,15 +42,12 @@
"variant": "digispark_pro32" "variant": "digispark_pro32"
}, },
"framework": "arduino", "framework": "arduino",
"name": "Digispark Pro (16 Mhz) (32 byte buffer)", "name": "Digispark Pro (16 MHz) (32 byte buffer)",
"platform": "atmelavr", "platform": "atmelavr",
"upload": { "upload": {
"disable_flushing": false,
"maximum_ram_size": 512, "maximum_ram_size": 512,
"maximum_size": 14844, "maximum_size": 14844,
"protocol": "digispark", "protocol": "digispark"
"use_1200bps_touch": false,
"wait_for_upload_port": false
} }
}, },
"digispark-pro64": { "digispark-pro64": {
@@ -68,15 +59,12 @@
"variant": "digispark_pro64" "variant": "digispark_pro64"
}, },
"framework": "arduino", "framework": "arduino",
"name": "Digispark Pro (16 Mhz) (64 byte buffer)", "name": "Digispark Pro (16 MHz) (64 byte buffer)",
"platform": "atmelavr", "platform": "atmelavr",
"upload": { "upload": {
"disable_flushing": false,
"maximum_ram_size": 512, "maximum_ram_size": 512,
"maximum_size": 14844, "maximum_size": 14844,
"protocol": "digispark", "protocol": "digispark"
"use_1200bps_touch": false,
"wait_for_upload_port": false
} }
}, },
"digix": { "digix": {
@@ -96,10 +84,11 @@
"name": "Digistump DigiX", "name": "Digistump DigiX",
"platform": "atmelsam", "platform": "atmelsam",
"upload": { "upload": {
"disable_flushing": false, "disable_flushing": true,
"maximum_ram_size": 28672, "maximum_ram_size": 28672,
"maximum_size": 524288, "maximum_size": 524288,
"protocol": "sam-ba", "protocol": "sam-ba",
"require_upload_port" : true,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true
} }

View File

@@ -18,6 +18,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true
@@ -42,6 +43,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true
@@ -66,6 +68,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true

View File

@@ -14,6 +14,7 @@
"maximum_ram_size": 16384, "maximum_ram_size": 16384,
"maximum_size": 130048, "maximum_size": 130048,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
}, },
@@ -32,6 +33,7 @@
"maximum_ram_size": 16384, "maximum_ram_size": 16384,
"maximum_size": 130048, "maximum_size": 130048,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
}, },
@@ -50,6 +52,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 15872, "maximum_size": 15872,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
}, },
@@ -68,6 +71,7 @@
"maximum_ram_size": 1024, "maximum_ram_size": 1024,
"maximum_size": 15872, "maximum_size": 15872,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
}, },
@@ -86,6 +90,7 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 32256, "maximum_size": 32256,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
}, },
@@ -103,6 +108,7 @@
"upload": { "upload": {
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 32256, "maximum_size": 32256,
"require_upload_port" : true,
"protocol": "arduino", "protocol": "arduino",
"speed": 57600 "speed": 57600
} }
@@ -125,6 +131,7 @@
"maximum_ram_size": 2560, "maximum_ram_size": 2560,
"maximum_size": 28672, "maximum_size": 28672,
"protocol": "avr109", "protocol": "avr109",
"require_upload_port" : true,
"speed": 57600, "speed": 57600,
"use_1200bps_touch": true, "use_1200bps_touch": true,
"wait_for_upload_port": true "wait_for_upload_port": true
@@ -145,6 +152,7 @@
"maximum_ram_size": 4096, "maximum_ram_size": 4096,
"maximum_size": 64512, "maximum_size": 64512,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 115200 "speed": 115200
} }
}, },
@@ -163,6 +171,7 @@
"maximum_ram_size": 4096, "maximum_ram_size": 4096,
"maximum_size": 64512, "maximum_size": 64512,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
} }

View File

@@ -14,7 +14,60 @@
"maximum_ram_size": 2048, "maximum_ram_size": 2048,
"maximum_size": 30720, "maximum_size": 30720,
"protocol": "arduino", "protocol": "arduino",
"require_upload_port" : true,
"speed": 57600 "speed": 57600
} }
},
"sainSmartDue": {
"build": {
"core": "arduino",
"extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM",
"f_cpu": "84000000L",
"mcu": "at91sam3x8e",
"cpu": "cortex-m3",
"pid": "0x003e",
"usb_product": "Arduino Due",
"variant": "arduino_due_x",
"vid": "0x2341",
"ldscript": "sam3x8e.ld"
},
"framework": "arduino",
"name": "SainSmart Due (Programming Port)",
"platform": "atmelsam",
"upload": {
"disable_flushing": true,
"maximum_ram_size": 28672,
"maximum_size": 524288,
"protocol": "sam-ba",
"require_upload_port" : true,
"use_1200bps_touch": true,
"wait_for_upload_port": true
}
},
"sainSmartDueUSB": {
"build": {
"core": "arduino",
"extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM",
"f_cpu": "84000000L",
"mcu": "at91sam3x8e",
"cpu": "cortex-m3",
"pid": "0x003e",
"usb_product": "Arduino Due",
"variant": "arduino_due_x",
"vid": "0x2341",
"ldscript": "sam3x8e.ld"
},
"framework": "arduino",
"name": "SainSmart Due (USB Native Port)",
"platform": "atmelsam",
"upload": {
"disable_flushing": true,
"maximum_ram_size": 28672,
"maximum_size": 524288,
"protocol": "sam-ba",
"require_upload_port" : true,
"use_1200bps_touch": true,
"wait_for_upload_port": true
}
} }
} }

View File

@@ -50,7 +50,10 @@ commonvars.AddVariables(
) )
DefaultEnvironment( DefaultEnvironment(
tools=["gcc", "g++", "as", "ar", "gnulink", "platformio"], tools=[
"gcc", "g++", "as", "ar", "gnulink",
"platformio", "pioupload", "pioar"
],
toolpath=[join("$PIOBUILDER_DIR", "tools")], toolpath=[join("$PIOBUILDER_DIR", "tools")],
variables=commonvars, variables=commonvars,

View File

@@ -20,16 +20,16 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
with open(path, "w") as f: with open(path, "w") as f:
f.write(str(value)) f.write(str(value))
if "UPLOAD_SPEED" in env: upload_options = env.get("BOARD_OPTIONS", {}).get("upload", {})
env.Append(
UPLOADERFLAGS=["-b", "$UPLOAD_SPEED"]
)
if "usb" not in env.subst("$UPLOAD_PROTOCOL"): if env.subst("$UPLOAD_SPEED"):
env.AutodetectUploadPort() env.Append(UPLOADERFLAGS=["-b", "$UPLOAD_SPEED"])
env.Append(
UPLOADERFLAGS=["-P", "$UPLOAD_PORT"] if not upload_options.get("require_upload_port", False):
) return
env.AutodetectUploadPort()
env.Append(UPLOADERFLAGS=["-P", "$UPLOAD_PORT"])
if env.subst("$BOARD") == "raspduino": if env.subst("$BOARD") == "raspduino":
_rpi_sysgpio("/sys/class/gpio/export", 18) _rpi_sysgpio("/sys/class/gpio/export", 18)
@@ -38,9 +38,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
sleep(0.1) sleep(0.1)
_rpi_sysgpio("/sys/class/gpio/gpio18/value", 0) _rpi_sysgpio("/sys/class/gpio/gpio18/value", 0)
_rpi_sysgpio("/sys/class/gpio/unexport", 18) _rpi_sysgpio("/sys/class/gpio/unexport", 18)
elif "UPLOAD_PORT" in env: else:
upload_options = env.get("BOARD_OPTIONS", {}).get("upload", {})
if not upload_options.get("disable_flushing", False): if not upload_options.get("disable_flushing", False):
env.FlushSerialBuffer("$UPLOAD_PORT") env.FlushSerialBuffer("$UPLOAD_PORT")
@@ -65,7 +63,7 @@ if "digispark" in env.get(
"-c", "$UPLOAD_PROTOCOL", "-c", "$UPLOAD_PROTOCOL",
"--timeout", "60" "--timeout", "60"
], ],
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i' UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
) )
else: else:

View File

@@ -10,10 +10,33 @@ from os.path import join
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
DefaultEnvironment, SConscript) DefaultEnvironment, SConscript)
from platformio.util import get_serialports
def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
env.AutodetectUploadPort() env.AutodetectUploadPort()
board_type = env.subst("$BOARD")
env.Append(
UPLOADERFLAGS=[
"-U",
"true" if "usb" in board_type.lower(
) or board_type == "digix" else "false"
])
upload_options = env.get("BOARD_OPTIONS", {}).get("upload", {})
if not upload_options.get("disable_flushing", False):
env.FlushSerialBuffer("$UPLOAD_PORT")
before_ports = [i['port'] for i in get_serialports()]
if upload_options.get("use_1200bps_touch", False):
env.TouchSerialPort("$UPLOAD_PORT", 1200)
if upload_options.get("wait_for_upload_port", False):
env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports))
env = DefaultEnvironment() env = DefaultEnvironment()

View File

@@ -50,11 +50,6 @@ env.Replace(
SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES' SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES'
) )
if "UPLOAD_SPEED" in env:
env.Append(UPLOADERFLAGS=["-b", "$UPLOAD_SPEED"])
if env.subst("$UPLOAD_PROTOCOL") != "usbtiny":
env.Append(UPLOADERFLAGS=["-P", "$UPLOAD_PORT"])
env.Append( env.Append(
BUILDERS=dict( BUILDERS=dict(
ElfToEep=Builder( ElfToEep=Builder(

View File

@@ -0,0 +1,42 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
import atexit
from os import remove
from tempfile import mkstemp
MAX_SOURCES_LENGTH = 8000 # Windows CLI has limit with command length to 8192
def _remove_tmpfile(path):
try:
remove(path)
except WindowsError: # pylint: disable=E0602
pass
def _huge_sources_hook(sources):
if len(str(sources)) < MAX_SOURCES_LENGTH:
return sources
_, tmp_file = mkstemp()
with open(tmp_file, "w") as f:
f.write(str(sources).replace("\\", "/"))
atexit.register(_remove_tmpfile, tmp_file)
return "@%s" % tmp_file
def exists(_):
return True
def generate(env):
env.Replace(
_huge_sources_hook=_huge_sources_hook,
ARCOM=env.get("ARCOM", "").replace(
"$SOURCES", "${_huge_sources_hook(SOURCES)}"))
return env

View File

@@ -0,0 +1,76 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
import platform
from time import sleep
from SCons.Script import Exit
from serial import Serial
from platformio.util import get_serialports
def FlushSerialBuffer(env, port):
s = Serial(env.subst(port))
s.flushInput()
s.setDTR(False)
s.setRTS(False)
sleep(0.1)
s.setDTR(True)
s.setRTS(True)
s.close()
def TouchSerialPort(env, port, baudrate):
s = Serial(port=env.subst(port), baudrate=baudrate)
s.close()
if platform.system() != "Darwin":
sleep(0.3)
def WaitForNewSerialPort(_, before):
new_port = None
elapsed = 0
while elapsed < 10:
now = [i['port'] for i in get_serialports()]
diff = list(set(now) - set(before))
if diff:
new_port = diff[0]
break
before = now
sleep(0.25)
elapsed += 0.25
if not new_port:
Exit("Error: Couldn't find a board on the selected port. "
"Check that you have the correct port selected. "
"If it is correct, try pressing the board's reset "
"button after initiating the upload.")
return new_port
def AutodetectUploadPort(env):
if "UPLOAD_PORT" not in env:
for item in get_serialports():
if "VID:PID" in item['hwid']:
print "Auto-detected UPLOAD_PORT: %s" % item['port']
env.Replace(UPLOAD_PORT=item['port'])
break
if "UPLOAD_PORT" not in env:
Exit("Error: Please specify `upload_port` for environment or use "
"global `--upload-port` option.\n")
def exists(_):
return True
def generate(env):
env.AddMethod(FlushSerialBuffer)
env.AddMethod(TouchSerialPort)
env.AddMethod(WaitForNewSerialPort)
env.AddMethod(AutodetectUploadPort)
return env

View File

@@ -2,17 +2,12 @@
# See LICENSE for details. # See LICENSE for details.
import atexit import atexit
import platform
import re import re
from os import getenv, listdir, remove, sep, walk from os import getenv, listdir, remove, sep, walk
from os.path import basename, dirname, isdir, isfile, join, normpath from os.path import basename, dirname, isdir, isfile, join, normpath
from time import sleep
from SCons.Script import Exit, SConscript, SConscriptChdir from SCons.Script import SConscript, SConscriptChdir
from SCons.Util import case_sensitive_suffixes from SCons.Util import case_sensitive_suffixes
from serial import Serial
from platformio.util import get_serialports
def ProcessGeneral(env): def ProcessGeneral(env):
@@ -64,7 +59,7 @@ def BuildFirmware(env, corelibs):
_LIBFLAGS=" -Wl,--end-group" _LIBFLAGS=" -Wl,--end-group"
) )
firmenv.MergeFlags(getenv("PIOSRCBUILD_FLAGS", "$SRCBUILD_FLAGS")) firmenv.MergeFlags(getenv("PLATFORMIO_SRCBUILD_FLAGS", "$SRCBUILD_FLAGS"))
return firmenv.Program( return firmenv.Program(
join("$BUILD_DIR", "firmware"), join("$BUILD_DIR", "firmware"),
@@ -303,60 +298,6 @@ def ConvertInoToCpp(env):
atexit.register(delete_tmpcpp, tmpcpp) atexit.register(delete_tmpcpp, tmpcpp)
def FlushSerialBuffer(env, port):
s = Serial(env.subst(port))
s.flushInput()
s.setDTR(False)
s.setRTS(False)
sleep(0.1)
s.setDTR(True)
s.setRTS(True)
s.close()
def TouchSerialPort(env, port, baudrate):
s = Serial(port=env.subst(port), baudrate=baudrate)
s.close()
if platform.system() != "Darwin":
sleep(0.3)
def WaitForNewSerialPort(_, before):
new_port = None
elapsed = 0
while elapsed < 10:
now = [i['port'] for i in get_serialports()]
diff = list(set(now) - set(before))
if diff:
new_port = diff[0]
break
before = now
sleep(0.25)
elapsed += 0.25
if not new_port:
Exit("Error: Couldn't find a board on the selected port. "
"Check that you have the correct port selected. "
"If it is correct, try pressing the board's reset "
"button after initiating the upload.")
return new_port
def AutodetectUploadPort(env):
if "UPLOAD_PORT" not in env:
for item in get_serialports():
if "VID:PID" in item['hwid']:
print "Auto-detected UPLOAD_PORT: %s" % item['port']
env.Replace(UPLOAD_PORT=item['port'])
break
if "UPLOAD_PORT" not in env:
Exit("Error: Please specify `upload_port` for environment or use "
"global `--upload-port` option.\n")
def exists(_): def exists(_):
return True return True
@@ -369,8 +310,4 @@ def generate(env):
env.AddMethod(BuildLibrary) env.AddMethod(BuildLibrary)
env.AddMethod(BuildDependentLibraries) env.AddMethod(BuildDependentLibraries)
env.AddMethod(ConvertInoToCpp) env.AddMethod(ConvertInoToCpp)
env.AddMethod(FlushSerialBuffer)
env.AddMethod(TouchSerialPort)
env.AddMethod(WaitForNewSerialPort)
env.AddMethod(AutodetectUploadPort)
return env return env

View File

@@ -56,25 +56,29 @@ def get_systype():
return ("%s_%s" % (data[0], data[4])).lower() return ("%s_%s" % (data[0], data[4])).lower()
def _get_projconf_option_dir(option_name): def _get_projconf_option_dir(name, default=None):
_env_name = "PLATFORMIO_%s" % name.upper()
if _env_name in os.environ:
return os.getenv(_env_name)
try: try:
config = get_project_config() config = get_project_config()
if (config.has_section("platformio") and if (config.has_section("platformio") and
config.has_option("platformio", option_name)): config.has_option("platformio", name)):
option_dir = config.get("platformio", option_name) option_dir = config.get("platformio", name)
if option_dir.startswith("~"): if option_dir.startswith("~"):
option_dir = expanduser(option_dir) option_dir = expanduser(option_dir)
return abspath(option_dir) return abspath(option_dir)
except exception.NotPlatformProject: except exception.NotPlatformProject:
pass pass
return None return default
def get_home_dir(): def get_home_dir():
home_dir = _get_projconf_option_dir("home_dir") home_dir = _get_projconf_option_dir(
"home_dir",
if not home_dir: join(expanduser("~"), ".platformio")
home_dir = join(expanduser("~"), ".platformio") )
if not isdir(home_dir): if not isdir(home_dir):
os.makedirs(home_dir) os.makedirs(home_dir)
@@ -84,12 +88,10 @@ def get_home_dir():
def get_lib_dir(): def get_lib_dir():
lib_dir = _get_projconf_option_dir("lib_dir") return _get_projconf_option_dir(
"lib_dir",
if not lib_dir: join(get_home_dir(), "lib")
lib_dir = join(get_home_dir(), "lib") )
return lib_dir
def get_source_dir(): def get_source_dir():
@@ -101,16 +103,17 @@ def get_project_dir():
def get_projectsrc_dir(): def get_projectsrc_dir():
src_dir = _get_projconf_option_dir("src_dir") return _get_projconf_option_dir(
"src_dir",
if not src_dir: join(get_project_dir(), "src")
src_dir = join(get_project_dir(), "src") )
return src_dir
def get_pioenvs_dir(): def get_pioenvs_dir():
return os.getenv("PIOENVS_DIR", join(get_project_dir(), ".pioenvs")) return _get_projconf_option_dir(
"envs_dir",
join(get_project_dir(), ".pioenvs")
)
def get_project_config(): def get_project_config():

View File

@@ -1,28 +1,24 @@
# Copyright (C) Ivan Kravets <me@ikravets.com> # Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details. # See LICENSE for details.
from os import environ
from click.testing import CliRunner from click.testing import CliRunner
import pytest import pytest
from platformio import app
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def platformio_setup(request): def platformio_setup(request):
prev_settings = dict( pioenvvars = ("ENABLE_PROMPTS", "ENABLE_TELEMETRY")
enable_telemetry=None, for v in pioenvvars:
enable_prompts=None environ["PLATFORMIO_SETTING_%s" % v] = "No"
)
for key, value in prev_settings.iteritems():
prev_settings[key] = app.get_setting(key)
# disable temporary
if prev_settings[key]:
app.set_setting(key, False)
def platformio_teardown(): def platformio_teardown():
# restore settings for v in pioenvvars:
for key, value in prev_settings.iteritems(): _name = "PLATFORMIO_SETTING_%s" % v
app.set_setting(key, value) if _name in environ:
del environ[_name]
request.addfinalizer(platformio_teardown) request.addfinalizer(platformio_teardown)

View File

@@ -38,6 +38,8 @@ basepython =
py27: python2.7 py27: python2.7
usedevelop = True usedevelop = True
deps = pytest deps = pytest
setenv =
PLATFORMIO_SETTING_ENABLE_PROMPTS = False
commands = commands =
{envpython} --version {envpython} --version
pip install --egg http://sourceforge.net/projects/scons/files/latest/download pip install --egg http://sourceforge.net/projects/scons/files/latest/download