diff --git a/HISTORY.rst b/HISTORY.rst index f5783f63..b09e2216 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,25 +1,46 @@ Release History =============== +0.10.0 (2015-01-01) Happy New Year! +----------------------------------- + +* Implemented `platformio boards `_ + command (`issue #11 `_) +* Added support of *Engduino* boards for + `atmelavr `__ + platform (`issue #38 `_) +* Added ``--board`` option to `platformio init `_ + command which allows to initialise project with the specified embedded boards + (`issue #21 `_) +* Added `example with uploading firmware `_ + via USB programmer (USBasp) for + `atmelavr `_ + *MCUs* (`issue #35 `_) +* Automatic detection of port on `platformio serialports monitor `_ + (`issue #37 `_) +* Allowed auto-installation of platforms when prompts are disabled (`issue #43 `_) +* Fixed urllib3's *SSL* warning under Python <= 2.7.2 (`issue #39 `_) +* Fixed bug with *Arduino USB* boards (`issue #40 `_) + + 0.9.2 (2014-12-10) ------------------ * Replaced "dark blue" by "cyan" colour for the texts (`issue #33 `_) -* Added new setting `enable_prompts `_ +* Added new setting `enable_prompts `_ and allowed to disable all *PlatformIO* prompts (useful for cloud compilers) (`issue #34 `_) * Fixed compilation bug on *Windows* with installed *MSVC* (`issue #18 `_) - 0.9.1 (2014-12-05) ------------------ * Ask user to install platform (when it hasn't been installed yet) within - `platformio run `_ - and `platformio show `_ commands -* Improved main `documentation `_ + `platformio run `__ + and `platformio show `_ commands +* Improved main `documentation `_ * Fixed "*OSError: [Errno 2] No such file or directory*" within - `platformio run `_ + `platformio run `__ command when PlatformIO isn't installed properly * Fixed example for `Eclipse IDE with Tiva board `_ (`issue #32 `_) @@ -29,8 +50,8 @@ Release History 0.9.0 (2014-12-01) ------------------ -* Implemented `platformio settings `_ command -* Improved `platformio init `_ command. +* Implemented `platformio settings `_ command +* Improved `platformio init `_ command. Added new option ``--project-dir`` where you can specify another path to directory where new project will be initialized (`issue #31 `_) * Added *Migration Manager* which simplifies process with upgrading to a @@ -47,18 +68,18 @@ Release History 0.8.0 (2014-10-19) ------------------ -* Avoided trademark issues in `library.json `_ - with the new fields: `frameworks `_, - `platforms `_ - and `dependencies `_ +* Avoided trademark issues in `library.json `_ + with the new fields: `frameworks `_, + `platforms `_ + and `dependencies `_ (`issue #17 `_) * Switched logic from "Library Name" to "Library Registry ID" for all - `platformio lib `_ + `platformio lib `_ commands (install, uninstall, update and etc.) -* Renamed ``author`` field to `authors `_ - and allowed to setup multiple authors per library in `library.json `_ -* Added option to specify "maintainer" status in `authors `_ field -* New filters/options for `platformio lib search `_ +* Renamed ``author`` field to `authors `_ + and allowed to setup multiple authors per library in `library.json `_ +* Added option to specify "maintainer" status in `authors `_ field +* New filters/options for `platformio lib search `_ command: ``--framework`` and ``--platform`` 0.7.1 (2014-10-06) @@ -72,15 +93,15 @@ Release History 0.7.0 (2014-09-24) ------------------ -* Implemented new `[platformio] `_ - section for Configuration File with `home_dir `_ +* Implemented new `[platformio] `_ + section for Configuration File with `home_dir `_ option (`issue #14 `_) * Implemented *Library Manager* (`issue #6 `_) 0.6.0 (2014-08-09) ------------------ -* Implemented `platformio serialports monitor `_ (`issue #10 `_) +* Implemented `platformio serialports monitor `_ (`issue #10 `_) * Fixed an issue ``ImportError: No module named platformio.util`` (`issue #9 `_) * Fixed bug with auto-conversation from Arduino \*.ino to \*.cpp @@ -93,7 +114,7 @@ Release History frameworks (`issue #7 `_) * Added `Arduino example `_ with external library (*Adafruit CC3000*) -* Implemented `platformio upgrade `_ +* Implemented `platformio upgrade `_ command and "auto-check" for the latest version (`issue #8 `_) * Fixed an issue with "auto-reset" for *Raspduino* board @@ -102,21 +123,21 @@ Release History 0.4.0 (2014-07-31) ------------------ -* Implemented `platformio serialports `_ command +* Implemented `platformio serialports `_ command * Allowed to put special build flags only for ``src`` files via - `srcbuild_flags `_ + `srcbuild_flags `_ environment option * Allowed to override some of settings via system environment variables such as: ``$PIOSRCBUILD_FLAGS`` and ``$PIOENVS_DIR`` -* Added ``--upload-port`` option for `platformio run `_ command +* Added ``--upload-port`` option for `platformio run `__ command * Implemented (especially for `SmartAnthill `_) - `platformio run -t uploadlazy `_ + `platformio run -t uploadlazy `_ target (no dependencies to framework libs, ELF and etc.) -* Allowed to skip default packages via `platformio install --skip-default-package `_ +* Allowed to skip default packages via `platformio install --skip-default-package `_ option * Added tools for *Raspberry Pi* platform * Added support for *Microduino* and *Raspduino* boards in - `atmelavr `_ platform + `atmelavr `_ platform 0.3.1 (2014-06-21) diff --git a/LICENSE b/LICENSE index 588d06b2..50d24ce8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Ivan Kravets +Copyright (c) 2014-2015 Ivan Kravets Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.rst b/README.rst index a92a43d6..76fba3ca 100644 --- a/README.rst +++ b/README.rst @@ -17,26 +17,26 @@ PlatformIO :target: https://pypi.python.org/pypi/platformio/ :alt: License -`Website + Library Search `_ | -`Documentation `_ | +`Website + Library Search `_ | +`Documentation `_ | `Project Examples `_ | `Blog `_ | -`Twitter `_ +`Twitter `_ .. image:: https://raw.githubusercontent.com/ivankravets/platformio/develop/docs/_static/platformio-logo.png - :target: http://platformio.ikravets.com + :target: http://platformio.org -`PlatformIO `_ is a cross-platform code builder +`PlatformIO `_ is a cross-platform code builder and the missing library manager. -* `Get Started `_ -* `Web 2.0 Library Search `_ -* `Development Platforms `_ -* `Embedded Boards `_ -* `Library Manager `_ -* `User Guide `_ -* `IDE Integration `_ -* `Release History `_ +* `Get Started `_ +* `Web 2.0 Library Search `_ +* `Development Platforms `_ +* `Embedded Boards `_ +* `Library Manager `_ +* `User Guide `_ +* `IDE Integration `_ +* `Release History `_ You have **no need** to install any *IDE* or compile any tool chains. *PlatformIO* has pre-built different development platforms including: compiler, debugger, @@ -52,18 +52,18 @@ sized computers (like *Raspberry Pi*). Embedded Development. *Easier Than Ever.* ----------------------------------------- *PlatformIO* is well suited for embedded development and has pre-configured -settings for most popular `Embedded Boards `_. +settings for most popular `Embedded Boards `_. * Colourful `command-line output `_ -* Built-in `Serial Port Monitor `_ -* Configurable `build -flags/-options `_ +* Built-in `Serial Port Monitor `_ +* Configurable `build -flags/-options `_ * Automatic **firmware uploading** -* Integration with `development environments (IDE) `_ +* Integration with `development environments (IDE) `_ * Ready for **cloud compilers** -* Pre-built tool chains, frameworks for the popular `Hardware Platforms `_ +* Pre-built tool chains, frameworks for the popular `Hardware Platforms `_ .. image:: https://raw.githubusercontent.com/ivankravets/platformio-web/develop/app/images/platformio-embedded-development.png - :target: http://platformio.ikravets.com + :target: http://platformio.org :alt: PlatformIO Embedded Development Process The Missing Library Manager. *It's here!* @@ -71,16 +71,16 @@ The Missing Library Manager. *It's here!* *PlatformIO Library Manager* is the missing library manager for development platforms which allows you to organize and have up-to-date external libraries. -* Friendly `Command-Line Interface `_ -* Modern `Web 2.0 Library Search `_ +* Friendly `Command-Line Interface `_ +* Modern `Web 2.0 Library Search `_ * Open Source `Library Registry API `_ -* Library Crawler based on `library.json `_ +* Library Crawler based on `library.json `_ specification * Library **dependency management** * Automatic library updating .. image:: https://raw.githubusercontent.com/ivankravets/platformio-web/develop/app/images/platformio-library-manager.png - :target: http://platformio.ikravets.com + :target: http://platformio.org :alt: PlatformIO Library Manager Architecture Smart Code Builder. *Fast and Reliable.* @@ -93,36 +93,36 @@ cross-platform substitute for the classic *Make* utility. * Reliable detection of *build changes* * Improved support for *parallel builds* * Ability to share *built files in a cache* -* Lookup for external libraries which are installed via `Library Manager `_ +* Lookup for external libraries which are installed via `Library Manager `_ .. image:: https://raw.githubusercontent.com/ivankravets/platformio-web/develop/app/images/platformio-scons-builder.png - :target: http://platformio.ikravets.com + :target: http://platformio.org :alt: PlatformIO Code Builder Architecture Single source code. *Multiple platforms.* ----------------------------------------- *PlatformIO* allows developer to compile the same code with different development platforms using the *Only One Command* -`platformio run `_. +`platformio run `_. This happens due to -`Project Configuration File (platformio.ini) `_ +`Project Configuration File (platformio.ini) `_ where you can setup different environments with specific options (platform type, firmware uploading settings, pre-built framework, build flags and many more). It has support for many popular embedded platforms like these: -* ``atmelavr`` `Atmel AVR `_ +* ``atmelavr`` `Atmel AVR `_ (including *Arduino*-based boards, *Microduino, Raspduino, Teensy*) -* ``timsp430`` `TI MSP430 `_ +* ``timsp430`` `TI MSP430 `_ (including *MSP430* LaunchPads) -* ``titiva`` `TI TIVA C `_ +* ``titiva`` `TI TIVA C `_ (including *TIVA C* Series LaunchPads) Licence ------- -Copyright (C) 2014 Ivan Kravets +Copyright (C) 2014-2015 Ivan Kravets Licenced under the MIT Licence. diff --git a/docs/conf.py b/docs/conf.py index 5e890ad6..b499869d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -45,7 +45,7 @@ master_doc = 'index' # General information about the project. project = u'PlatformIO' -copyright = u'2014, Ivan Kravets' +copyright = u'2014-2015, Ivan Kravets' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/docs/index.rst b/docs/index.rst index b72528a6..ee2680b9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,14 +2,14 @@ PlatformIO: A cross-platform code builder and the missing library manager ========================================================================= .. image:: _static/platformio-logo.png - :target: http://platformio.ikravets.com + :target: http://platformio.org -`Website + Library Search `_ | +`Website + Library Search `_ | `Project Examples `_ | `Source Code `_ | `Issues `_ | `Blog `_ | -`Twitter `_ +`Twitter `_ You have no need to install any *IDE* or compile any tool chains. *PlatformIO* has pre-built different development platforms including: compiler, debugger, diff --git a/docs/librarymanager/index.rst b/docs/librarymanager/index.rst index 5dcc323a..3e9604ef 100644 --- a/docs/librarymanager/index.rst +++ b/docs/librarymanager/index.rst @@ -9,7 +9,7 @@ Library Manager *PlatformIO Library Manager* allows you to organize external embedded libraries. You can search for new libraries via :ref:`Command Line interface ` -or `Web 2.0 Library Search `_. +or `Web 2.0 Library Search `_. You don't need to bother for finding the latest version of library. Due to :ref:`cmd_lib_update` command you will have up-to-date external libraries. diff --git a/docs/platforms/atmelavr.rst b/docs/platforms/atmelavr.rst index 49ad22a9..9b8aa94d 100644 --- a/docs/platforms/atmelavr.rst +++ b/docs/platforms/atmelavr.rst @@ -59,8 +59,9 @@ Boards ------ .. note:: - For more detailed ``board`` information please scroll tables below by - horizontal. + * You can list pre-configured boards by :ref:`cmd_boards` command + * For more detailed ``board`` information please scroll tables below by + horizontal. Arduino ~~~~~~~ @@ -218,6 +219,41 @@ More detailed information you can find here `Arduino boards `_. +Engduino +~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller ``board_mcu`` + - Frequency ``board_f_cpu`` + - Flash + - RAM + * - ``engduinov1`` + - `Engduino 1 `_ + - ATmega32u4 ``atmega32u4`` + - 8 MHz ``8000000L`` + - 32 Kb + - 2.5 Kb + * - ``engduinov2`` + - `Engduino 2 `_ + - ATmega32u4 ``atmega32u4`` + - 8 MHz ``8000000L`` + - 32 Kb + - 2.5 Kb + * - ``engduinov3`` + - `Engduino 3 `_ + - ATmega32u4 ``atmega32u4`` + - 8 MHz ``8000000L`` + - 32 Kb + - 2.5 Kb + +More detailed information you can find here +`Engduino Site `_. + + Microduino ~~~~~~~~~~ @@ -319,5 +355,5 @@ Raspduino - 32 Kb - 2 Kb -More detailed information you can find in +More detailed information you can find here `Wiki `_. diff --git a/docs/platforms/timsp430.rst b/docs/platforms/timsp430.rst index 22809b5d..5d7e625e 100644 --- a/docs/platforms/timsp430.rst +++ b/docs/platforms/timsp430.rst @@ -56,8 +56,9 @@ Boards ------ .. note:: - For more detailed ``board`` information please scroll table below by - horizontal. + * You can list pre-configured boards by :ref:`cmd_boards` command + * For more detailed ``board`` information please scroll tables below by + horizontal. .. list-table:: :header-rows: 1 diff --git a/docs/platforms/titiva.rst b/docs/platforms/titiva.rst index 0b1f7b80..1c00ce02 100644 --- a/docs/platforms/titiva.rst +++ b/docs/platforms/titiva.rst @@ -56,8 +56,9 @@ Boards ------ .. note:: - For more detailed ``board`` information please scroll table below by - horizontal. + * You can list pre-configured boards by :ref:`cmd_boards` command + * For more detailed ``board`` information please scroll tables below by + horizontal. .. list-table:: :header-rows: 1 diff --git a/docs/projectconf.rst b/docs/projectconf.rst index aa3bf1ba..999ec4c0 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -8,7 +8,7 @@ The Project configuration file is named ``platformio.ini``. This is a ``platformio.ini`` has sections (each denoted by a ``[header]``) and key / value pairs within the sections. A sign ``#`` at the beginning of the -line indicate a comment. Comment lines are ignored. +line indicates a comment. Comment lines are ignored. The sections and their allowable values are described below. @@ -58,18 +58,24 @@ For example, ``[env:hello_world]``. Options ~~~~~~~ +.. _projectconf_env_platform: + ``platform`` ^^^^^^^^^^^^ :ref:`Platform ` type +.. _projectconf_env_framework: + ``framework`` ^^^^^^^^^^^^^ See ``framework`` type in *Frameworks* section of :ref:`platforms` +.. _projectconf_env_board: + ``board`` ^^^^^^^^^ @@ -246,7 +252,7 @@ Examples ``board_*`` and ``upload_*`` options (use only ``board`` option) and Arduino Wiring-based Framework -.. code-block:: ini +.. code-block:: ini [env:atmelavr_arduino_uno_board] platform = atmelavr @@ -261,7 +267,7 @@ Examples auto pre-configured ``board_*`` and ``upload_*`` options (use only ``board`` option) and Arduino Wiring-based Framework -.. code-block:: ini +.. code-block:: ini [env:atmelavr_microduino_core_board] platform = atmelavr @@ -276,7 +282,7 @@ Examples auto pre-configured ``board_*`` and ``upload_*`` options (use only ``board`` option) and Arduino Wiring-based Framework -.. code-block:: ini +.. code-block:: ini [env:atmelavr_raspduino_board] platform = atmelavr @@ -292,7 +298,7 @@ Examples 4. :ref:`platform_atmelavr`: Embedded board that is based on ATmega168 MCU with "arduino" bootloader -.. code-block:: ini +.. code-block:: ini [env:atmelavr_atmega168_board] platform = atmelavr @@ -309,11 +315,23 @@ Examples targets = upload -5. :ref:`platform_timsp430`: TI MSP430G2553 LaunchPad with auto pre-configured +5. Upload firmware via USB programmer (USBasp) to :ref:`platform_atmelavr` + microcontrollers + +.. code-block:: ini + + [env:atmelavr_usbasp] + platform = atmelavr + framework = arduino + board = pro8MHzatmega328 + 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 -.. code-block:: ini +.. code-block:: ini [env:timsp430_g2553_launchpad] platform = timsp430 @@ -321,9 +339,9 @@ Examples board = lpmsp430g2553 -6. :ref:`platform_timsp430`: Embedded board that is based on MSP430G2553 MCU +7. :ref:`platform_timsp430`: Embedded board that is based on MSP430G2553 MCU -.. code-block:: ini +.. code-block:: ini [env:timsp430_g2553_board] platform = timsp430 @@ -336,11 +354,11 @@ Examples targets = upload -5. :ref:`platform_titiva`: TI Tiva C ARM Series TM4C123G LaunchPad with auto +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 +.. code-block:: ini [env:titiva_tm4c1230c3pm_launchpad] platform = titiva diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 1fc63923..26d6a656 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -4,36 +4,21 @@ Quickstart ========== .. note:: - Please read `Get Started `_ + Please read `Get Started `_ article from the official WebSite. -First, :ref:`Install PlatformIO `. +1. :ref:`Install PlatformIO `. -Print all available development platforms for installing +2. Find board ``type`` from :ref:`platforms` (you can choose multiple board + types). + +3. Initialize new PlatformIO based project with the pre-configured + environments for your boards: .. code-block:: bash - $ platformio search - [ ... ] + $ platformio init --board=TYPE1 --board=TYPE2 - -Install new development platform - -.. code-block:: bash - - $ platformio install PLATFORM - Downloading [####################################] 100% - Unpacking [####################################] 100% - Installing ..... - [ ... ] - The platform 'PLATFORM' has been successfully installed! - - -Initialize new PlatformIO based project - -.. code-block:: bash - - $ platformio init The current working directory *** will be used for the new project. You can specify another project directory via `platformio init -d %PATH_TO_THE_PROJECT_DIR%` command. @@ -46,29 +31,23 @@ Initialize new PlatformIO based project Project has been successfully initialized! Now you can process it with `platformio run` command. +More detailed information about this command is here :ref:`cmd_init`. -Setup environments in ``platformio.ini``. For more examples go to -:ref:`Project Configuration File ` - -.. code-block:: ini - - # Simple and base environment - [env:mybaseenv] - platform = %INSTALLED_PLATFORM_NAME_HERE% - - -Process the project's environments +4. Process the project's environments. .. code-block:: bash $ platformio run - # if embedded project then upload firmware + # if you don't have specified `targets = upload` option for environment, + # then you can upload firmware manually with this command: $ platformio run --target upload # clean project $ platformio run --target clean +If you don't have installed required platforms, then *PlatformIO* will propose +you to install them automatically. Further examples can be found in the ``examples/`` directory in the source distribution or `on the web `_. diff --git a/docs/userguide/cmd_boards.rst b/docs/userguide/cmd_boards.rst new file mode 100644 index 00000000..d8188832 --- /dev/null +++ b/docs/userguide/cmd_boards.rst @@ -0,0 +1,86 @@ +.. _cmd_boards: + +platformio boards +================= + +.. contents:: + +Usage +----- + +.. code-block:: bash + + # Print all available pre-configured embedded boards + platformio boards + + # Filter boards by "Query" + platformio boards QUERY + + +Description +----------- + +List pre-configured Embedded Boards + + +Examples +-------- + +1. Show Arduino-based boards + +.. code-block:: bash + + $ platformio boards arduino + + Platform: atmelavr + --------------------------------------------------------------------------- + Type MCU Frequency Flash RAM Name + --------------------------------------------------------------------------- + btatmega168 atmega168 16Mhz 14Kb 1Kb Arduino BT ATmega168 + btatmega328 atmega328p 16Mhz 28Kb 2Kb Arduino BT ATmega328 + diecimilaatmega168 atmega168 16Mhz 14Kb 1Kb Arduino Duemilanove or Diecimila ATmega168 + diecimilaatmega328 atmega328p 16Mhz 30Kb 2Kb Arduino Duemilanove or Diecimila ATmega328 + esplora atmega32u4 16Mhz 28Kb 2Kb Arduino Esplora + ethernet atmega328p 16Mhz 31Kb 2Kb Arduino Ethernet + ... + + +2. Show boards which are based on ``ATmega168`` MCU + +.. code-block:: bash + + $ platformio boards atmega168 + + Platform: atmelavr + --------------------------------------------------------------------------- + Type MCU Frequency Flash RAM Name + --------------------------------------------------------------------------- + btatmega168 atmega168 16Mhz 14Kb 1Kb Arduino BT ATmega168 + diecimilaatmega168 atmega168 16Mhz 14Kb 1Kb Arduino Duemilanove or Diecimila ATmega168 + miniatmega168 atmega168 16Mhz 14Kb 1Kb Arduino Mini ATmega168 + atmegangatmega168 atmega168 16Mhz 14Kb 1Kb Arduino NG or older ATmega168 + nanoatmega168 atmega168 16Mhz 14Kb 1Kb Arduino Nano ATmega168 + pro8MHzatmega168 atmega168 8Mhz 14Kb 1Kb Arduino Pro or Pro Mini ATmega168 (3.3V, 8 MHz) + pro16MHzatmega168 atmega168 16Mhz 14Kb 1Kb Arduino Pro or Pro Mini ATmega168 (5V, 16 MHz) + lilypadatmega168 atmega168 8Mhz 14Kb 1Kb LilyPad Arduino ATmega168 + 168pa16m atmega168p 16Mhz 15Kb 1Kb Microduino Core (Atmega168PA@16M,5V) + 168pa8m atmega168p 8Mhz 15Kb 1Kb Microduino Core (Atmega168PA@8M,3.3V) + +3. Show boards by :ref:`platform_timsp430` + +.. code-block:: bash + + $ platformio boards timsp430 + + Platform: timsp430 + --------------------------------------------------------------------------- + Type MCU Frequency Flash RAM Name + --------------------------------------------------------------------------- + lpmsp430fr5739 msp430fr5739 16Mhz 15Kb 1Kb FraunchPad w/ msp430fr5739 + lpmsp430f5529 msp430f5529 16Mhz 128Kb 1Kb LaunchPad w/ msp430f5529 (16MHz) + lpmsp430f5529_25 msp430f5529 25Mhz 128Kb 1Kb LaunchPad w/ msp430f5529 (25MHz) + lpmsp430fr5969 msp430fr5969 8Mhz 64Kb 1Kb LaunchPad w/ msp430fr5969 + lpmsp430g2231 msp430g2231 1Mhz 2Kb 128B LaunchPad w/ msp430g2231 (1MHz) + lpmsp430g2452 msp430g2452 16Mhz 8Kb 256B LaunchPad w/ msp430g2452 (16MHz) + lpmsp430g2553 msp430g2553 16Mhz 16Kb 512B LaunchPad w/ msp430g2553 (16MHz) + diff --git a/docs/userguide/cmd_init.rst b/docs/userguide/cmd_init.rst index fb2ac331..295d2b89 100644 --- a/docs/userguide/cmd_init.rst +++ b/docs/userguide/cmd_init.rst @@ -32,8 +32,27 @@ Options .. option:: --project-dir, -d -Specified path to the directory where *PlatformIO* will initialize new project. +A path to the directory where *PlatformIO* will initialise new project. +.. option:: + --board, -b + +If you specify board ``type`` (you can pass multiple ``--board`` options), then +*PlatformIO* will automatically generate environment for :ref:`projectconf` and +pre-fill these data: + +* :ref:`projectconf_env_platform` +* :ref:`projectconf_env_framework` +* :ref:`projectconf_env_board` + +The full list with pre-configured boards is available here :ref:`platforms`. + +.. option:: + --disable-auto-uploading + +If you initialise project with the specified ``--board``, then *PlatformIO* +will create environment with enabled firmware auto-uploading. This option +allows you to disable firmware auto-uploading by default. Examples -------- @@ -43,6 +62,7 @@ Examples .. code-block:: bash $ platformio init + The current working directory *** will be used for the new project. You can specify another project directory via `platformio init -d %PATH_TO_THE_PROJECT_DIR%` command. @@ -61,6 +81,21 @@ Examples .. code-block:: bash $ platformio init -d %PATH_TO_DIR% + + The next files/directories will be created in *** + platformio.ini - Project Configuration File + src - a source directory. Put your source code here + lib - a directory for the project specific libraries + Do you want to continue? [y/N]: y + Project has been successfully initialized! + Now you can process it with `platformio run` command. + +3. Initialise project for Arduino Uno + +.. code-block:: bash + + $ platformio init --board uno + The next files/directories will be created in *** platformio.ini - Project Configuration File src - a source directory. Put your source code here diff --git a/docs/userguide/index.rst b/docs/userguide/index.rst index 59eab5a8..a2db09ce 100644 --- a/docs/userguide/index.rst +++ b/docs/userguide/index.rst @@ -14,6 +14,7 @@ To print all available commands and options use: .. toctree:: :maxdepth: 2 + cmd_boards cmd_init cmd_install platformio lib diff --git a/docs/userguide/lib/cmd_install.rst b/docs/userguide/lib/cmd_install.rst index b31a6b04..854401b7 100644 --- a/docs/userguide/lib/cmd_install.rst +++ b/docs/userguide/lib/cmd_install.rst @@ -17,7 +17,7 @@ Description ----------- Install new library by specified -`PlatformIO Library Registry ID `_. +`PlatformIO Library Registry ID `_. Options ------- @@ -35,7 +35,7 @@ Examples .. code-block:: bash - # IRremote: http://platformio.ikravets.com/#!/lib/show/4/IRremote + # IRremote: http://platformio.org/#!/lib/show/4/IRremote $ platformio lib install 4 # Installing library [ 4 ]: # Downloading [####################################] 100% @@ -47,7 +47,7 @@ Examples .. code-block:: bash - # XBee: http://platformio.ikravets.com/#!/lib/show/6/XBee + # XBee: http://platformio.org/#!/lib/show/6/XBee $ platformio lib install 6 --version=0.5 # Installing library [ 6 ]: # Downloading [####################################] 100% @@ -59,7 +59,7 @@ Examples .. code-block:: bash - # Adafruit-ST7735: http://platformio.ikravets.com/#!/lib/show/12/Adafruit-ST7735 + # Adafruit-ST7735: http://platformio.org/#!/lib/show/12/Adafruit-ST7735 $ platformio lib install 12 # Installing library [ 12 ]: # Downloading [####################################] 100% diff --git a/docs/userguide/lib/cmd_search.rst b/docs/userguide/lib/cmd_search.rst index 3156c0ee..84899256 100644 --- a/docs/userguide/lib/cmd_search.rst +++ b/docs/userguide/lib/cmd_search.rst @@ -16,7 +16,7 @@ Usage Description ----------- -Search for library in `PlatformIO Library Registry `_ +Search for library in `PlatformIO Library Registry `_ by :ref:`library_config` fields in the boolean mode. The boolean search capability supports the following operators: @@ -108,7 +108,7 @@ Examples # Show next libraries? [y/N]: # ... -2. Search for `1-Wire libraries `_ +2. Search for `1-Wire libraries `_ .. code-block:: bash @@ -120,7 +120,7 @@ Examples # [ 1 ] OneWire arduino, atmelavr "Paul Stoffregen": Control devices (from Dallas Semiconductor) that use the One Wire protocol (DS18S20, DS18B20, DS2408 and etc) # ... -3. Search for `Arduino-based "I2C" libraries `_ +3. Search for `Arduino-based "I2C" libraries `_ .. code-block:: bash @@ -135,7 +135,7 @@ Examples # [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) # ... -4. Search for `libraries by "web" and "http" keywords `_. +4. Search for `libraries by "web" and "http" keywords `_. .. code-block:: bash @@ -148,7 +148,7 @@ Examples # [ 17 ] Adafruit-CC3000 arduino, atmelavr "Adafruit Industries": Library code for Adafruit's CC3000 Wi-Fi/WiFi breakouts # ... -5. Search for `libraries from "Adafruit Industries" author `_ +5. Search for `libraries by "Adafruit Industries" author `_ .. code-block:: bash @@ -163,7 +163,7 @@ Examples # [ 26 ] Adafruit-LSM303DLHC-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) # ... -6. Search for `libraries that are compatible with Dallas temperature sensors `_ +6. Search for `libraries which are compatible with Dallas temperature sensors `_ like DS18B20, DS18S20 and etc. .. code-block:: bash @@ -176,16 +176,38 @@ Examples # [ 1 ] OneWire arduino, atmelavr "Paul Stoffregen": Control devices (from Dallas Semiconductor) that use the One Wire protocol (DS18S20, DS18B20, DS2408 and etc) # ... -7. Search for `Arduino-based *X10* or *XBee* libraries `_. +7. Search for `Energia-based *nRF24* or *HttpClient* libraries `_. The search query that is described below can be interpreted like - ``arduino x10 OR arduino xbee`` + ``energia nRF24 OR energia HttpClient`` .. code-block:: bash - $ platformio lib search "+(x10 xbee)" --framework="arduino" + $ platformio lib search "+(nRF24 HttpClient)" --framework="energia" # Found 2 libraries: # # [ ID ] Name Compatibility "Authors": Description # ------------------------------------------------------------------------------------- - # [ 36 ] X10 arduino, atmelavr "Doug Clinton": Sending X10 signals over AC power lines (PL513, TW523 and etc) - # [ 6 ] XBee arduino, atmelavr "Andrew Rapp": Arduino library for communicating with XBees in API mode + # [ 46 ] HttpClient energia, timsp430, titiva "Zack Lalanne": HttpClient is a library to make it easier to interact with web servers + # [ 43 ] nRF24 energia, timsp430 "Eric": The nRF24L01 is a low-cost 2.4GHz ISM transceiver module. It supports a number of channel frequencies in the 2.4GHz band and a range of data rates. + + +8. Search for the `all sensor libraries excluding temperature `_. + +.. code-block:: bash + + $ platformio lib search "sensor -temperature" + # Found N libraries: + # + # [ ID ] Name Compatibility "Authors": Description + # ------------------------------------------------------------------------------------- + # [ 31 ] Adafruit-Unified-Sensor arduino, atmelavr "Adafruit Industries": Adafruit Unified Sensor Driver + # [ 10 ] I2Cdevlib-AK8975 arduino, atmelavr "Jeff Rowberg": AK8975 is 3-axis electronic compass IC with high sensitive Hall sensor technology + # [ 14 ] Adafruit-9DOF-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the Adafruit 9DOF Breakout (L3GD20 / LSM303) + # [ 23 ] Adafruit-L3GD20-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for the L3GD20 Gyroscope + # [ 26 ] Adafruit-LSM303DLHC-Unified arduino, atmelavr "Adafruit Industries": Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) + # [ 33 ] Adafruit-TMP006 arduino, atmelavr "Adafruit Industries": A library for the Adafruit TMP006 Infrared Thermopile Sensor + # [ 34 ] Adafruit-TSL2561-Unified arduino, atmelavr "Adafruit Industries": Unified light sensor driver for Adafruit's TSL2561 breakouts + # [ 97 ] I2Cdevlib-BMA150 arduino, atmelavr "Jeff Rowberg": The BMA150 is a triaxial, low-g acceleration sensor IC with digital output for consumer market applications + # [ 106 ] I2Cdevlib-MPR121 arduino, atmelavr "Jeff Rowberg": The MPR121 is a 12-bit proximity capacitive touch sensor + # [ 111 ] I2Cdevlib-AK8975 energia, timsp430 "Jeff Rowberg": AK8975 is 3-axis electronic compass IC with high sensitive Hall sensor technology + # Show next libraries? [y/N]: diff --git a/docs/userguide/lib/cmd_show.rst b/docs/userguide/lib/cmd_show.rst index 669acac6..8c4730a4 100644 --- a/docs/userguide/lib/cmd_show.rst +++ b/docs/userguide/lib/cmd_show.rst @@ -24,7 +24,7 @@ Examples .. code-block:: bash - # OneWire: http://platformio.ikravets.com/#!/lib/show/1/OneWire + # OneWire: http://platformio.org/#!/lib/show/1/OneWire $ platformio lib show 1 # OneWire # ------- diff --git a/docs/userguide/lib/cmd_uninstall.rst b/docs/userguide/lib/cmd_uninstall.rst index b98025ed..c2a3d327 100644 --- a/docs/userguide/lib/cmd_uninstall.rst +++ b/docs/userguide/lib/cmd_uninstall.rst @@ -24,6 +24,6 @@ Examples .. code-block:: bash - # XBee: http://platformio.ikravets.com/#!/lib/show/6/XBee + # XBee: http://platformio.org/#!/lib/show/6/XBee $ platformio lib uninstall 6 # The library #6 'XBee' has been successfully uninstalled! diff --git a/platformio/__init__.py b/platformio/__init__.py index aa63e746..acddb2e5 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,18 +1,18 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (0, 9, 2) +VERSION = (0, 10, 0) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" __description__ = ("A cross-platform code builder and " "the missing library manager") -__url__ = "http://platformio.ikravets.com" +__url__ = "http://platformio.org" __author__ = "Ivan Kravets" __email__ = "me@ikravets.com" __license__ = "MIT License" -__copyright__ = "Copyright (C) 2014 Ivan Kravets" +__copyright__ = "Copyright (C) 2014-2015 Ivan Kravets" -__apiurl__ = "http://api.platformio.ikravets.com" +__apiurl__ = "http://api.platformio.org" diff --git a/platformio/boards/arduino.json b/platformio/boards/arduino.json new file mode 100644 index 00000000..3e86b106 --- /dev/null +++ b/platformio/boards/arduino.json @@ -0,0 +1,540 @@ +{ + "LilyPadUSB": { + "build": { + "board": "AVR_LILYPAD_USB", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega32u4", + "pid": "0x9208", + "usb_product": "LilyPad USB", + "variant": "leonardo", + "vid": "0x1B4F" + }, + "name": "LilyPad Arduino USB", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + } + }, + "atmegangatmega168": { + "build": { + "board": "AVR_NG", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168", + "variant": "standard" + }, + "name": "Arduino NG or older ATmega168", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "atmegangatmega8": { + "build": { + "board": "AVR_NG", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega8", + "variant": "standard" + }, + "name": "Arduino NG or older ATmega8", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 7168, + "protocol": "arduino", + "speed": 19200 + } + }, + "btatmega168": { + "build": { + "board": "AVR_BT", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino BT ATmega168", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "btatmega328": { + "build": { + "board": "AVR_BT", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "name": "Arduino BT ATmega328", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2048, + "maximum_size": 28672, + "protocol": "arduino", + "speed": 19200 + } + }, + "diecimilaatmega168": { + "build": { + "board": "AVR_DUEMILANOVE", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168", + "variant": "standard" + }, + "name": "Arduino Duemilanove or Diecimila ATmega168", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "diecimilaatmega328": { + "build": { + "board": "AVR_DUEMILANOVE", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "name": "Arduino Duemilanove or Diecimila ATmega328", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "speed": 57600 + } + }, + "esplora": { + "build": { + "board": "AVR_ESPLORA", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega32u4", + "pid": "0x803c", + "usb_product": "Arduino Esplora", + "variant": "leonardo", + "vid": "0x2341" + }, + "name": "Arduino Esplora", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + } + }, + "ethernet": { + "build": { + "board": "AVR_ETHERNET", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "ethernet" + }, + "name": "Arduino Ethernet", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32256, + "protocol": "arduino", + "speed": 115200 + } + }, + "fio": { + "build": { + "board": "AVR_FIO", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "name": "Arduino Fio", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "speed": 57600 + } + }, + "leonardo": { + "build": { + "board": "AVR_LEONARDO", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega32u4", + "pid": "0x8036", + "usb_product": "Arduino Leonardo", + "variant": "leonardo", + "vid": "0x2341" + }, + "name": "Arduino Leonardo", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + } + }, + "lilypadatmega168": { + "build": { + "board": "AVR_LILYPAD", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega168", + "variant": "standard" + }, + "name": "LilyPad Arduino ATmega168", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "lilypadatmega328": { + "build": { + "board": "AVR_LILYPAD", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "name": "LilyPad Arduino ATmega328", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "speed": 57600 + } + }, + "megaADK": { + "build": { + "board": "AVR_ADK", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega2560", + "variant": "mega" + }, + "name": "Arduino Mega ADK", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 253952, + "protocol": "wiring", + "speed": 115200 + } + }, + "megaatmega1280": { + "build": { + "board": "AVR_MEGA", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega1280", + "variant": "mega" + }, + "name": "Arduino Mega or Mega 2560 ATmega1280", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 126976, + "protocol": "arduino", + "speed": 57600 + } + }, + "megaatmega2560": { + "build": { + "board": "AVR_MEGA2560", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega2560", + "variant": "mega" + }, + "name": "Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 253952, + "protocol": "wiring", + "speed": 115200 + } + }, + "micro": { + "build": { + "board": "AVR_MICRO", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega32u4", + "pid": "0x8037", + "usb_product": "Arduino Micro", + "variant": "micro", + "vid": "0x2341" + }, + "name": "Arduino Micro", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + } + }, + "miniatmega168": { + "build": { + "board": "AVR_MINI", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Mini ATmega168", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "miniatmega328": { + "build": { + "board": "AVR_MINI", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "name": "Arduino Mini ATmega328", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 28672, + "protocol": "arduino", + "speed": 115200 + } + }, + "nanoatmega168": { + "build": { + "board": "AVR_NANO", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Nano ATmega168", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "nanoatmega328": { + "build": { + "board": "AVR_NANO", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "name": "Arduino Nano ATmega328", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "speed": 57600 + } + }, + "pro16MHzatmega168": { + "build": { + "board": "AVR_PRO", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Pro or Pro Mini ATmega168 (5V, 16 MHz)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "pro16MHzatmega328": { + "build": { + "board": "AVR_PRO", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "name": "Arduino Pro or Pro Mini ATmega328 (5V, 16 MHz)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "speed": 57600 + } + }, + "pro8MHzatmega168": { + "build": { + "board": "AVR_PRO", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Pro or Pro Mini ATmega168 (3.3V, 8 MHz)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "pro8MHzatmega328": { + "build": { + "board": "AVR_PRO", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "name": "Arduino Pro or Pro Mini ATmega328 (3.3V, 8 MHz)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "speed": 57600 + } + }, + "robotControl": { + "build": { + "board": "AVR_ROBOT_CONTROL", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega32u4", + "pid": "0x8038", + "usb_product": "Robot Control", + "variant": "robot_control", + "vid": "0x2341" + }, + "name": "Arduino Robot Control", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + } + }, + "robotMotor": { + "build": { + "board": "AVR_ROBOT_MOTOR", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega32u4", + "pid": "0x8039", + "usb_product": "Robot Motor", + "variant": "robot_motor", + "vid": "0x2341" + }, + "name": "Arduino Robot Motor", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + } + }, + "uno": { + "build": { + "board": "AVR_UNO", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "name": "Arduino Uno", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32256, + "protocol": "arduino", + "speed": 115200 + } + }, + "yun": { + "build": { + "board": "AVR_YUN", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega32u4", + "pid": "0x8041", + "usb_product": "Arduino Yun", + "variant": "yun", + "vid": "0x2341" + }, + "name": "Arduino Yun", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "via_ssh": true, + "wait_for_upload_port": true + } + } +} \ No newline at end of file diff --git a/platformio/boards/engduino.json b/platformio/boards/engduino.json new file mode 100644 index 00000000..0d45a52c --- /dev/null +++ b/platformio/boards/engduino.json @@ -0,0 +1,71 @@ +{ + "engduinov1": { + "build": { + "board": "AVR_ENGDUINOV1", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega32u4", + "pid": "0x9208", + "usb_product": "EngduinoV1", + "variant": "engduinov1", + "vid": "0x1B4F" + }, + "name": "Engduino 1", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + } + }, + "engduinov2": { + "build": { + "board": "AVR_ENGDUINOV2", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega32u4", + "pid": "0x9208", + "usb_product": "EngduinoV2", + "variant": "engduinov2", + "vid": "0x1B4F" + }, + "name": "Engduino 2", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + } + }, + "engduinov3": { + "build": { + "board": "AVR_ENGDUINOV3", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega32u4", + "pid": "0x9208", + "usb_product": "EngduinoV3", + "variant": "engduinov3", + "vid": "0x1B4F" + }, + "name": "Engduino 3", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + } + } +} \ No newline at end of file diff --git a/platformio/boards/microduino.json b/platformio/boards/microduino.json new file mode 100644 index 00000000..4799e105 --- /dev/null +++ b/platformio/boards/microduino.json @@ -0,0 +1,160 @@ +{ + "1284p16m": { + "build": { + "board": "AVR_MICRODUINO_CORE_PLUS", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega1284p", + "variant": "plus" + }, + "name": "Microduino Core+ (ATmega1284P@16M,5V)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 130048, + "protocol": "arduino", + "speed": 115200 + } + }, + "1284p8m": { + "build": { + "board": "AVR_MICRODUINO_CORE_PLUS", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega1284p", + "variant": "plus" + }, + "name": "Microduino Core+ (ATmega1284P@8M,3.3V)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 130048, + "protocol": "arduino", + "speed": 57600 + } + }, + "168pa16m": { + "build": { + "board": "AVR_MICRODUINO_CORE", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168p", + "variant": "standard" + }, + "name": "Microduino Core (Atmega168PA@16M,5V)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 15872, + "protocol": "arduino", + "speed": 115200 + } + }, + "168pa8m": { + "build": { + "board": "AVR_MICRODUINO_CORE", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega168p", + "variant": "standard" + }, + "name": "Microduino Core (Atmega168PA@8M,3.3V)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 15872, + "protocol": "arduino", + "speed": 57600 + } + }, + "328p16m": { + "build": { + "board": "AVR_MICRODUINO_CORE", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "name": "Microduino Core (Atmega328P@16M,5V)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32256, + "protocol": "arduino", + "speed": 115200 + } + }, + "328p8m": { + "build": { + "board": "AVR_MICRODUINO_CORE", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "name": "Microduino Core (Atmega328P@8M,3.3V)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32256, + "protocol": "arduino", + "speed": 57600 + } + }, + "32u416m": { + "build": { + "board": "AVR_MICRODUINO_CORE_USB", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega32u4", + "pid": "0x8036", + "variant": "32u4", + "vid": "0x2341" + }, + "name": "Microduino Core USB (ATmega32U4@16M,5V)", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + } + }, + "644pa16m": { + "build": { + "board": "AVR_MICRODUINO_CORE_PLUS", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega644p", + "variant": "plus" + }, + "name": "Microduino Core+ (Atmega644PA@16M,5V)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 4096, + "maximum_size": 64512, + "protocol": "arduino", + "speed": 115200 + } + }, + "644pa8m": { + "build": { + "board": "AVR_MICRODUINO_CORE_PLUS", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega644p", + "variant": "plus" + }, + "name": "Microduino Core+ (Atmega644PA@8M,3.3V)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 4096, + "maximum_size": 64512, + "protocol": "arduino", + "speed": 57600 + } + } +} \ No newline at end of file diff --git a/platformio/boards/misc.json b/platformio/boards/misc.json new file mode 100644 index 00000000..c9d378fa --- /dev/null +++ b/platformio/boards/misc.json @@ -0,0 +1,19 @@ +{ + "raspduino": { + "build": { + "board": "AVR_RASPDUINO", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "name": "Raspduino", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "speed": 57600 + } + } +} \ No newline at end of file diff --git a/platformio/boards/timsp430.json b/platformio/boards/timsp430.json new file mode 100644 index 00000000..87051331 --- /dev/null +++ b/platformio/boards/timsp430.json @@ -0,0 +1,107 @@ +{ + "lpmsp430f5529": { + "build": { + "core": "msp430", + "f_cpu": "16000000L", + "mcu": "msp430f5529", + "variant": "launchpad_f5529" + }, + "name": "LaunchPad w/ msp430f5529 (16MHz)", + "platform": "timsp430", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 131072, + "protocol": "tilib" + } + }, + "lpmsp430f5529_25": { + "build": { + "core": "msp430", + "f_cpu": "25000000L", + "mcu": "msp430f5529", + "variant": "launchpad_f5529" + }, + "name": "LaunchPad w/ msp430f5529 (25MHz)", + "platform": "timsp430", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 131072, + "protocol": "tilib" + } + }, + "lpmsp430fr5739": { + "build": { + "core": "msp430", + "f_cpu": "16000000L", + "mcu": "msp430fr5739", + "variant": "fraunchpad" + }, + "name": "FraunchPad w/ msp430fr5739", + "platform": "timsp430", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 15872, + "protocol": "rf2500" + } + }, + "lpmsp430fr5969": { + "build": { + "core": "msp430", + "f_cpu": "8000000L", + "mcu": "msp430fr5969", + "variant": "launchpad_fr5969" + }, + "name": "LaunchPad w/ msp430fr5969", + "platform": "timsp430", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 65536, + "protocol": "tilib" + } + }, + "lpmsp430g2231": { + "build": { + "core": "msp430", + "f_cpu": "1000000L", + "mcu": "msp430g2231", + "variant": "launchpad" + }, + "name": "LaunchPad w/ msp430g2231 (1MHz)", + "platform": "timsp430", + "upload": { + "maximum_ram_size": 128, + "maximum_size": 2048, + "protocol": "rf2500" + } + }, + "lpmsp430g2452": { + "build": { + "core": "msp430", + "f_cpu": "16000000L", + "mcu": "msp430g2452", + "variant": "launchpad" + }, + "name": "LaunchPad w/ msp430g2452 (16MHz)", + "platform": "timsp430", + "upload": { + "maximum_ram_size": 256, + "maximum_size": 8192, + "protocol": "rf2500" + } + }, + "lpmsp430g2553": { + "build": { + "core": "msp430", + "f_cpu": "16000000L", + "mcu": "msp430g2553", + "variant": "launchpad" + }, + "name": "LaunchPad w/ msp430g2553 (16MHz)", + "platform": "timsp430", + "upload": { + "maximum_ram_size": 512, + "maximum_size": 16384, + "protocol": "rf2500" + } + } +} \ No newline at end of file diff --git a/platformio/boards/titiva.json b/platformio/boards/titiva.json new file mode 100644 index 00000000..acccb418 --- /dev/null +++ b/platformio/boards/titiva.json @@ -0,0 +1,47 @@ +{ + "lplm4f120h5qr": { + "build": { + "core": "lm4f", + "f_cpu": "80000000L", + "ldscript": "lm4fcpp_blizzard.ld", + "mcu": "cortex-m4", + "variant": "stellarpad" + }, + "name": "LaunchPad (Stellaris) w/ lm4f120 (80MHz)", + "platform": "titiva", + "upload": { + "maximum_ram_size": 32768, + "maximum_size": 262144 + } + }, + "lptm4c1230c3pm": { + "build": { + "core": "lm4f", + "f_cpu": "80000000L", + "ldscript": "lm4fcpp_blizzard.ld", + "mcu": "cortex-m4", + "variant": "stellarpad" + }, + "name": "LaunchPad (Tiva C) w/ tm4c123 (80MHz)", + "platform": "titiva", + "upload": { + "maximum_ram_size": 32768, + "maximum_size": 262144 + } + }, + "lptm4c1294ncpdt": { + "build": { + "core": "lm4f", + "f_cpu": "120000000L", + "ldscript": "lm4fcpp_snowflake.ld", + "mcu": "cortex-m4", + "variant": "launchpad_129" + }, + "name": "LaunchPad (Tiva C) w/ tm4c129 (120MHz)", + "platform": "titiva", + "upload": { + "maximum_ram_size": 262144, + "maximum_size": 1048576 + } + } +} \ No newline at end of file diff --git a/platformio/builder/main.py b/platformio/builder/main.py index d2cac107..a69a31d0 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -2,22 +2,20 @@ # See LICENSE for details. try: - from platformio.util import get_home_dir + from platformio import util except ImportError: import sys for _path in sys.path: if "platformio" in _path: sys.path.insert(0, _path[:_path.rfind("platformio")-1]) break - from platformio.util import get_home_dir + from platformio import util from os.path import join from SCons.Script import (DefaultEnvironment, SConscript, SConscriptChdir, Variables) -from platformio.util import (get_lib_dir, get_pioenvs_dir, get_project_dir, - get_source_dir) # AllowSubstExceptions() @@ -50,28 +48,43 @@ commonvars.AddVariables( ) DefaultEnvironment( - # Temporary fix for the issue #18 - tools=["default", "gcc", "g++", "ar", "gnulink", "platformio"], + tools=["gcc", "g++", "ar", "gnulink", "platformio"], toolpath=[join("$PIOBUILDER_DIR", "tools")], variables=commonvars, - PIOHOME_DIR=get_home_dir(), - PROJECT_DIR=get_project_dir(), - PIOENVS_DIR=get_pioenvs_dir(), + PIOHOME_DIR=util.get_home_dir(), + PROJECT_DIR=util.get_project_dir(), + PIOENVS_DIR=util.get_pioenvs_dir(), - PIOBUILDER_DIR=join(get_source_dir(), "builder"), + PIOBUILDER_DIR=join(util.get_source_dir(), "builder"), PIOPACKAGES_DIR=join("$PIOHOME_DIR", "packages"), PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_FRAMEWORK"), BUILD_DIR=join("$PIOENVS_DIR", "$PIOENV"), LIBSOURCE_DIRS=[ join("$PROJECT_DIR", "lib"), - get_lib_dir(), + util.get_lib_dir(), join("$PLATFORMFW_DIR", "libraries"), ] ) env = DefaultEnvironment() + +if "BOARD" in env: + try: + env.Replace(BOARD_OPTIONS=util.get_boards(env.subst("$BOARD"))) + except KeyError: + env.Exit("Error: Unknown board '%s'" % env.subst("$BOARD")) + + 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']['protocol']}") + if "UPLOAD_SPEED" not in env: + env.Replace(UPLOAD_SPEED="${BOARD_OPTIONS['upload']['speed']}") + env.PrependENVPath( "PATH", env.subst(join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN", "bin")) diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index cfdd2de9..2b2584a4 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -11,7 +11,7 @@ from time import sleep from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default, DefaultEnvironment, Exit) -from platformio.util import get_serialports, reset_serialport +from platformio.util import get_serialports env = DefaultEnvironment() @@ -41,7 +41,10 @@ env.Replace( "-mmcu=$BOARD_MCU" ], - CXXFLAGS=["-fno-exceptions"], + CXXFLAGS=[ + "-fno-exceptions", + "-fno-threadsafe-statics" + ], CPPDEFINES=[ "F_CPU=$BOARD_F_CPU" @@ -55,7 +58,6 @@ env.Replace( UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"), UPLOADERFLAGS=[ - "-V", # do not verify "-q", # suppress progress output "-D", # disable auto erase for flash memory "-p", "$BOARD_MCU", @@ -101,7 +103,7 @@ env.Append( ) -def reset_device(): +def before_upload(): def rpi_sysgpio(path, value): with open(path, "w") as f: @@ -115,7 +117,19 @@ def reset_device(): rpi_sysgpio("/sys/class/gpio/gpio18/value", 0) rpi_sysgpio("/sys/class/gpio/unexport", 18) else: - return reset_serialport(env.subst("$UPLOAD_PORT")) + 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) and + "UPLOAD_PORT" in env): + env.TouchSerialPort("$UPLOAD_PORT", 1200) + + if upload_options.get("wait_for_upload_port", False): + env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports)) CORELIBS = env.ProcessGeneral() @@ -147,7 +161,7 @@ else: # upload = env.Alias(["upload", "uploadlazy"], target_hex, [ - lambda target, source, env: reset_device(), "$UPLOADHEXCMD"]) + lambda target, source, env: before_upload(), "$UPLOADHEXCMD"]) AlwaysBuild(upload) # @@ -155,7 +169,7 @@ AlwaysBuild(upload) # uploadeep = env.Alias("uploadeep", target_eep, [ - lambda target, source, env: reset_device(), "$UPLOADEEPCMD"]) + lambda target, source, env: before_upload(), "$UPLOADEEPCMD"]) AlwaysBuild(uploadeep) # @@ -171,7 +185,7 @@ if is_uptarget: for item in get_serialports(): if "VID:PID" in item['hwid']: print "Auto-detected UPLOAD_PORT: %s" % item['port'] - env['UPLOAD_PORT'] = item['port'] + env.Replace(UPLOAD_PORT=item['port']) break if "UPLOAD_PORT" not in env: diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index d6f8dbf1..ca7409eb 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -12,34 +12,31 @@ from SCons.Script import Import, Return env = None Import("env") -BOARD_OPTIONS = env.ParseBoardOptions( - join("$PLATFORMFW_DIR", "boards.txt"), - "${BOARD}" -) ARDUINO_VERSION = int( open(join(env.subst("$PLATFORMFW_DIR"), "version.txt")).read().replace(".", "").strip()) # usb flags ARDUINO_USBDEFINES = [] -if "build.usb_product" in BOARD_OPTIONS: +if "usb_product" in env.subst("${BOARD_OPTIONS['build']}"): ARDUINO_USBDEFINES = [ - "USB_VID=%s" % BOARD_OPTIONS['build.vid'], - "USB_PID=%s" % BOARD_OPTIONS['build.pid'], - "USB_PRODUCT=%s" % BOARD_OPTIONS['build.usb_product'].replace('"', "") + "USB_VID=${BOARD_OPTIONS['build']['vid']}", + "USB_PID=${BOARD_OPTIONS['build']['pid']}", + 'USB_PRODUCT=\\"%s\\"' % (env.subst( + "${BOARD_OPTIONS['build']['usb_product']}").replace('"', "")) ] # include board variant env.VariantDir( join("$BUILD_DIR", "FrameworkArduinoVariant"), - join("$PLATFORMFW_DIR", "variants", BOARD_OPTIONS['build.variant']) + join("$PLATFORMFW_DIR", "variants", "${BOARD_OPTIONS['build']['variant']}") ) env.Append( CPPDEFINES=[ - "ARDUINO_ARCH_AVR", # @TODO Should be dynamic + "ARDUINO_ARCH_%s" % env.subst("$PLATFORM").upper()[-3:], "ARDUINO=%d" % ARDUINO_VERSION, - "ARDUINO_%s" % BOARD_OPTIONS['build.board'] + "ARDUINO_${BOARD_OPTIONS['build']['board']}" ] + ARDUINO_USBDEFINES, CPPPATH=[ join("$BUILD_DIR", "FrameworkArduino"), @@ -47,25 +44,16 @@ env.Append( ] ) -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.protocol']) -if "UPLOAD_SPEED" not in env: - env.Replace(UPLOAD_SPEED=BOARD_OPTIONS['upload.speed']) - - -libs = [] # # Target: Build Core Library # +libs = [] + libs.append(env.BuildLibrary( join("$BUILD_DIR", "FrameworkArduino"), - join("$PLATFORMFW_DIR", "cores", BOARD_OPTIONS['build.core']) + join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}") )) Return("libs") diff --git a/platformio/builder/scripts/frameworks/energia.py b/platformio/builder/scripts/frameworks/energia.py index e2bb8a53..45db6e7d 100644 --- a/platformio/builder/scripts/frameworks/energia.py +++ b/platformio/builder/scripts/frameworks/energia.py @@ -12,10 +12,6 @@ from SCons.Script import Import, Return env = None Import("env") -BOARD_OPTIONS = env.ParseBoardOptions( - join("$PLATFORMFW_DIR", "boards.txt"), - "${BOARD}" -) ENERGIA_VERSION = int( open(join(env.subst("$PLATFORMFW_DIR"), "version.txt")).read().replace(".", "").strip()) @@ -23,7 +19,7 @@ ENERGIA_VERSION = int( # include board variant env.VariantDir( join("$BUILD_DIR", "FrameworkEnergiaVariant"), - join("$PLATFORMFW_DIR", "variants", BOARD_OPTIONS['build.variant']) + join("$PLATFORMFW_DIR", "variants", "${BOARD_OPTIONS['build']['variant']}") ) env.Append( @@ -37,31 +33,25 @@ env.Append( ] ) -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 and "upload.protocol" in BOARD_OPTIONS: - env.Replace(UPLOAD_PROTOCOL=BOARD_OPTIONS['upload.protocol']) - # specific linker script for TIVA devices -if "ldscript" in BOARD_OPTIONS: +if "ldscript" in env.subst("${BOARD_OPTIONS['build']}"): env.Append( - LINKFLAGS=["-T", join("$PLATFORMFW_DIR", "cores", - BOARD_OPTIONS['build.core'], - BOARD_OPTIONS['ldscript'])] + LINKFLAGS=["-T", join( + "$PLATFORMFW_DIR", "cores", + "${BOARD_OPTIONS['build']['core']}", + "${BOARD_OPTIONS['build']['ldscript']}")] ) -libs = [] - # # Target: Build Core Library # +libs = [] + libs.append(env.BuildLibrary( join("$BUILD_DIR", "FrameworkEnergia"), - join("$PLATFORMFW_DIR", "cores", BOARD_OPTIONS['build.core']) + join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}") )) Return("libs") diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 3304598b..d76eea5f 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -2,11 +2,16 @@ # See LICENSE for details. import atexit +import platform import re from os import getenv, listdir, remove, walk from os.path import basename, isdir, isfile, join +from time import sleep -from SCons.Script import SConscript, SConscriptChdir +from SCons.Script import Exit, SConscript, SConscriptChdir +from serial import Serial + +from platformio.util import get_serialports def ProcessGeneral(env): @@ -16,7 +21,7 @@ def ProcessGeneral(env): if "FRAMEWORK" in env: if env['FRAMEWORK'] in ("arduino", "energia"): - env.ConvertInotoCpp() + env.ConvertInoToCpp() SConscriptChdir(0) corelibs = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "frameworks", "${FRAMEWORK}.py")), @@ -29,7 +34,7 @@ def BuildFirmware(env, corelibs): vdirs = src.VariantDirRecursive( join("$BUILD_DIR", "src"), join("$PROJECT_DIR", "src")) - # build source's dependent libs + # build dependent libs deplibs = [] for vdir in vdirs: deplibs += src.BuildDependentLibraries(vdir) @@ -78,16 +83,23 @@ def BuildDependentLibraries(env, src_dir): def GetDependentLibraries(env, src_dir): includes = {} regexp = re.compile(r"^\s*#include\s+(?:\<|\")([^\>\"\']+)(?:\>|\")", re.M) - for node in env.GlobCXXFiles(src_dir): + nodes = env.GlobCXXFiles(src_dir) + env.Glob(join(src_dir, "*.h")) + for node in nodes: env.ParseIncludesRecurive(regexp, node, includes) includes = sorted(includes.items(), key=lambda s: s[0]) result = [] for i in includes: - item = (i[1][1], i[1][2]) - if item in result: - continue - result.append(item) + items = [(i[1][1], i[1][2])] + + if isdir(join(items[0][1], "utility")): + items.append(("%sUtility" % items[0][0], + join(items[0][1], "utility"))) + + for item in items: + if item in result: + continue + result.append(item) return result @@ -126,39 +138,7 @@ def VariantDirRecursive(env, variant_dir, src_dir, duplicate=True): return variants -def ParseBoardOptions(env, path, name): - path = env.subst(path) - name = env.subst(name) - if not isfile(path): - env.Exit("Invalid path to boards.txt -> %s" % path) - - data = {} - with open(path) as f: - for line in f: - if not line.strip() or line[0] == "#": - continue - - _group = line[:line.index(".")] - _cpu = name[len(_group):] - line = line[len(_group)+1:].strip() - if _group != name[:len(_group)]: - continue - elif "menu.cpu." in line: - if _cpu not in line: - continue - else: - line = line[len(_cpu)+10:] - - if "=" in line: - opt, value = line.split("=", 1) - data[opt] = value - if not data: - env.Exit("Unknown Board '%s'" % name) - else: - return data - - -def ConvertInotoCpp(env): +def ConvertInoToCpp(env): def delete_tmpcpp(files): for f in files: @@ -206,6 +186,47 @@ def ConvertInotoCpp(env): 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 exists(_): return True @@ -219,6 +240,8 @@ def generate(env): env.AddMethod(GetDependentLibraries) env.AddMethod(ParseIncludesRecurive) env.AddMethod(VariantDirRecursive) - env.AddMethod(ParseBoardOptions) - env.AddMethod(ConvertInotoCpp) + env.AddMethod(ConvertInoToCpp) + env.AddMethod(FlushSerialBuffer) + env.AddMethod(TouchSerialPort) + env.AddMethod(WaitForNewSerialPort) return env diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py new file mode 100644 index 00000000..77cbbb21 --- /dev/null +++ b/platformio/commands/boards.py @@ -0,0 +1,60 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +import json + +import click + +from platformio.util import get_boards + + +@click.command("list", short_help="Pre-configured Embedded Boards") +@click.argument("query", required=False) +def cli(query): + + BOARDLIST_TPL = ("{type:<30} {mcu:<13} {frequency:<8} " + " {flash:<7} {ram:<6} {name}") + + grpboards = {} + for type_, data in get_boards().items(): + if data['platform'] not in grpboards: + grpboards[data['platform']] = {} + grpboards[data['platform']][type_] = data + + for (platform, boards) in grpboards.items(): + if query: + search_data = json.dumps(boards).lower() + if query.lower() not in search_data.lower(): + continue + + click.echo("\nPlatform: %s" % platform) + click.echo("-" * 75) + click.echo(BOARDLIST_TPL.format( + type=click.style("Type", fg="cyan"), mcu="MCU", + frequency="Frequency", flash="Flash", ram="RAM", name="Name")) + click.echo("-" * 75) + + for type_, data in sorted(boards.items(), key=lambda b: b[1]['name']): + if query: + search_data = "%s %s" % (type_, json.dumps(data).lower()) + if query.lower() not in search_data.lower(): + continue + + flash_size = "" + if "maximum_size" in data.get("upload", None): + flash_size = int(data['upload']['maximum_size']) + flash_size = "%dKb" % (flash_size / 1024) + + ram_size = "" + if "maximum_ram_size" in data.get("upload", None): + ram_size = int(data['upload']['maximum_ram_size']) + if ram_size >= 1024: + ram_size = "%dKb" % (ram_size / 1024) + else: + ram_size = "%dB" % ram_size + + click.echo(BOARDLIST_TPL.format( + type=click.style(type_, fg="cyan"), mcu=data['build']['mcu'], + frequency="%dMhz" % (int(data['build']['f_cpu'][:-1]) + / 1000000), + flash=flash_size, ram=ram_size, name=data['name'])) diff --git a/platformio/commands/init.py b/platformio/commands/init.py index 986d784c..10e0fb2f 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -8,15 +8,17 @@ from shutil import copyfile import click from platformio import app -from platformio.exception import ProjectInitialized -from platformio.util import get_source_dir +from platformio.exception import ProjectInitialized, UnknownBoard +from platformio.util import get_boards, get_source_dir @click.command("init", short_help="Initialize new PlatformIO based project") @click.option("--project-dir", "-d", default=getcwd(), type=click.Path(exists=True, file_okay=False, dir_okay=True, writable=True, resolve_path=True)) -def cli(project_dir): +@click.option("--board", "-b", multiple=True, metavar="TYPE") +@click.option('--disable-auto-uploading', is_flag=True) +def cli(project_dir, board, disable_auto_uploading): project_file = join(project_dir, "platformio.ini") src_dir = join(project_dir, "src") @@ -24,6 +26,10 @@ def cli(project_dir): if all([isfile(project_file), isdir(src_dir), isdir(lib_dir)]): raise ProjectInitialized() + builtin_boards = set(get_boards().keys()) + if board and not set(board).issubset(builtin_boards): + raise UnknownBoard(", ".join(set(board).difference(builtin_boards))) + if project_dir == getcwd(): click.secho("The current working directory", fg="yellow", nl=False) click.secho(" %s " % project_dir, fg="cyan", nl=False) @@ -51,6 +57,8 @@ def cli(project_dir): if not isfile(project_file): copyfile(join(get_source_dir(), "projectconftpl.ini"), project_file) + if board: + fill_project_envs(project_file, board, disable_auto_uploading) click.secho( "Project has been successfully initialized!\n" "Now you can process it with `platformio run` command.", @@ -58,3 +66,31 @@ def cli(project_dir): ) else: click.secho("Aborted by user", fg="red") + + +def fill_project_envs(project_file, board_types, disable_auto_uploading): + builtin_boards = get_boards() + content = [] + for type_ in board_types: + if type_ not in builtin_boards: + continue + else: + content.append("") + + data = builtin_boards[type_] + framework = data.get("build", {}).get("core", None) + if framework in ("msp430", "lm4f"): + framework = "energia" + + content.append("[env:autogen_%s]" % type_) + content.append("platform = %s" % data['platform']) + + if framework: + content.append("framework = %s" % framework) + content.append("board = %s" % type_) + + content.append("%stargets = upload" % "# " if disable_auto_uploading + else "") + + with open(project_file, "a") as f: + f.write("\n".join(content)) diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index 67f61827..1c4bebde 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -3,9 +3,7 @@ import click -from platformio import app -from platformio.exception import (LibAlreadyInstalledError, - LibInstallDependencyError) +from platformio import app, exception from platformio.libmanager import LibraryManager from platformio.util import get_api_result, get_lib_dir @@ -57,6 +55,19 @@ def lib_search(query, **filters): query += ' %s:"%s"' % (key, value) result = get_api_result("/lib/search", dict(query=query)) + if result['total'] == 0: + click.secho( + "Nothing has been found by your request\n" + "Try a less-specific search or use truncation (or wildcard) " + "operator", fg="yellow", nl=False) + click.secho(" *", fg="green") + click.secho("For example: DS*, PCA*, DHT* and etc.\n", fg="yellow") + click.echo("For more examples and advanced search syntax, " + "please use documentation:") + click.secho("http://docs.platformio.org" + "/en/latest/userguide/lib/cmd_search.html\n", fg="cyan") + return + click.secho("Found %d libraries:\n" % result['total'], fg="green" if result['total'] else "yellow") @@ -107,9 +118,9 @@ def lib_install(ctx, libid, version): try: lib_install_dependency(ctx, item) except AssertionError: - raise LibInstallDependencyError(str(item)) + raise exception.LibInstallDependencyError(str(item)) - except LibAlreadyInstalledError: + except exception.LibAlreadyInstalledError: click.secho("Already installed", fg="yellow") @@ -155,7 +166,7 @@ def lib_list(): echo_liblist_item(item) -@cli.command("show", short_help="Show details about installed libraries") +@cli.command("show", short_help="Show details about installed library") @click.argument("libid", type=click.INT) def lib_show(libid): lm = LibraryManager(get_lib_dir()) @@ -221,6 +232,10 @@ def lib_update(ctx): @cli.command("register", short_help="Register new library") @click.argument("config_url") def lib_register(config_url): + if (not config_url.startswith("http://") and not + config_url.startswith("https://")): + raise exception.InvalidLibConfURL(config_url) + result = get_api_result("/lib/register", data=dict(config_url=config_url)) if "message" in result and result['message']: click.secho(result['message'], fg="green" if "successed" in result and diff --git a/platformio/commands/run.py b/platformio/commands/run.py index c45f61d6..2458b3bb 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -68,10 +68,12 @@ def process_environment(ctx, name, options, targets, upload_port): telemetry.on_run_environment(options, envtargets) - if (app.get_setting("enable_prompts") and - platform not in PlatformFactory.get_platforms(installed=True) and + installed_platforms = PlatformFactory.get_platforms( + installed=True).keys() + if (platform not in installed_platforms and ( + not app.get_setting("enable_prompts") or click.confirm("The platform '%s' has not been installed yet. " - "Would you like to install it now?" % platform)): + "Would you like to install it now?" % platform))): ctx.invoke(cmd_install, platforms=[platform]) p = PlatformFactory.newPlatform(platform) diff --git a/platformio/commands/serialports.py b/platformio/commands/serialports.py index 4a73775c..d75eba85 100644 --- a/platformio/commands/serialports.py +++ b/platformio/commands/serialports.py @@ -61,8 +61,15 @@ def serialports_list(): "miniterm (menu), default=0x14") @click.option("--quiet", is_flag=True, help="Diagnostics: suppress non-error messages, default=Off") -def serialports_monitor(**_): +def serialports_monitor(**kwargs): sys.argv = sys.argv[3:] + + if not kwargs['port']: + for item in get_serialports(): + if "VID:PID" in item['hwid']: + sys.argv += ["--port", item['port']] + break + try: miniterm.main() except: # pylint: disable=W0702 diff --git a/platformio/commands/show.py b/platformio/commands/show.py index de8769bb..989b9aaf 100644 --- a/platformio/commands/show.py +++ b/platformio/commands/show.py @@ -21,7 +21,7 @@ def cli(ctx, platform): installed=True).keys() if platform not in installed_platforms: - if (app.get_setting("enable_prompts") and + if (not app.get_setting("enable_prompts") or click.confirm("The platform '%s' has not been installed yet. " "Would you like to install it now?" % platform)): ctx.invoke(cmd_install, platforms=[platform]) diff --git a/platformio/exception.py b/platformio/exception.py index 8188a9fb..c3ef53a0 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -30,6 +30,11 @@ class UnknownCLICommand(PlatformioException): " to see all available commands") +class UnknownBoard(PlatformioException): + + MESSAGE = "Unknown board type '%s'" + + class UnknownPackage(PlatformioException): MESSAGE = "Detected unknown package '%s'" @@ -127,6 +132,11 @@ class LibInstallDependencyError(PlatformioException): MESSAGE = "Error has been occurred for library dependency '%s'" +class InvalidLibConfURL(PlatformioException): + + MESSAGE = "Invalid library config URL '%s'" + + class BuildScriptNotFound(PlatformioException): MESSAGE = "Invalid path '%s' to build script" @@ -152,5 +162,5 @@ class SConsNotInstalled(PlatformioException): MESSAGE = ( "The PlatformIO and `scons` aren't installed properly. " "Please use official installation manual: " - "http://docs.platformio.ikravets.com/en/latest/installation.html" + "http://docs.platformio.org/en/latest/installation.html" ) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index d7d620d5..dae2b648 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -92,7 +92,7 @@ def after_upgrade(ctx): "- %s us on Twitter to stay up-to-date " "on the latest project news > %s" % (click.style("follow", fg="cyan"), - click.style("https://twitter.com/platformiotool", fg="cyan")) + click.style("https://twitter.com/PlatformIO_Org", fg="cyan")) ) click.echo("- %s us a star on GitHub > %s" % ( click.style("give", fg="cyan"), @@ -140,7 +140,7 @@ def check_platformio_upgrade(): fg="yellow", nl=False) click.secho("platformio upgrade", fg="cyan", nl=False) click.secho(" command.\nChanges: ", fg="yellow", nl=False) - click.secho("http://docs.platformio.ikravets.com/en/latest/history.html\n", + click.secho("http://docs.platformio.org/en/latest/history.html\n", fg="cyan") diff --git a/platformio/projectconftpl.ini b/platformio/projectconftpl.ini index 21525446..da48cf88 100644 --- a/platformio/projectconftpl.ini +++ b/platformio/projectconftpl.ini @@ -1,10 +1,18 @@ # # Project Configuration File # -# A detailed documentation with EXAMPLES is located here: -# http://docs.platformio.ikravets.com/en/latest/projectconf.html +# A detailed documentation with the EXAMPLES is located here: +# http://docs.platformio.org/en/latest/projectconf.html # +# A sign `#` at the beginning of the line indicates a comment +# Comment lines are ignored. + # Simple and base environment -#[env:mybaseenv] -#platform = %INSTALLED_PLATFORM_NAME_HERE% +# [env:mybaseenv] +# platform = %INSTALLED_PLATFORM_NAME_HERE% +# framework = +# board = +# +# Automatic targets - enable auto-uploading +# targets = upload diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 55d1d276..6bd014dc 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -1,8 +1,10 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. +import atexit import platform import re +import threading import uuid from sys import argv as sys_argv from time import time @@ -57,14 +59,6 @@ class MeasurementProtocol(TelemetryBase): self._prefill_appinfo() self._prefill_custom_data() - @classmethod - def session_instance(cls): - try: - return cls._session_instance - except AttributeError: - cls._session_instance = requests.Session() - return cls._session_instance - def __getitem__(self, name): if name in self.PARAMS_MAP: name = self.PARAMS_MAP[name] @@ -119,22 +113,88 @@ class MeasurementProtocol(TelemetryBase): if "qt" in self._params and isinstance(self['qt'], float): self['qt'] = int((time() - self['qt']) * 1000) + MPDataPusher.get_instance().push(self._params) + + +class MPDataPusher(threading.Thread): + + @classmethod + def get_instance(cls): try: - r = self.session_instance().post( - "https://ssl.google-analytics.com/collect", - data=self._params - ) - r.raise_for_status() - except: # pylint: disable=W0702 - backup_report(self._params) - return False - return True + return cls._thinstance + except AttributeError: + cls._event = threading.Event() + cls._thinstance = cls() + cls._thinstance.start() + return cls._thinstance + + @classmethod + def http_session(cls): + try: + return cls._http_session + except AttributeError: + cls._http_session = requests.Session() + return cls._http_session + + def __init__(self): + threading.Thread.__init__(self) + self._terminate = False + self._server_online = False + self._stack = [] + + def run(self): + while not self._terminate: + self._event.wait() + if self._terminate or not self._stack: + return + self._event.clear() + + data = self._stack.pop() + try: + r = self.http_session().post( + "https://ssl.google-analytics.com/collect", + data=data, + timeout=3 + ) + r.raise_for_status() + self._server_online = True + except: # pylint: disable=W0702 + self._server_online = False + self._stack.append(data) + + def push(self, data): + self._stack.append(data) + self._event.set() + + def is_server_online(self): + return self._server_online + + def get_stack_data(self): + return self._stack + + def join(self, timeout=0.1): + self._terminate = True + self._event.set() + self.http_session().close() + threading.Thread.join(self, timeout) + + +@atexit.register +def _finalize(): + MAX_RESEND_REPORTS = 10 + mpdp = MPDataPusher.get_instance() + backup_reports(mpdp.get_stack_data()) + + resent_nums = 0 + while mpdp.is_server_online() and resent_nums < MAX_RESEND_REPORTS: + if not resend_backuped_report(): + break + resent_nums += 1 def on_command(ctx): # pylint: disable=W0613 mp = MeasurementProtocol() - if mp.send("screenview"): - resend_backuped_reports() + mp.send("screenview") def on_run_environment(options, targets): @@ -153,53 +213,54 @@ def on_event(category, action, label=None, value=None, screen_name=None): mp['event_value'] = int(value) if screen_name: mp['screen_name'] = screen_name[:2048] - return mp.send("event") + mp.send("event") def on_exception(e): mp = MeasurementProtocol() mp['exd'] = "%s: %s" % (type(e).__name__, e) mp['exf'] = 1 - return mp.send("exception") + mp.send("exception") -def backup_report(params): +def backup_reports(data): + if not data: + return + KEEP_MAX_REPORTS = 1000 tm = app.get_state_item("telemetry", {}) if "backup" not in tm: tm['backup'] = [] - # skip static options - for key in params.keys(): - if key in ("v", "tid", "cid", "cd1", "cd2", "sr", "an"): - del params[key] + for params in data: + # skip static options + for key in params.keys(): + if key in ("v", "tid", "cid", "cd1", "cd2", "sr", "an"): + del params[key] - # store time in UNIX format - if "qt" not in params: - params['qt'] = time() - elif not isinstance(params['qt'], float): - params['qt'] = time() - (params['qt'] / 1000) + # store time in UNIX format + if "qt" not in params: + params['qt'] = time() + elif not isinstance(params['qt'], float): + params['qt'] = time() - (params['qt'] / 1000) + + tm['backup'].append(params) - tm['backup'].append(params) tm['backup'] = tm['backup'][KEEP_MAX_REPORTS*-1:] app.set_state_item("telemetry", tm) -def resend_backuped_reports(): - MAX_RESEND_REPORTS = 10 +def resend_backuped_report(): + tm = app.get_state_item("telemetry", {}) + if "backup" not in tm or not tm['backup']: + return False - resent_nums = 0 - while resent_nums < MAX_RESEND_REPORTS: - tm = app.get_state_item("telemetry", {}) - if "backup" not in tm or not tm['backup']: - break + report = tm['backup'].pop() + app.set_state_item("telemetry", tm) - report = tm['backup'].pop() - app.set_state_item("telemetry", tm) - resent_nums += 1 + mp = MeasurementProtocol() + for key, value in report.items(): + mp[key] = value + mp.send(report['t']) - mp = MeasurementProtocol() - for key, value in report.items(): - mp[key] = value - if not mp.send(report['t']): - break + return True diff --git a/platformio/util.py b/platformio/util.py index 5509b1b2..a5c015f3 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -1,15 +1,14 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. +import json from os import name as os_name -from os import getcwd, getenv, makedirs, utime +from os import getcwd, getenv, listdir, makedirs, utime from os.path import dirname, expanduser, isdir, isfile, join, realpath from platform import system, uname from subprocess import PIPE, Popen -from time import sleep import requests -from serial import Serial from platformio import __apiurl__, __version__ from platformio.exception import (APIRequestError, GetSerialPortsError, @@ -94,17 +93,6 @@ def exec_command(args): return dict(out=out.strip(), err=err.strip()) -def reset_serialport(port): - s = Serial(port) - s.flushInput() - s.setDTR(False) - s.setRTS(False) - sleep(0.1) - s.setDTR(True) - s.setRTS(True) - s.close() - - def get_serialports(): if os_name == "nt": from serial.tools.list_ports_windows import comports @@ -120,12 +108,13 @@ def get_api_result(path, params=None, data=None): r = None try: + requests.packages.urllib3.disable_warnings() headers = {"User-Agent": "PlatformIO/%s %s" % ( __version__, requests.utils.default_user_agent())} # if packages - redirect to SF if path == "/packages": r = requests.get( - "https://sourceforge.net/projects/platformio-storage/files/" + "http://sourceforge.net/projects/platformio-storage/files/" "packages/manifest.json", params=params, headers=headers) elif data: r = requests.post(__apiurl__ + path, params=params, data=data, @@ -148,3 +137,19 @@ def get_api_result(path, params=None, data=None): if r: r.close() return result + + +def get_boards(type_=None): + boards = {} + bdirs = [join(get_source_dir(), "boards")] + if isdir(join(get_home_dir(), "boards")): + bdirs.append(join(get_home_dir(), "boards")) + + for bdir in bdirs: + for json_file in listdir(bdir): + if not json_file.endswith(".json"): + continue + with open(join(bdir, json_file)) as f: + boards.update(json.load(f)) + + return boards[type_] if type_ is not None else boards diff --git a/requirements.txt b/requirements.txt index f2fc32dd..cb607b15 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ click==3.3 colorama==0.3.2 pyserial==2.7 -requests==2.5.0 +requests==2.5.1 scons==2.3.0 diff --git a/setup.py b/setup.py index 00be7482..7db2c825 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ setup( # "SCons" ] + (["colorama"] if system() == "Windows" else []), packages=find_packages(), - package_data={"platformio": ["*.ini"]}, + package_data={"platformio": ["projectconftpl.ini", "boards/*.json"]}, entry_points={ "console_scripts": [ "platformio = platformio.__main__:main"