diff --git a/HISTORY.rst b/HISTORY.rst index f74898fe..c20f2f59 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,8 @@ Release History 0.10.0 (?) ---------- +* Implemented `platformio boards `_ + command (`issue #11 `_) * Added `example with uploading firmware `_ via USB programmer (USBasp) to `atmelavr `_ diff --git a/docs/userguide/cmd_boards.rst b/docs/userguide/cmd_boards.rst new file mode 100644 index 00000000..49fc3f0a --- /dev/null +++ b/docs/userguide/cmd_boards.rst @@ -0,0 +1,87 @@ +.. _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 + --------------------------------------------------------------------------- + bt atmega168 16Mhz 14Kb 1Kb Arduino BT + btatmega168 atmega168 16Mhz 14Kb 1Kb Arduino BT ATmega168 + btatmega328 atmega168 16Mhz 14Kb 1Kb Arduino BT ATmega328 + diecimila atmega168 16Mhz 14Kb 1Kb Arduino Duemilanove or Diecimila + diecimilaatmega168 atmega168 16Mhz 14Kb 1Kb Arduino Duemilanove or Diecimila ATmega168 + diecimilaatmega328 atmega168 16Mhz 14Kb 1Kb 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 + --------------------------------------------------------------------------- + bt atmega168 16Mhz 14Kb 1Kb Arduino BT + btatmega168 atmega168 16Mhz 14Kb 1Kb Arduino BT ATmega168 + ... + pro atmega168 8Mhz 14Kb 1Kb Arduino Pro or Pro Mini + ... + lilypad atmega168 8Mhz 14Kb 1Kb LilyPad Arduino + lilypadatmega168 atmega168 8Mhz 14Kb 1Kb LilyPad Arduino ATmega168 + lilypadatmega328 atmega168 8Mhz 14Kb 1Kb LilyPad Arduino ATmega328 + 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/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/platformio/boards/arduino.json b/platformio/boards/arduino.json new file mode 100644 index 00000000..9715f6d8 --- /dev/null +++ b/platformio/boards/arduino.json @@ -0,0 +1,684 @@ +{ + "LilyPadUSB": { + "build": { + "board": "AVR_LILYPAD_USB", + "core": "arduino", + "extra_flags": "{build.usb_flags}", + "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" + } + }, + "atmegang": { + "build": { + "board": "AVR_NG", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega8", + "variant": "standard" + }, + "name": "Arduino NG or older", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 7168, + "protocol": "arduino", + "speed": 19200 + } + }, + "atmegangatmega168": { + "build": { + "board": "AVR_NG", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega8", + "variant": "standard" + }, + "name": "Arduino NG or older ATmega168", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 7168, + "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 + } + }, + "bt": { + "build": { + "board": "AVR_BT", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino BT", + "platform": "atmelavr", + "upload": { + "disable_flushing": "true", + "maximum_ram_size": 1024, + "maximum_size": 14336, + "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": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino BT ATmega328", + "platform": "atmelavr", + "upload": { + "disable_flushing": "true", + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "diecimila": { + "build": { + "board": "AVR_DUEMILANOVE", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168", + "variant": "standard" + }, + "name": "Arduino Duemilanove or Diecimila", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "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": "atmega168", + "variant": "standard" + }, + "name": "Arduino Duemilanove or Diecimila ATmega328", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "esplora": { + "build": { + "board": "AVR_ESPLORA", + "core": "arduino", + "extra_flags": "{build.usb_flags}", + "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", + "extra_flags": "{build.usb_flags}", + "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" + } + }, + "lilypad": { + "build": { + "board": "AVR_LILYPAD", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega168", + "variant": "standard" + }, + "name": "LilyPad Arduino", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "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": "atmega168", + "variant": "standard" + }, + "name": "LilyPad Arduino ATmega328", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "mega": { + "build": { + "board": "AVR_MEGA", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega1280", + "variant": "mega" + }, + "name": "Arduino Mega or Mega 2560", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 126976, + "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_MEGA", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega1280", + "variant": "mega" + }, + "name": "Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 126976, + "protocol": "arduino", + "speed": 57600 + } + }, + "micro": { + "build": { + "board": "AVR_MICRO", + "core": "arduino", + "extra_flags": "{build.usb_flags}", + "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" + } + }, + "mini": { + "build": { + "board": "AVR_MINI", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Mini", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "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": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Mini ATmega328", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "nano": { + "build": { + "board": "AVR_NANO", + "core": "arduino", + "f_cpu": "16000000L", + "mcu": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Nano", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "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": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Nano ATmega328", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "pro": { + "build": { + "board": "AVR_PRO", + "core": "arduino", + "f_cpu": "8000000L", + "mcu": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Pro or Pro Mini", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "pro16MHzatmega168": { + "build": { + "board": "AVR_PRO", + "core": "arduino", + "f_cpu": "8000000L", + "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": "8000000L", + "mcu": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Pro or Pro Mini ATmega328 (5V, 16 MHz)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "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": "atmega168", + "variant": "eightanaloginputs" + }, + "name": "Arduino Pro or Pro Mini ATmega328 (3.3V, 8 MHz)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 14336, + "protocol": "arduino", + "speed": 19200 + } + }, + "robotControl": { + "build": { + "board": "AVR_ROBOT_CONTROL", + "core": "arduino", + "extra_flags": "{build.usb_flags}", + "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", + "extra_flags": "{build.usb_flags}", + "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", + "extra_flags": "{build.usb_flags}", + "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/microduino.json b/platformio/boards/microduino.json new file mode 100644 index 00000000..01740513 --- /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 05810edb..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() @@ -54,23 +52,39 @@ DefaultEnvironment( 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..9fdc0460 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" @@ -101,7 +104,7 @@ env.Append( ) -def reset_device(): +def before_upload(): def rpi_sysgpio(path, value): with open(path, "w") as f: @@ -115,7 +118,7 @@ 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")) + return env.FlushSerialBuffer("$UPLOAD_PORT") CORELIBS = env.ProcessGeneral() @@ -147,7 +150,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 +158,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) # diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index 129f539d..ca7409eb 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -12,35 +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_%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"), @@ -48,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 c751e56a..822600fb 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -5,8 +5,10 @@ import atexit 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 serial import Serial def ProcessGeneral(env): @@ -126,38 +128,6 @@ 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 delete_tmpcpp(files): @@ -206,6 +176,17 @@ 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 exists(_): return True @@ -219,6 +200,6 @@ def generate(env): env.AddMethod(GetDependentLibraries) env.AddMethod(ParseIncludesRecurive) env.AddMethod(VariantDirRecursive) - env.AddMethod(ParseBoardOptions) env.AddMethod(ConvertInoToCpp) + env.AddMethod(FlushSerialBuffer) 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/util.py b/platformio/util.py index 2ef61ca6..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 @@ -149,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/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"