diff --git a/HISTORY.rst b/HISTORY.rst index be668065..3543d3df 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,10 +4,29 @@ Release Notes PlatformIO 2.0 -------------- +2.10.0 (2016-06-13) +~~~~~~~~~~~~~~~~~~~ + +* Added support for `emonPi `__, + the OpenEnergyMonitor system + (`issue #687 `_) +* Added support for `SPL `__ + framework for STM32F0 boards + (`issue #683 `_) +* Added support for `Arduboy DevKit `__, the game system + the size of a credit card +* Updated ARM mbed framework package to v121 +* Check program size before uploading to the board + (`issue #689 `_) +* Improved firmware uploading to Arduino Leonardo based boards + (`issue #691 `_) +* Fixed issue with ``-L relative/path`` when parsing ``build_flags`` + (`issue #688 `_) + 2.9.4 (2016-06-04) ~~~~~~~~~~~~~~~~~~ -* Show ``udev`` warning only for the Linux OS while upload firmware +* Show ``udev`` warning only for the Linux OS while uploading firmware 2.9.3 (2016-06-03) ~~~~~~~~~~~~~~~~~~ diff --git a/docs/demo.rst b/docs/demo.rst index 7d1d2c25..28dcc084 100644 --- a/docs/demo.rst +++ b/docs/demo.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present Ivan Kravets Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -19,7 +19,7 @@ Demo & Projects Project Examples ---------------- -Preconfigured demo projects are located in `PlatformIO GitHub `_ repository. +Pre-configured demo projects are located in `PlatformIO GitHub `_ repository. "Blink Project" --------------- diff --git a/docs/frameworks/arduino.rst b/docs/frameworks/arduino.rst index b4fcf0e7..f7a4877a 100644 --- a/docs/frameworks/arduino.rst +++ b/docs/frameworks/arduino.rst @@ -196,6 +196,13 @@ Arduboy - 32 Kb - 2.5 Kb + * - ``arduboy_devkit`` + - `Arduboy DevKit `_ + - ATMEGA32U4 + - 16 MHz + - 32 Kb + - 2.5 Kb + Arduino ~~~~~~~ @@ -1190,6 +1197,26 @@ OpenBCI - 128 Kb - 32 Kb +OpenEnergyMonitor +~~~~~~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``emonpi`` + - `emonPi `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + PONTECH ~~~~~~~ diff --git a/docs/index.rst b/docs/index.rst index f839bbd8..ce0d088c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,7 +19,7 @@ integration. Arduino and MBED compatible. Ready for Cloud compiling.** C/C++ Intelligent Code Completion and Smart Code Linter for the super-fast coding. Multi-projects workflow with Multiple Panes. Themes Support with dark and light colors. Built-in Terminal with PlatformIO CLI tool and support for the powerful Serial Port Monitor. - All advanced instruments without leaving your favourite development environment. + All advanced instruments without leaving your favorite development environment. * **Development Platforms** - Embedded and Desktop development platforms with pre-built toolchains, debuggers, uploaders and frameworks which work under popular host OS: Mac, Windows, Linux (+ARM) @@ -110,8 +110,7 @@ Contents platforms/index platforms/embedded_boards frameworks/index - platforms/creating_platform - platforms/creating_board + platforms/custom_platform_and_board .. toctree:: :caption: Library Manager diff --git a/docs/platforms/atmelavr.rst b/docs/platforms/atmelavr.rst index d1e26c13..58185e7c 100644 --- a/docs/platforms/atmelavr.rst +++ b/docs/platforms/atmelavr.rst @@ -186,6 +186,13 @@ Arduboy - 32 Kb - 2.5 Kb + * - ``arduboy_devkit`` + - `Arduboy DevKit `_ + - ATMEGA32U4 + - 16 MHz + - 32 Kb + - 2.5 Kb + Arduino ~~~~~~~ @@ -805,6 +812,26 @@ Microduino - 64 Kb - 4 Kb +OpenEnergyMonitor +~~~~~~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``emonpi`` + - `emonPi `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + PanStamp ~~~~~~~~ diff --git a/docs/platforms/creating_board.rst b/docs/platforms/creating_board.rst index c55b1649..55be0dbd 100644 --- a/docs/platforms/creating_board.rst +++ b/docs/platforms/creating_board.rst @@ -11,8 +11,8 @@ .. _board_creating: -Custom Board -============ +Custom Embedded Board +===================== *PlatformIO* has pre-built settings for the most popular embedded boards. This list is available: diff --git a/docs/platforms/creating_platform.rst b/docs/platforms/creating_platform.rst index d4e6d96a..913fb40d 100644 --- a/docs/platforms/creating_platform.rst +++ b/docs/platforms/creating_platform.rst @@ -11,8 +11,8 @@ .. _platform_creating: -Custom Platform -=============== +Custom Development Platform +=========================== *PlatformIO* was developed like a tool which would build the same source code for the different development platforms via single command :ref:`cmd_run` diff --git a/docs/platforms/custom_platform_and_board.rst b/docs/platforms/custom_platform_and_board.rst new file mode 100644 index 00000000..7db1381c --- /dev/null +++ b/docs/platforms/custom_platform_and_board.rst @@ -0,0 +1,19 @@ +.. Copyright 2014-present Ivan Kravets + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Custom Platform & Board +======================= + +.. toctree:: + :maxdepth: 2 + + creating_platform + creating_board diff --git a/docs/platforms/embedded_boards.rst b/docs/platforms/embedded_boards.rst index 9b755937..7095dd76 100644 --- a/docs/platforms/embedded_boards.rst +++ b/docs/platforms/embedded_boards.rst @@ -182,6 +182,13 @@ Arduboy - 32 Kb - 2.5 Kb + * - ``arduboy_devkit`` + - `Arduboy DevKit `_ + - ATMEGA32U4 + - 16 MHz + - 32 Kb + - 2.5 Kb + Arduino ~~~~~~~ @@ -1555,6 +1562,26 @@ OpenBCI - 128 Kb - 32 Kb +OpenEnergyMonitor +~~~~~~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``emonpi`` + - `emonPi `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + Outrageous Circuits ~~~~~~~~~~~~~~~~~~~ diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 5274ccb4..f7dbc86c 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -373,7 +373,7 @@ For more detailed information about available flags/options go to: ``src_build_flags`` ^^^^^^^^^^^^^^^^^^^ -An option ``src_build_flags`` has the same behaviour like ``build_flags`` +An option ``src_build_flags`` has the same behavior like ``build_flags`` but will be applied only for the project source code from :ref:`projectconf_pio_src_dir` directory. @@ -585,7 +585,7 @@ Example: ``lib_dfcyclic`` ^^^^^^^^^^^^^^^^ -Control cyclic (recursive) behaviour for ``Library Dependency Finder (LDF)``. +Control cyclic (recursive) behavior for ``Library Dependency Finder (LDF)``. By default, this option is turned OFF (``lib_dfcyclic=False``) and means that ``LDF`` will find only libraries which are included in source files from the project :ref:`projectconf_pio_src_dir`. diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 77877d28..3b2d0c24 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present Ivan Kravets Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -30,7 +30,7 @@ PlatformIO CLI provides special :ref:`cmd_init` command for configuring your pro It allows to initialize new empty project or update existing with the new data. What is more, :ref:`cmd_init` can be used for :ref:`ide`. It means that you will -be able to import pre-generated PlatformIO project using favourite IDE and +be able to import pre-generated PlatformIO project using favorite IDE and extend it with the professional instruments for IoT development. This tutorial is based on the next popular embedded boards and development diff --git a/docs/userguide/cmd_ci.rst b/docs/userguide/cmd_ci.rst index be11b0bc..d97d3b96 100644 --- a/docs/userguide/cmd_ci.rst +++ b/docs/userguide/cmd_ci.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present Ivan Kravets Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -29,7 +29,7 @@ Description :ref:`cmd_ci` command is conceived of as "hot key" for building project with arbitrary source code structure. In a nutshell, using ``SRC`` and -:option:`platformio ci --lib` contents PlatformIO initialises via +:option:`platformio ci --lib` contents PlatformIO initializes via :ref:`cmd_init` new project in :option:`platformio ci --build-dir` with the build environments (using :option:`platformio ci --board` or :option:`platformio ci --project-conf`) and processes them via :ref:`cmd_run` diff --git a/docs/userguide/cmd_init.rst b/docs/userguide/cmd_init.rst index 45ef6f30..716ed155 100644 --- a/docs/userguide/cmd_init.rst +++ b/docs/userguide/cmd_init.rst @@ -1,4 +1,4 @@ -.. Copyright 2014-2016 Ivan Kravets +.. Copyright 2014-present Ivan Kravets Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -47,7 +47,7 @@ Options .. option:: -d, --project-dir -A path to the directory where *PlatformIO* will initialise new project. +A path to the directory where *PlatformIO* will initialize new project. .. option:: -b, --board diff --git a/platformio/__init__.py b/platformio/__init__.py index e470d028..5e508f39 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (2, 9, 4) +VERSION = (2, 10, 0) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/boards/adafruit.json b/platformio/boards/adafruit.json index 9fb2dda4..6200608e 100644 --- a/platformio/boards/adafruit.json +++ b/platformio/boards/adafruit.json @@ -7,7 +7,7 @@ "mcu": "atmega32u4", "usb_product": "Adafruit Flora", "variant": "flora", - "hwid": [ + "hwids": [ ["0x239A", "0x8004"] ] }, @@ -36,7 +36,7 @@ "mcu": "atmega32u4", "usb_product": "Bluefruit Micro", "variant": "bluefruitmicro", - "hwid": [ + "hwids": [ ["0x239A", "0x800A"] ] }, @@ -85,7 +85,7 @@ "mcu": "atmega32u4", "usb_product": "Feather 32u4", "variant": "feather32u4", - "hwid": [ + "hwids": [ ["0x239A", "0x800C"] ] }, diff --git a/platformio/boards/arduino.json b/platformio/boards/arduino.json index 602c066e..dab169e5 100644 --- a/platformio/boards/arduino.json +++ b/platformio/boards/arduino.json @@ -7,7 +7,7 @@ "mcu": "atmega32u4", "usb_product": "LilyPad USB", "variant": "leonardo", - "hwid": [ + "hwids": [ ["0x1B4F", "0x9207"], ["0x1B4F", "0x9208"] ] @@ -164,7 +164,7 @@ "mcu": "atmega32u4", "usb_product": "Arduino Esplora", "variant": "leonardo", - "hwid": [ + "hwids": [ ["0x2341", "0x003C"], ["0x2341", "0x803C"], ["0x2A03", "0x003C"], @@ -237,7 +237,7 @@ "mcu": "atmega32u4", "usb_product": "Arduino Leonardo", "variant": "leonardo", - "hwid": [ + "hwids": [ ["0x2341", "0x0036"], ["0x2341", "0x8036"], ["0x2A03", "0x0036"], @@ -268,7 +268,7 @@ "mcu": "atmega32u4", "usb_product": "Arduino Leonardo ETH", "variant": "leonardo", - "hwid": [ + "hwids": [ ["0x2A03", "0x8040"], ["0x2A03", "0x0040"] ] @@ -402,7 +402,7 @@ "mcu": "atmega32u4", "usb_product": "Arduino Micro", "variant": "micro", - "hwid": [ + "hwids": [ ["0x2341", "0x0037"], ["0x2341", "0x8037"], ["0x2A03", "0x0037"], @@ -601,7 +601,7 @@ "mcu": "atmega32u4", "usb_product": "Robot Control", "variant": "robot_control", - "hwid": [ + "hwids": [ ["0x2341", "0x0038"], ["0x2341", "0x8038"], ["0x2A03", "0x0038"], @@ -632,7 +632,7 @@ "mcu": "atmega32u4", "usb_product": "Robot Motor", "variant": "robot_motor", - "hwid": [ + "hwids": [ ["0x2341", "0x0039"], ["0x2341", "0x8039"], ["0x2A03", "0x0039"], @@ -662,7 +662,7 @@ "f_cpu": "16000000L", "mcu": "atmega328p", "variant": "standard", - "hwid": [ + "hwids": [ ["0x2341", "0x0043"], ["0x2341", "0x0001"], ["0x2A03", "0x0043"] @@ -689,7 +689,7 @@ "mcu": "atmega32u4", "usb_product": "Arduino Yun", "variant": "yun", - "hwid": [ + "hwids": [ ["0x2341", "0x0041"], ["0x2341", "0x8041"], ["0x2A03", "0x0041"], @@ -721,7 +721,7 @@ "mcu": "atmega32u4", "usb_product": "Arduino Yun Mini", "variant": "yun", - "hwid": [ + "hwids": [ ["0x2A03", "0x8050"], ["0x2A03", "0x0050"] ] @@ -751,7 +751,7 @@ "mcu": "atmega32u4", "usb_product": "Arduino Industrial 101", "variant": "yun", - "hwid": [ + "hwids": [ ["0x2A03", "0x8056"], ["0x2A03", "0x0056"] ] @@ -781,7 +781,7 @@ "mcu": "atmega32u4", "usb_product": "Linino One", "variant": "yun", - "hwid": [ + "hwids": [ ["0x2A03", "0x8001"], ["0x2A03", "0x0001"] ] @@ -813,7 +813,7 @@ "usb_product": "Arduino Due", "variant": "arduino_due_x", "ldscript": "sam3x8e.ld", - "hwid": [ + "hwids": [ ["0x2341", "0x003D"], ["0x2A03", "0x003D"] ] @@ -843,7 +843,7 @@ "usb_product": "Arduino Due", "variant": "arduino_due_x", "ldscript": "sam3x8e.ld", - "hwid": [ + "hwids": [ ["0x2341", "0x003E"], ["0x2A03", "0x003E"] ] @@ -873,7 +873,7 @@ "usb_product": "Arduino Zero", "variant": "arduino_zero", "ldscript": "flash_with_bootloader.ld", - "hwid": [ + "hwids": [ ["0x2341", "0x804D"], ["0x03EB", "0x2157"] ] @@ -903,7 +903,7 @@ "usb_product": "Arduino Zero", "variant": "arduino_zero", "ldscript": "flash_with_bootloader.ld", - "hwid": [ + "hwids": [ ["0x2341", "0x804D"], ["0x2341", "0x004D"], ["0x2341", "0x824D"] diff --git a/platformio/boards/digistump.json b/platformio/boards/digistump.json index 24634358..87e4b4b5 100644 --- a/platformio/boards/digistump.json +++ b/platformio/boards/digistump.json @@ -85,7 +85,7 @@ "ldscript": "sam3x8e.ld", "usb_product": "Digistump DigiX", "variant": "digispark_digix", - "hwid": [ + "hwids": [ ["0x16D0", "0x078A"] ] }, diff --git a/platformio/boards/engduino.json b/platformio/boards/engduino.json index 5e7c1c48..9d76376e 100644 --- a/platformio/boards/engduino.json +++ b/platformio/boards/engduino.json @@ -7,7 +7,7 @@ "mcu": "atmega32u4", "usb_product": "EngduinoV1", "variant": "engduinov1", - "hwid": [ + "hwids": [ ["0x1B4F", "0x9208"] ] }, @@ -35,7 +35,7 @@ "mcu": "atmega32u4", "usb_product": "EngduinoV2", "variant": "engduinov2", - "hwid": [ + "hwids": [ ["0x1B4F", "0x9208"] ] }, @@ -63,7 +63,7 @@ "mcu": "atmega32u4", "usb_product": "EngduinoV3", "variant": "engduinov3", - "hwid": [ + "hwids": [ ["0x1B4F", "0x9208"] ] }, diff --git a/platformio/boards/espressif.json b/platformio/boards/espressif.json index 691b4dc6..a3db71e2 100644 --- a/platformio/boards/espressif.json +++ b/platformio/boards/espressif.json @@ -133,7 +133,10 @@ "flash_mode": "qio", "ldscript": "esp8266.flash.4m1m.ld", "mcu": "esp8266", - "variant": "nodemcu" + "variant": "nodemcu", + "hwids": [ + ["0x10C4", "0xEA60"] + ] }, "frameworks": ["arduino", "simba"], "name": "NodeMCU 0.9 (ESP-12 Module)", @@ -158,7 +161,10 @@ "flash_mode": "dio", "ldscript": "esp8266.flash.4m1m.ld", "mcu": "esp8266", - "variant": "nodemcu" + "variant": "nodemcu", + "hwids": [ + ["0x10C4", "0xEA60"] + ] }, "frameworks": ["arduino", "simba"], "name": "NodeMCU 1.0 (ESP-12E Module)", diff --git a/platformio/boards/intel.json b/platformio/boards/intel.json index e74bdd39..33e35e3c 100644 --- a/platformio/boards/intel.json +++ b/platformio/boards/intel.json @@ -8,7 +8,7 @@ "mcu": "ARCv2EM", "usb_product": "Genuino 101", "variant": "arduino_101", - "hwid": [ + "hwids": [ ["0x8087", "0x0AB6"] ] }, @@ -18,11 +18,8 @@ "upload": { "maximum_ram_size": 81920, "maximum_size": 196608, - "use_1200bps_touch": true, "protocol": "script", - "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": false + "require_upload_port" : true }, "url": "https://www.arduino.cc/en/Main/ArduinoBoard101", "vendor": "Intel" diff --git a/platformio/boards/lattice.json b/platformio/boards/lattice.json index ce31a2e4..02e699f9 100755 --- a/platformio/boards/lattice.json +++ b/platformio/boards/lattice.json @@ -6,7 +6,7 @@ "cpu": "fpga", "mcu": "ice40hx1k", "variant": "1k", - "hwid": [ + "hwids": [ ["0x0403", "0x6010"] ] }, @@ -28,7 +28,7 @@ "cpu": "fpga", "mcu": "ice40hx1k", "variant": "1k", - "hwid": [ + "hwids": [ ["0x0403", "0x6010"] ] }, diff --git a/platformio/boards/microchippic32.json b/platformio/boards/microchippic32.json index b5a949be..83af9110 100644 --- a/platformio/boards/microchippic32.json +++ b/platformio/boards/microchippic32.json @@ -16,8 +16,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/cerebot-32mx4-limited-time-see-chipkit-pro-mx4/", "vendor": "Digilent" @@ -40,8 +39,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=TDGL004", "vendor": "Digilent" @@ -64,8 +62,7 @@ "maximum_size": 126976, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/chipkit-mx3-microcontroller-board-with-pmod-headers/", "vendor": "Digilent" @@ -88,8 +85,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/chipkit-pro-mx4-embedded-systems-trainer-board/", "vendor": "Digilent" @@ -112,8 +108,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/chipkit-pro-mx7-advanced-peripherals-embedded-systems-trainer-board/", "vendor": "Digilent" @@ -136,8 +131,7 @@ "maximum_size": 122880, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://www.element14.com/community/community/knode/dev_platforms_kits/element14_dev_kits/microchip-chipkit/chipkit_pi", "vendor": "element14" @@ -160,8 +154,7 @@ "maximum_size": 126976, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/chipkit-cmod-breadboardable-mz-microcontroller-board/", "vendor": "Digilent" @@ -184,8 +177,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://www.seeedstudio.com/wiki/CUI32Stem", "vendor": "SeeedStudio" @@ -208,8 +200,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://www.schmalzhaus.com/UBW32/", "vendor": "UBW32" @@ -232,8 +223,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://www.schmalzhaus.com/UBW32/", "vendor": "UBW32" @@ -256,8 +246,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://www.pontech.com/productdisplay/uav100", "vendor": "PONTECH" @@ -280,8 +269,7 @@ "maximum_size": 122880, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/chipkit-dp32-dip-package-prototyping-microcontroller-board/", "vendor": "Digilent" @@ -304,8 +292,7 @@ "maximum_size": 122880, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://fubarino.org/mini/", "vendor": "Fubarino" @@ -328,8 +315,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://fubarino.org/sd/index.html", "vendor": "Fubarino" @@ -352,8 +338,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/chipkit-max32-microcontroller-board-with-mega-r3-headers/", "vendor": "Digilent" @@ -376,8 +361,7 @@ "maximum_size": 258048, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "https://www.olimex.com/Products/Duino/PIC32/PIC32-PINGUINO/open-source-hardware", "vendor": "Olimex" @@ -400,8 +384,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://www.4dsystems.com.au/product/Picadillo_35T/", "vendor": "4DSystems" @@ -424,8 +407,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://quick240.com/quicki/", "vendor": "PONTECH" @@ -448,8 +430,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/chipkit-uc32-basic-microcontroller-board-with-uno-r3-headers/", "vendor": "Digilent" @@ -472,8 +453,7 @@ "maximum_size": 126976, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/chipkit-uno32-basic-microcontroller-board-retired-see-chipkit-uc32/", "vendor": "Digilent" @@ -496,8 +476,7 @@ "maximum_size": 520192, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/chipkit-wf32-wifi-enabled-microntroller-board-with-uno-r3-headers/", "vendor": "Digilent" @@ -520,8 +499,7 @@ "maximum_size": 2080768, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/chipkit-wi-fire-wifi-enabled-mz-microcontroller-board/", "vendor": "Digilent" @@ -544,8 +522,7 @@ "maximum_size": 2080768, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://store.digilentinc.com/", "vendor": "Digilent" @@ -568,8 +545,7 @@ "maximum_size": 122880, "protocol": "stk500v2", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "http://shop.openbci.com/", "vendor": "OpenBCI" diff --git a/platformio/boards/microduino.json b/platformio/boards/microduino.json index 64e88ec5..1a0aa341 100644 --- a/platformio/boards/microduino.json +++ b/platformio/boards/microduino.json @@ -132,7 +132,7 @@ "f_cpu": "16000000L", "mcu": "atmega32u4", "variant": "32u4", - "hwid": [ + "hwids": [ ["0x2341", "0x8036"] ] }, diff --git a/platformio/boards/misc.json b/platformio/boards/misc.json index 4d65abdb..a8cc9e5a 100644 --- a/platformio/boards/misc.json +++ b/platformio/boards/misc.json @@ -43,6 +43,28 @@ "vendor": "BitWizard" }, + "emonpi": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_EMONPI", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "frameworks": ["arduino"], + "name": "emonPi", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 115200 + }, + "url": "https://github.com/openenergymonitor/emonpi", + "vendor": "OpenEnergyMonitor" + }, + "sainSmartDue": { "build": { "core": "arduino", @@ -53,7 +75,7 @@ "usb_product": "Arduino Due", "variant": "arduino_due_x", "ldscript": "sam3x8e.ld", - "hwid": [ + "hwids": [ ["0x2341", "0x003E"] ] }, @@ -82,7 +104,7 @@ "usb_product": "Arduino Due", "variant": "arduino_due_x", "ldscript": "sam3x8e.ld", - "hwid": [ + "hwids": [ ["0x2341", "0x003E"] ] }, @@ -326,7 +348,7 @@ "mcu": "atmega32u4", "usb_product": "RedBearLab Blend", "variant": "leonardo", - "hwid": [ + "hwids": [ ["0x2341", "0x8036"] ] }, @@ -355,7 +377,7 @@ "mcu": "atmega32u4", "usb_product": "RedBearLab Blend", "variant": "micro", - "hwid": [ + "hwids": [ ["0x03EB", "0x2404"] ] }, @@ -384,7 +406,7 @@ "mcu": "atmega32u4", "usb_product": "RedBearLab Blend", "variant": "micro", - "hwid": [ + "hwids": [ ["0x03EB", "0x2404"] ] }, @@ -435,7 +457,7 @@ "mcu": "atmega32u4", "usb_product": "LightUp", "variant": "leonardo", - "hwid": [ + "hwids": [ ["0x1d50", "0x6096"] ] }, @@ -531,7 +553,7 @@ "mcu": "atmega32u4", "variant" : "quirkbot", "usb_product": "Quirkbot", - "hwid": [ + "hwids": [ ["0x2886", "0xf004"], ["0x2886", "0xf005"], ["0x2886", "0xf006"], @@ -743,16 +765,14 @@ "arduboy": { "build": { "core": "arduino", - "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_LEONARDO", + "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ARDUBOY -DARDUBOY_10", "f_cpu": "16000000L", "mcu": "atmega32u4", - "usb_product": "Arduino Leonardo", + "usb_product": "Arduboy", "variant": "leonardo", - "hwid": [ + "hwids": [ ["0x2341", "0x0036"], - ["0x2341", "0x8036"], - ["0x2A03", "0x0036"], - ["0x2A03", "0x8036"] + ["0x2341", "0x8036"] ] }, "frameworks": ["arduino"], @@ -770,5 +790,35 @@ }, "url": "https://www.arduboy.com", "vendor": "Arduboy" + }, + + "arduboy_devkit": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ARDUBOY_DEVKIT -DAB_DEVKIT", + "f_cpu": "16000000L", + "mcu": "atmega32u4", + "usb_product": "Arduboy DevKit", + "variant": "leonardo", + "hwids": [ + ["0x2341", "0x0036"], + ["0x2341", "0x8036"] + ] + }, + "frameworks": ["arduino"], + "name": "Arduboy DevKit", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "require_upload_port" : true, + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + }, + "url": "https://www.arduboy.com", + "vendor": "Arduboy" } } diff --git a/platformio/boards/sparkfun.json b/platformio/boards/sparkfun.json index 6bf11499..44d5cb52 100644 --- a/platformio/boards/sparkfun.json +++ b/platformio/boards/sparkfun.json @@ -28,7 +28,7 @@ "mcu": "atmega32u4", "usb_product": "SparkFun Pro Micro", "variant": "sparkfun_promicro", - "hwid": [ + "hwids": [ ["0x1B4F", "0x9205"], ["0x1B4F", "0x9206"] ] @@ -57,7 +57,7 @@ "mcu": "atmega32u4", "usb_product": "SparkFun Pro Micro", "variant": "sparkfun_promicro", - "hwid": [ + "hwids": [ ["0x1B4F", "0x9203"], ["0x1B4F", "0x9204"] ] @@ -86,7 +86,7 @@ "mcu": "atmega32u4", "usb_product": "SparkFun Fio v3", "variant": "sparkfun_promicro", - "hwid": [ + "hwids": [ ["0x1B4F", "0xF100"], ["0x1B4F", "0xF101"] ] @@ -115,7 +115,7 @@ "mcu": "atmega32u4", "usb_product": "SparkFun MaKey", "variant": "sparkfun_promicro", - "hwid": [ + "hwids": [ ["0x1B4F", "0x2B74"], ["0x1B4F", "0x2B75"] ] diff --git a/platformio/boards/ststm32.json b/platformio/boards/ststm32.json index 46037168..1366a4e4 100644 --- a/platformio/boards/ststm32.json +++ b/platformio/boards/ststm32.json @@ -586,6 +586,22 @@ "url": "https://developer.mbed.org/platforms/ST-Nucleo-L073RZ/", "vendor": "ST" }, + "nucleo_l031k6": { + "build": { + "f_cpu": "32000000L", + "cpu": "cortex-m0plus", + "mcu": "stm32l031k6t6" + }, + "frameworks": ["mbed"], + "name": "ST Nucleo L031K6", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 32768 + }, + "url": "https://developer.mbed.org/platforms/ST-Nucleo-L031K6/", + "vendor": "ST" + }, "seeedArchMax": { "build": { "f_cpu": "168000000L", diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index ff3ceadf..2500084e 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -49,18 +49,19 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 env.AutodetectUploadPort() env.Append(UPLOADERFLAGS=["-P", '"$UPLOAD_PORT"']) - if env.subst("$BOARD") == "raspduino": + if env.subst("$BOARD") in ("raspduino", "emonpi"): def _rpi_sysgpio(path, value): with open(path, "w") as f: f.write(str(value)) - _rpi_sysgpio("/sys/class/gpio/export", 18) - _rpi_sysgpio("/sys/class/gpio/gpio18/direction", "out") - _rpi_sysgpio("/sys/class/gpio/gpio18/value", 1) + pin_num = 18 if env.subst("$BOARD") == "raspduino" else 4 + _rpi_sysgpio("/sys/class/gpio/export", pin_num) + _rpi_sysgpio("/sys/class/gpio/gpio%d/direction" % pin_num, "out") + _rpi_sysgpio("/sys/class/gpio/gpio%d/value" % pin_num, 1) sleep(0.1) - _rpi_sysgpio("/sys/class/gpio/gpio18/value", 0) - _rpi_sysgpio("/sys/class/gpio/unexport", 18) + _rpi_sysgpio("/sys/class/gpio/gpio%d/value" % pin_num, 0) + _rpi_sysgpio("/sys/class/gpio/unexport", pin_num) else: if not upload_options.get("disable_flushing", False): env.FlushSerialBuffer("$UPLOAD_PORT") @@ -148,10 +149,9 @@ AlwaysBuild(upload) # Target: Upload EEPROM data (from EEMEM directive) # -uploadeep = env.Alias( - "uploadeep", - env.ElfToEep(join("$BUILD_DIR", "firmware"), target_elf), - [BeforeUpload, "$UPLOADEEPCMD"]) +uploadeep = env.Alias("uploadeep", + env.ElfToEep(join("$BUILD_DIR", "firmware"), target_elf), + [BeforeUpload, "$UPLOADEEPCMD"]) AlwaysBuild(uploadeep) # diff --git a/platformio/builder/scripts/atmelsam.py b/platformio/builder/scripts/atmelsam.py index 79eca59e..5fa5cd4b 100644 --- a/platformio/builder/scripts/atmelsam.py +++ b/platformio/builder/scripts/atmelsam.py @@ -25,8 +25,6 @@ from platformio.util import get_serialports def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - env.AutodetectUploadPort() - board_type = env.subst("$BOARD") if "zero" not in board_type: env.Append( @@ -176,8 +174,9 @@ AlwaysBuild(target_size) if env.subst("$BOARD") == "zero": upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") else: - upload = env.Alias(["upload", "uploadlazy"], target_firm, - [BeforeUpload, "$UPLOADCMD"]) + upload = env.Alias( + ["upload", "uploadlazy"], target_firm, + [env.AutodetectUploadPort, BeforeUpload, "$UPLOADCMD"]) AlwaysBuild(upload) diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index 8f74ca71..7c167489 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -346,7 +346,7 @@ AlwaysBuild(target_size) target_upload = env.Alias( ["upload", "uploadlazy", "uploadfs"], target_firm, - [lambda target, source, env: env.AutodetectUploadPort(), "$UPLOADCMD"]) + [env.AutodetectUploadPort, "$UPLOADCMD"]) env.AlwaysBuild(target_upload) diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index d3170687..a81d29b3 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -179,8 +179,8 @@ ARDUINO_VERSION = int( ARDUINO_USBDEFINES = [] if "usb_product" in BOARD_BUILDOPTS: ARDUINO_USBDEFINES = [ - "USB_VID=${BOARD_OPTIONS['build']['hwid'][0][0]}", - "USB_PID=${BOARD_OPTIONS['build']['hwid'][0][1]}", + "USB_VID=${BOARD_OPTIONS['build']['hwids'][0][0]}", + "USB_PID=${BOARD_OPTIONS['build']['hwids'][0][1]}", 'USB_PRODUCT=\\"%s\\"' % (env.subst( "${BOARD_OPTIONS['build']['usb_product']}").replace('"', "")), 'USB_MANUFACTURER=\\"%s\\"' % (env.subst( diff --git a/platformio/builder/scripts/frameworks/mbed.py b/platformio/builder/scripts/frameworks/mbed.py index 0f6399e2..55b9fe14 100644 --- a/platformio/builder/scripts/frameworks/mbed.py +++ b/platformio/builder/scripts/frameworks/mbed.py @@ -71,7 +71,7 @@ MBED_VARIANTS = { "samr21_xpro": "SAMR21G18A", "saml21_xpro_b": "SAML21J18A", "samd21_xpro": "SAMD21J18A", - "bbcmicrobit": "NRF51822" + "bbcmicrobit": "NRF51_MICROBIT" } MBED_LIBS_MAP = { @@ -149,6 +149,18 @@ def add_mbedlib(libname, libar): if (not any(f.endswith(".h") for f in files) and basename(root) not in sysincdirs): continue + + target_includes = ( + "TARGET_%s" % env.get( + "BOARD_OPTIONS", {}).get("vendor", "").upper(), + "TARGET_%s" % variant, + "TARGET_CORTEX_M" + ) + + if "TARGET_" in root: + if all([p not in root.upper() for p in target_includes]): + continue + var_dir = join("$BUILD_DIR", "FrameworkMbed%sInc%d" % (libname.upper(), crc32(root))) if var_dir in env.get("CPPPATH"): diff --git a/platformio/builder/scripts/intel_arc32.py b/platformio/builder/scripts/intel_arc32.py index e5db85d8..fcb97512 100644 --- a/platformio/builder/scripts/intel_arc32.py +++ b/platformio/builder/scripts/intel_arc32.py @@ -21,20 +21,6 @@ from os.path import join from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, DefaultEnvironment) - -def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - - if "program" in COMMAND_LINE_TARGETS: - return - - env.AutodetectUploadPort() - env.Prepend(UPLOADERFLAGS=['"$UPLOAD_PORT"']) - - if env.get("BOARD_OPTIONS", {}).get("upload", {}).get( - "use_1200bps_touch", False): - env.TouchSerialPort("$UPLOAD_PORT", 1200) - - env = DefaultEnvironment() env.Replace( @@ -112,8 +98,11 @@ env.Replace( SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', UPLOADER=join("$PIOPACKAGES_DIR", "tool-arduino101load", "arduino101load"), + UPLOADERFLAGS=[ + '"$UPLOAD_PORT"' + ], DFUUTIL=join("$PIOPACKAGES_DIR", "tool-arduino101load", "dfu-util"), - UPLOADCMD='"$UPLOADER" $DFUUTIL $SOURCES $UPLOADERFLAGS verbose', + UPLOADCMD='"$UPLOADER" "$DFUUTIL" $SOURCES $UPLOADERFLAGS verbose', PROGNAME="firmware", PROGSUFFIX=".elf" @@ -189,8 +178,8 @@ AlwaysBuild(target_size) # Target: Upload firmware # -upload = env.Alias( - ["upload", "uploadlazy"], target_firm, [BeforeUpload, "$UPLOADCMD"]) +upload = env.Alias(["upload", "uploadlazy"], target_firm, + [env.AutodetectUploadPort, "$UPLOADCMD"]) AlwaysBuild(upload) # diff --git a/platformio/builder/scripts/microchippic32.py b/platformio/builder/scripts/microchippic32.py index 01695a96..607baf25 100644 --- a/platformio/builder/scripts/microchippic32.py +++ b/platformio/builder/scripts/microchippic32.py @@ -21,12 +21,6 @@ from os.path import join from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, DefaultEnvironment) - -def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - - env.AutodetectUploadPort() - env.Prepend(UPLOADERFLAGS=["-d", '"$UPLOAD_PORT"']) - env = DefaultEnvironment() env.Replace( @@ -86,7 +80,8 @@ env.Replace( UPLOADER=join("$PIOPACKAGES_DIR", "tool-pic32prog", "pic32prog"), UPLOADERFLAGS=[ - "-b", "$UPLOAD_SPEED" + "-b", "$UPLOAD_SPEED", + "-d", '"$UPLOAD_PORT"' ], UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES', @@ -179,8 +174,8 @@ AlwaysBuild(target_size) # Target: Upload firmware # -upload = env.Alias( - ["upload", "uploadlazy"], target_firm, [BeforeUpload, "$UPLOADCMD"]) +upload = env.Alias(["upload", "uploadlazy"], target_firm, + [env.AutodetectUploadPort, "$UPLOADCMD"]) AlwaysBuild(upload) # diff --git a/platformio/builder/scripts/nordicnrf51.py b/platformio/builder/scripts/nordicnrf51.py index a39e94fa..99f96614 100644 --- a/platformio/builder/scripts/nordicnrf51.py +++ b/platformio/builder/scripts/nordicnrf51.py @@ -63,9 +63,8 @@ AlwaysBuild(target_size) # if env.subst("$BOARD") == "rfduino": - upload = env.Alias( - ["upload", "uploadlazy"], target_firm, - [lambda target, source, env: env.AutodetectUploadPort(), "$UPLOADCMD"]) + upload = env.Alias(["upload", "uploadlazy"], target_firm, + [env.AutodetectUploadPort, "$UPLOADCMD"]) else: upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk) AlwaysBuild(upload) diff --git a/platformio/builder/scripts/nxplpc.py b/platformio/builder/scripts/nxplpc.py index a3f5eed3..727c9c8b 100644 --- a/platformio/builder/scripts/nxplpc.py +++ b/platformio/builder/scripts/nxplpc.py @@ -17,19 +17,10 @@ """ from os.path import join -from shutil import copyfile from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, DefaultEnvironment, SConscript) - -def UploadToDisk(target, source, env): # pylint: disable=W0613,W0621 - env.AutodetectUploadPort() - copyfile(join(env.subst("$BUILD_DIR"), "firmware.bin"), - join(env.subst("$UPLOAD_PORT"), "firmware.bin")) - print("Firmware has been successfully uploaded.\n" - "Please restart your board.") - env = DefaultEnvironment() SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) @@ -60,7 +51,7 @@ AlwaysBuild(target_size) # Target: Upload by default .bin file # -upload = env.Alias(["upload", "uploadlazy"], target_firm, UploadToDisk) +upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk) AlwaysBuild(upload) # diff --git a/platformio/builder/scripts/ststm32.py b/platformio/builder/scripts/ststm32.py index 34eee8d8..8dbd70ef 100644 --- a/platformio/builder/scripts/ststm32.py +++ b/platformio/builder/scripts/ststm32.py @@ -100,8 +100,7 @@ AlwaysBuild(target_size) # if "mbed" in env.subst("$FRAMEWORK") and not env.subst("$UPLOAD_PROTOCOL"): - upload = env.Alias(["upload", "uploadlazy"], - target_firm, env.UploadToDisk) + upload = env.Alias(["upload", "uploadlazy"], target_firm, env.UploadToDisk) else: upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") AlwaysBuild(upload) diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index b7fe229e..874d4086 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -14,6 +14,7 @@ from __future__ import absolute_import +from os import environ from os.path import isfile, join from platform import system from shutil import copyfile @@ -21,7 +22,7 @@ from time import sleep from serial import Serial -from platformio.util import get_logicaldisks, get_serialports, get_systype +from platformio import util def FlushSerialBuffer(env, port): @@ -36,7 +37,7 @@ def FlushSerialBuffer(env, port): def TouchSerialPort(env, port, baudrate): - if "windows" not in get_systype(): + if system() != "Windows": try: s = Serial(env.subst(port)) s.close() @@ -53,8 +54,9 @@ def WaitForNewSerialPort(env, before): prev_port = env.subst("$UPLOAD_PORT") new_port = None elapsed = 0 + sleep(1) while elapsed < 5 and new_port is None: - now = get_serialports() + now = util.get_serialports() for p in now: if p not in before: new_port = p['port'] @@ -78,40 +80,52 @@ def WaitForNewSerialPort(env, before): return new_port -def AutodetectUploadPort(env): - if "UPLOAD_PORT" in env: - return +def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument + env = args[0] + print "Looking for upload port/disk..." - if env.subst("$FRAMEWORK") == "mbed": + def _look_for_mbed_disk(): msdlabels = ("mbed", "nucleo", "frdm") - for item in get_logicaldisks(): + for item in util.get_logicaldisks(): if (not item['name'] or not any([l in item['name'].lower() for l in msdlabels])): continue - env.Replace(UPLOAD_PORT=item['disk']) - break + return item['disk'] + return None + + def _look_for_serial_port(): + port = None + board_hwids = env.get("BOARD_OPTIONS", {}).get( + "build", {}).get("hwids", []) + for item in util.get_serialports(): + if "VID:PID" not in item['hwid']: + continue + port = item['port'] + for hwid in board_hwids: + hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") + if hwid_str in item['hwid']: + return port + return port + + if "UPLOAD_PORT" in env: + print env.subst("Manually specified: $UPLOAD_PORT") + return + + if env.subst("$FRAMEWORK") == "mbed": + env.Replace(UPLOAD_PORT=_look_for_mbed_disk()) else: if (system() == "Linux" and not isfile("/etc/udev/99-platformio-udev.rules")): - print ( + print( "\nWarning! Please install `99-platformio-udev.rules` and " "check that your board's PID and VID are listed in the rules." "\n https://raw.githubusercontent.com/platformio/platformio" "/develop/scripts/99-platformio-udev.rules\n" ) + env.Replace(UPLOAD_PORT=_look_for_serial_port()) - board_build_opts = env.get("BOARD_OPTIONS", {}).get("build", {}) - for item in get_serialports(): - if "VID:PID" not in item['hwid']: - continue - env.Replace(UPLOAD_PORT=item['port']) - for hwid in board_build_opts.get("hwid", []): - board_hwid = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") - if board_hwid in item['hwid']: - break - - if "UPLOAD_PORT" in env: - print "Auto-detected UPLOAD_PORT/DISK: %s" % env['UPLOAD_PORT'] + if env.subst("$UPLOAD_PORT"): + print env.subst("Auto-detected: $UPLOAD_PORT") else: env.Exit("Error: Please specify `upload_port` for environment or use " "global `--upload-port` option.\n" @@ -132,6 +146,30 @@ def UploadToDisk(_, target, source, env): # pylint: disable=W0613,W0621 "Please restart your board.") +def CheckUploadSize(_, target, source, env): # pylint: disable=W0613,W0621 + max_size = int(env.get("BOARD_OPTIONS", {}).get("upload", {}).get( + "maximum_size", 0)) + if max_size == 0 or "SIZETOOL" not in env: + return + + print "Check program size..." + sysenv = environ.copy() + sysenv['PATH'] = str(env['ENV']['PATH']) + cmd = [env.subst("$SIZETOOL"), "-B", str(source[0])] + result = util.exec_command(cmd, env=sysenv) + if result['returncode'] != 0: + return + print result['out'].strip() + + line = result['out'].strip().splitlines()[1] + values = [v.strip() for v in line.split("\t")] + used_size = int(values[0]) + int(values[1]) + + if used_size > max_size: + env.Exit("Error: The program size (%d bytes) is greater " + "than maximum allowed (%s bytes)" % (used_size, max_size)) + + def exists(_): return True @@ -142,4 +180,5 @@ def generate(env): env.AddMethod(WaitForNewSerialPort) env.AddMethod(AutodetectUploadPort) env.AddMethod(UploadToDisk) + env.AddMethod(CheckUploadSize) return env diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 891f45ba..863e0ef1 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -35,6 +35,11 @@ SRC_DEFAULT_FILTER = " ".join([ def BuildProgram(env): + env.Append( + CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( + *pioversion_to_intstr())], + ) + # fix ASM handling under non-casitive OS if not case_sensitive_suffixes(".s", ".S"): env.Replace( @@ -78,8 +83,6 @@ def BuildProgram(env): env.ProcessFlags([env.get("SRC_BUILD_FLAGS", None)]) env.Append( - CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( - *pioversion_to_intstr())], CPPPATH=["$PROJECTSRC_DIR"], LIBS=deplibs, LIBPATH=["$BUILD_DIR"] @@ -94,11 +97,16 @@ def BuildProgram(env): "Error: Nothing to build. Please put your source code files " "to '%s' folder" % env.subst("$PROJECTSRC_DIR")) - return env.Program( + program = env.Program( join("$BUILD_DIR", env.subst("$PROGNAME")), sources ) + if set(["upload", "uploadlazy", "program"]) & set(COMMAND_LINE_TARGETS): + env.AddPostAction(program, env.CheckUploadSize) + + return program + def ProcessFlags(env, flags): for f in flags: @@ -114,10 +122,11 @@ def ProcessFlags(env, flags): env.Append(CPPDEFINES=[flag]) env.Append(**parsed_flags) - # fix relative CPPPATH - for i, p in enumerate(env.get("CPPPATH", [])): - if isdir(p): - env['CPPPATH'][i] = realpath(p) + # fix relative CPPPATH & LIBPATH + for k in ("CPPPATH", "LIBPATH"): + for i, p in enumerate(env.get(k, [])): + if isdir(p): + env[k][i] = realpath(p) # fix relative path for "-include" for i, f in enumerate(env.get("CCFLAGS", [])): if isinstance(f, tuple) and f[0] == "-include":