diff --git a/docs/platforms/creating_platform.rst b/docs/platforms/creating_platform.rst index 5347be01..9865beec 100644 --- a/docs/platforms/creating_platform.rst +++ b/docs/platforms/creating_platform.rst @@ -217,6 +217,8 @@ base template of ``test-builder.py``. CPPDEFINES=["DEFINE_1", "DEFINE=2", "DEFINE_N"], + LIBS=["additional", "libs", "here"], + UPLOADER=join("$PIOPACKAGES_DIR", "tool-bar", "uploader"), UPLOADCMD="$UPLOADER $SOURCES" ) @@ -238,12 +240,10 @@ base template of ``test-builder.py``. # The source code of "platformio-build-tool" is here # https://github.com/ivankravets/platformio/blob/develop/platformio/builder/tools/platformio.py - CORELIBS = env.ProcessGeneral() - # # Target: Build executable and linkable firmware # - target_elf = env.BuildFirmware(CORELIBS + ["additional", "libs", "here"]) + target_elf = env.BuildFirmware() # # Target: Build the .bin file diff --git a/docs/platforms/freescalekinetis.rst b/docs/platforms/freescalekinetis.rst new file mode 100644 index 00000000..de5f7aa4 --- /dev/null +++ b/docs/platforms/freescalekinetis.rst @@ -0,0 +1,104 @@ +.. _platform_freescalekinetis: + +Platform ``freescalekinetis`` +============================= + +`Freescale Kinetis Microcontrollers `_ is family of multiple hardware- and software-compatible ARM® Cortex®-M0+, Cortex-M4 and Cortex-M7-based MCU series. Kinetis MCUs offer exceptional low-power performance, scalability and feature integration. + +.. contents:: + +Packages +-------- + +.. list-table:: + :header-rows: 1 + + * - Name + - Alias + - Contents + * - ``toolchain-gccarmnoneeabi`` + - toolchain + - `gcc-arm-embedded `_, + `GDB `_ + * - ``framework-mbed`` + - + - See below in :ref:`freescalekinetis_frameworks` + +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). + + +.. _freescalekinetis_frameworks: + +Frameworks +---------- + +.. list-table:: + :header-rows: 1 + + * - Type ``framework`` + - Name + - Reference + * - ``mbed`` + - MBED Framework + - `Documentation `__ + + +Boards +------ + +.. note:: + * 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 + + * - Type ``board`` + - Name + - Microcontroller ``board_mcu`` + - Frequency ``board_f_cpu`` + - Flash + - RAM + * - ``frdm_kl05z`` + - `Freescale Kinetis FRDM-KL05Z `_ + - MKL05Z32VFM4 ``cortex-m0plus`` + - 48 MHz ``48000000L`` + - 32 Kb + - 4 Kb + * - ``frdm_kl25z`` + - `Freescale Kinetis FRDM-KL25Z `_ + - MKL25Z128VLK4 ``cortex-m0plus`` + - 48 MHz ``48000000L`` + - 128 Kb + - 16 Kb + * - ``frdm_kl46z`` + - `Freescale Kinetis FRDM-KL46Z `_ + - MKL46Z256Vll4 ``cortex-m0plus`` + - 48 MHz ``48000000L`` + - 256 Kb + - 32 Kb + * - ``frdm_k22f`` + - `Freescale Kinetis FRDM-K22F `_ + - MK22FN512VLH12 ``cortex-m4`` + - 120 MHz ``120000000L`` + - 512 Kb + - 128 Kb + * - ``frdm_k64f`` + - `Freescale Kinetis FRDM-K64F `_ + - MK64fN1M0VLL12 ``cortex-m4`` + - 120 MHz ``120000000L`` + - 1 Mb + - 256 Kb + * - ``frdm_k20d50m`` + - `Freescale Kinetis FRDM-K20D50M `_ + - MK20DX128VLH5 ``cortex-m4`` + - 48 MHz ``48000000L`` + - 128 Kb + - 16 Kb + + +More detailed information you can find here +`Freescale Kinetis platforms with support MBED framework `_. diff --git a/docs/platforms/index.rst b/docs/platforms/index.rst index 5aa06bcc..220c3a67 100644 --- a/docs/platforms/index.rst +++ b/docs/platforms/index.rst @@ -16,7 +16,10 @@ MCU, upload protocol or etc. Please use ``board`` option. atmelavr atmelsam - stm32 + freescalekinetis + nordicnrf51 + nxplpc + ststm32 teensy timsp430 titiva diff --git a/docs/platforms/nordicnrf51.rst b/docs/platforms/nordicnrf51.rst new file mode 100644 index 00000000..6241ee64 --- /dev/null +++ b/docs/platforms/nordicnrf51.rst @@ -0,0 +1,110 @@ +.. _platform_nordicnrf51: + +Platform ``nordicnrf51`` +======================== + +`The Nordic nRF51 Series `_ is a family of highly flexible, multi-protocol, system-on-chip (SoC) devices for ultra-low power wireless applications. nRF51 Series devices support a range of protocol stacks including Bluetooth Smart (previously called Bluetooth low energy), ANT and proprietary 2.4GHz protocols such as Gazell. + +.. contents:: + +Packages +-------- + +.. list-table:: + :header-rows: 1 + + * - Name + - Alias + - Contents + * - ``toolchain-gccarmnoneeabi`` + - toolchain + - `gcc-arm-embedded `_, + `GDB `_ + * - ``framework-mbed`` + - + - See below in :ref:`nordicnrf51_frameworks` + +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). + + +.. _nordicnrf51_frameworks: + +Frameworks +---------- + +.. list-table:: + :header-rows: 1 + + * - Type ``framework`` + - Name + - Reference + * - ``mbed`` + - MBED Framework + - `Documentation `__ + + +Boards +------ + +.. note:: + * 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 + + * - Type ``board`` + - Name + - Microcontroller ``board_mcu`` + - Frequency ``board_f_cpu`` + - Flash + - RAM + * - ``nrf51_mkit`` + - `Nordic nRF51822-mKIT `_ + - nrf51822 ``cortex-m0`` + - 16 MHz ``16000000L`` + - 128 Kb + - 16 Kb + * - ``nrf51_dongle`` + - `Nordic nRF51-Dongle `_ + - nrf51822/nrf51422 ``cortex-m0`` + - 32 MHz ``32000000L`` + - 256 Kb + - 16 Kb + * - ``nrf51_dk`` + - `Nordic nRF51-DK `_ + - nrf51822/nrf51422 ``cortex-m0`` + - 32 MHz ``32000000L`` + - 256 Kb + - 16 Kb + * - ``redBearLab`` + - `RedBearLab nRF51822 `_ + - nrf51822 ``cortex-m0`` + - 16 MHz ``16000000L`` + - 256 Kb + - 16 Kb + * - ``redBearLabBLENano`` + - `RedBearLab BLE Nano `_ + - nrf51822 ``cortex-m0`` + - 16 MHz ``16000000L`` + - 256 Kb + - 16 Kb + * - ``wallBotBLE`` + - `JKSoft Wallbot BLE `_ + - nrf51822 ``cortex-m0`` + - 16 MHz ``16000000L`` + - 128 Kb + - 16 Kb + * - ``hrm1017`` + - `Switch Science mbed HRM1017 `_ + - nrf51822 ``cortex-m0`` + - 16 MHz ``16000000L`` + - 128 Kb + - 16 Kb + + +More detailed information you can find here +`nRF51 platforms with support MBED framework `_. diff --git a/docs/platforms/nxplpc.rst b/docs/platforms/nxplpc.rst new file mode 100644 index 00000000..d8dcff37 --- /dev/null +++ b/docs/platforms/nxplpc.rst @@ -0,0 +1,146 @@ +.. _platform_nxplpc: + +Platform ``nxplpc`` +=================== + +`The NXP LPC `_ is a family of 32-bit microcontroller integrated circuits by NXP Semiconductors. The LPC chips are grouped into related series that are based around the same 32-bit ARM processor core, such as the Cortex-M4F, Cortex-M3, Cortex-M0+, or Cortex-M0. Internally, each microcontroller consists of the processor core, static RAM memory, flash memory, debugging interface, and various peripherals. + +.. contents:: + +Packages +-------- + +.. list-table:: + :header-rows: 1 + + * - Name + - Alias + - Contents + * - ``toolchain-gccarmnoneeabi`` + - toolchain + - `gcc-arm-embedded `_, + `GDB `_ + * - ``framework-mbed`` + - + - See below in :ref:`nxplpc_frameworks` + +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). + + +.. _nxplpc_frameworks: + +Frameworks +---------- + +.. list-table:: + :header-rows: 1 + + * - Type ``framework`` + - Name + - Reference + * - ``mbed`` + - MBED Framework + - `Documentation `__ + + +Boards +------ + +.. note:: + * 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 + + * - Type ``board`` + - Name + - Microcontroller ``board_mcu`` + - Frequency ``board_f_cpu`` + - Flash + - RAM + * - ``lpc1549`` + - `LPCXpresso1549 `_ + - LPC1549 ``cortex-m3`` + - 72 MHz ``72000000L`` + - 256 Kb + - 36 Kb + * - ``lpc1768`` + - `mbed LPC1768 `_ + - LPC1768 ``cortex-m3`` + - 96 MHz ``96000000L`` + - 512 Kb + - 32 Kb + * - ``seeeduinoArchPro`` + - `Seeeduino-Arch-Pro `_ + - LPC1768 ``cortex-m3`` + - 96 MHz ``96000000L`` + - 512 Kb + - 32 Kb + * - ``ubloxc027`` + - `U-blox C027 `_ + - LPC1768 ``cortex-m3`` + - 96 MHz ``96000000L`` + - 512 Kb + - 32 Kb + * - ``lpc1114fn28`` + - `mbed LPC1114FN28 `_ + - LPC1114FN28 ``cortex-m0`` + - 48 MHz ``48000000L`` + - 32 Kb + - 4 Kb + * - ``lpc11u24`` + - `mbed LPC11U24 `_ + - LPC11U24 ``cortex-m0`` + - 48 MHz ``48000000L`` + - 32 Kb + - 8 Kb + * - ``dipcortexm0`` + - `DipCortex M0 `_ + - LPC11U24 ``cortex-m0`` + - 50 MHz ``50000000L`` + - 32 Kb + - 8 Kb + * - ``blueboard_lpc11u24`` + - `BlueBoard-LPC11U24 `_ + - LPC11U24 ``cortex-m0`` + - 48 MHz ``48000000L`` + - 32 Kb + - 8 Kb + * - ``mbuino`` + - `Outrageous Circuits mBuino `_ + - LPC11U24 ``cortex-m0`` + - 50 MHz ``50000000L`` + - 32 Kb + - 8 Kb + * - ``lpc11u35`` + - `EA LPC11U35 QuickStart Board `_ + - LPC11U35 ``cortex-m0`` + - 48 MHz ``48000000L`` + - 64 Kb + - 10 Kb + * - ``lpc11u35_501`` + - `TG-LPC11U35-501 QuickStart Board `_ + - LPC11U35 ``cortex-m0`` + - 48 MHz ``48000000L`` + - 64 Kb + - 10 Kb + * - ``lpc4088`` + - `EA LPC4088 QuickStart Board `_ + - LPC4088 ``cortex-m4`` + - 120 MHz ``120000000L`` + - 512 Kb + - 96 Kb + * - ``lpc4088_dm`` + - `EA LPC4088 Display Module `_ + - LPC4088 ``cortex-m4`` + - 120 MHz ``120000000L`` + - 512 Kb + - 96 Kb + + +More detailed information you can find here +`NXP platforms with support MBED framework `_. diff --git a/docs/platforms/stm32.rst b/docs/platforms/stm32.rst deleted file mode 100644 index 4748f6a9..00000000 --- a/docs/platforms/stm32.rst +++ /dev/null @@ -1,104 +0,0 @@ -.. _platform_stm32: - -Platform ``stm32`` -================== - -`The STM32 family of 32-bit Flash MCUs `_ based on the ARM® Cortex®-M processor is designed to offer new degrees of freedom to MCU users. It offers a 32-bit product range that combines very high performance, real-time capabilities, digital signal processing, and low-power, low-voltage operation, while maintaining full integration and ease of development. - -The unparalleled and large range of STM32 devices, based on an industry-standard core and accompanied by a vast choice of tools and software, makes this family of products the ideal choice, both for small projects and for entire platform decisions. - -.. contents:: - -Packages --------- - -.. list-table:: - :header-rows: 1 - - * - Name - - Alias - - Contents - * - ``toolchain-gccarmnoneeabi`` - - toolchain - - `gcc-arm-embedded `_, - `GDB `_ - * - ``tool-stlink`` - - uploader - - `STLink `_ - * - ``framework-cmsis`` - - - - See below in :ref:`stm32_frameworks` - * - ``framework-spl`` - - - - See below in :ref:`stm32_frameworks` - * - ``framework-opencm3`` - - - - See below in :ref:`stm32_frameworks` - -.. warning:: - **Linux Users:** Don't forget to install "udev" rules file - `99-platformio-udev.rules `_ (an instruction is located in the file). - - -.. _stm32_frameworks: - -Frameworks ----------- - -.. list-table:: - :header-rows: 1 - - * - Type ``framework`` - - Name - - Reference - * - ``cmsis`` - - Vendor-independent hardware abstraction layer for the Cortex-M processor series - - `Documentation `__ - * - ``spl`` - - Standard Peripheral Library for STM32 MCUs - - `Documentation `__ - * - ``opencm3`` - - libOpenCM3 Framework - - `Documentation `__ - - -Boards ------- - -.. note:: - * 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 - - * - Type ``board`` - - Name - - Microcontroller ``board_mcu`` - - Frequency ``board_f_cpu`` - - Flash - - RAM - * - ``stm32ldiscovery`` - - `Discovery kit for STM32L151/152 line `_ - - STM32L152rbt6 ``cortex-m3`` - - 32 MHz ``32000000L`` - - 128 Kb - - 16 Kb - * - ``stm32f3discovery`` - - `Discovery kit for STM32F303xx microcontrollers - `_ - - STM32F303vct6 ``cortex-m4`` - - 72 MHz ``72000000L`` - - 256 Kb - - 48 Kb - * - ``stm32f4discovery`` - - `Discovery kit for STM32F407/417 lines - `_ - - STM32F407vgt6 ``cortex-m4`` - - 168 Mhz ``168000000L`` - - 1 Mb - - 192 Kb - -More detailed information you can find here -`STM32 Discovery kits `_. diff --git a/docs/platforms/ststm32.rst b/docs/platforms/ststm32.rst new file mode 100644 index 00000000..4f024041 --- /dev/null +++ b/docs/platforms/ststm32.rst @@ -0,0 +1,224 @@ +.. _platform_ststm32: + +Platform ``ststm32`` +==================== + +`The STM32 family of 32-bit Flash MCUs `_ based on the ARM® Cortex®-M processor is designed to offer new degrees of freedom to MCU users. It offers a 32-bit product range that combines very high performance, real-time capabilities, digital signal processing, and low-power, low-voltage operation, while maintaining full integration and ease of development. + +The unparalleled and large range of STM32 devices, based on an industry-standard core and accompanied by a vast choice of tools and software, makes this family of products the ideal choice, both for small projects and for entire platform decisions. + +.. contents:: + +Packages +-------- + +.. list-table:: + :header-rows: 1 + + * - Name + - Alias + - Contents + * - ``toolchain-gccarmnoneeabi`` + - toolchain + - `gcc-arm-embedded `_, + `GDB `_ + * - ``tool-stlink`` + - uploader + - `STLink `_ + * - ``framework-cmsis`` + - + - See below in :ref:`ststm32_frameworks` + * - ``framework-spl`` + - + - See below in :ref:`ststm32_frameworks` + * - ``framework-opencm3`` + - + - See below in :ref:`ststm32_frameworks` + * - ``framework-mbed`` + - + - See below in :ref:`ststm32_frameworks` + +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). + + +.. _ststm32_frameworks: + +Frameworks +---------- + +.. list-table:: + :header-rows: 1 + + * - Type ``framework`` + - Name + - Reference + * - ``cmsis`` + - Vendor-independent hardware abstraction layer for the Cortex-M processor series + - `Documentation `__ + * - ``spl`` + - Standard Peripheral Library for ST STM32 MCUs + - `Documentation `__ + * - ``opencm3`` + - libOpenCM3 Framework + - `Documentation `__ + * - ``mbed`` + - MBED Framework + - `Documentation `__ + + +Boards +------ + +.. note:: + * 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 + + * - Type ``board`` + - Name + - Microcontroller ``board_mcu`` + - Frequency ``board_f_cpu`` + - Flash + - RAM + * - ``disco_l152rb`` + - `STM32LDISCOVERY + `_ + - STM32L152rbt6 ``cortex-m3`` + - 32 MHz ``32000000L`` + - 128 Kb + - 16 Kb + * - ``disco_f303vc`` + - `STM32F3DISCOVERY + `_ + - STM32F303vct6 ``cortex-m4`` + - 72 MHz ``72000000L`` + - 256 Kb + - 48 Kb + * - ``disco_f407vg`` + - `STM32F4DISCOVERY + `_ + - STM32F407vgt6 ``cortex-m4`` + - 168 Mhz ``168000000L`` + - 1 Mb + - 192 Kb + * - ``disco_f100rb`` + - `STM32VLDISCOVERY + `_ + - STM32F100rbt6 ``cortex-m3`` + - 24 Mhz ``24000000L`` + - 128 Kb + - 8 Kb + * - ``disco_f051r8`` + - `STM32F0DISCOVERY + `_ + - STM32F051r8t6 ``cortex-m0`` + - 48 Mhz ``48000000L`` + - 64 Kb + - 8 Kb + * - ``disco_f334c8`` + - `32F3348DISCOVERY + `_ + - STM32F334c8t6 ``cortex-m4`` + - 72 Mhz ``72000000L`` + - 64 Kb + - 16 Kb + * - ``disco_f401vc`` + - `32F401CDISCOVERY + `_ + - STM32F401vct6 ``cortex-m4`` + - 84 Mhz ``84000000L`` + - 256 Kb + - 64 Kb + * - ``disco_f429zi`` + - `32F429IDISCOVERY + `_ + - STM32F429zit6 ``cortex-m4`` + - 180 Mhz ``180000000L`` + - 2 Mb + - 256 Kb + * - ``nucleo_f030r8`` + - `ST Nucleo F030R8 + `_ + - STM32F030r8t6 ``cortex-m0`` + - 48 Mhz ``48000000L`` + - 64 Kb + - 8 Kb + * - ``nucleo_f070rb`` + - `ST Nucleo F070RB + `_ + - STM32F070rbt6 ``cortex-m0`` + - 48 Mhz ``48000000L`` + - 128 Kb + - 16 Kb + * - ``nucleo_f072rb`` + - `ST Nucleo F072RB + `_ + - STM32F072rbt6 ``cortex-m0`` + - 48 Mhz ``48000000L`` + - 128 Kb + - 16 Kb + * - ``nucleo_f091rc`` + - `ST Nucleo F091RC + `_ + - STM32F091rct6 ``cortex-m0`` + - 48 Mhz ``48000000L`` + - 256 Kb + - 32 Kb + * - ``nucleo_f103rb`` + - `ST Nucleo F103RB + `_ + - STM32F103rbt6 ``cortex-m3`` + - 72 Mhz ``72000000L`` + - 128 Kb + - 20 Kb + * - ``nucleo_f302r8`` + - `ST Nucleo F302R8 + `_ + - STM32F302r8t6 ``cortex-m4`` + - 72 Mhz ``72000000L`` + - 64 Kb + - 16 Kb + * - ``nucleo_f334r8`` + - `ST Nucleo F334R8 + `_ + - STM32F334r8t6 ``cortex-m4`` + - 72 Mhz ``72000000L`` + - 64 Kb + - 16 Kb + * - ``nucleo_f401re`` + - `ST Nucleo F401RE + `_ + - STM32F401ret6 ``cortex-m4`` + - 84 Mhz ``84000000L`` + - 512 Kb + - 96 Kb + * - ``nucleo_f411re`` + - `ST Nucleo F411RE + `_ + - STM32F411ret6 ``cortex-m4`` + - 100 Mhz ``100000000L`` + - 512 Kb + - 128 Kb + * - ``nucleo_l053r8`` + - `ST Nucleo L053R8 + `_ + - STM32L053r8t6 ``cortex-m0`` + - 48 Mhz ``48000000L`` + - 64 Kb + - 8 Kb + * - ``nucleo_l152re`` + - `ST Nucleo L152RE + `_ + - STM32L152ret6 ``cortex-m3`` + - 32 Mhz ``32000000L`` + - 512 Kb + - 80 Kb + +More detailed information you can find here +`STM32 Discovery kits `_ and here +`ST Nucleo boards with MBED support `_. diff --git a/examples/mbed/mbed-blink/README.rst b/examples/mbed/mbed-blink/README.rst new file mode 100644 index 00000000..b36ea0e3 --- /dev/null +++ b/examples/mbed/mbed-blink/README.rst @@ -0,0 +1,21 @@ +How to buid PlatformIO based project +==================================== + +1. `Install PlatformIO `_ +2. Download `source code with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platformio-develop/examples/mbed/mbed-blink + + # Process example project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/mbed/mbed-blink/platformio.ini b/examples/mbed/mbed-blink/platformio.ini new file mode 100644 index 00000000..bbef0cbe --- /dev/null +++ b/examples/mbed/mbed-blink/platformio.ini @@ -0,0 +1,43 @@ +# +# Project Configuration File +# +# 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% +# framework = +# board = +# +# Automatic targets - enable auto-uploading +# targets = upload + + +# NXP LPC Platform +[env:lpc1768] +platform = nxplpc +framework = mbed +board = lpc1768 + +# Nordic nRF51 Platform +[env:nrf51_mkit] +platform = nordicnrf51 +framework = mbed +board = nrf51_mkit + +# Freescale FRDM Platform +[env:frdm_k64f] +platform = freescalekinetis +framework = mbed +board = frdm_k64f + +# ST STM32 Platform +[env:nucleo_f401re] +platform = ststm32 +framework = mbed +board = nucleo_f401re \ No newline at end of file diff --git a/examples/mbed/mbed-blink/src/main.cpp b/examples/mbed/mbed-blink/src/main.cpp new file mode 100644 index 00000000..8247a2e9 --- /dev/null +++ b/examples/mbed/mbed-blink/src/main.cpp @@ -0,0 +1,12 @@ +#include "mbed.h" + +DigitalOut myled(LED1); + +int main() { + while(1) { + myled = 1; + wait(1); + myled = 0; + wait(1); + } +} \ No newline at end of file diff --git a/examples/stm32/stm32-cmsis-blink/platformio.ini b/examples/stm32/stm32-cmsis-blink/platformio.ini index c90f099e..d19acf8d 100644 --- a/examples/stm32/stm32-cmsis-blink/platformio.ini +++ b/examples/stm32/stm32-cmsis-blink/platformio.ini @@ -17,17 +17,17 @@ # Automatic targets - enable auto-uploading # targets = upload -[env:stm32f4discovery] -platform = stm32 +[env:disco_f407vg] +platform = ststm32 framework = cmsis -board = stm32f4discovery +board = disco_f407vg -[env:stm32ldiscovery] -platform = stm32 +[env:disco_l152rb] +platform = ststm32 framework = cmsis -board = stm32ldiscovery +board = disco_l152rb -[env:stm32f3discovery] -platform = stm32 +[env:disco_f303vc] +platform = ststm32 framework = cmsis -board = stm32f3discovery +board = disco_f303vc \ No newline at end of file diff --git a/examples/stm32/stm32-opencm3-blink/platformio.ini b/examples/stm32/stm32-opencm3-blink/platformio.ini index 3c472f00..4055d71f 100644 --- a/examples/stm32/stm32-opencm3-blink/platformio.ini +++ b/examples/stm32/stm32-opencm3-blink/platformio.ini @@ -17,17 +17,17 @@ # Automatic targets - enable auto-uploading # targets = upload -[env:stm32f4discovery] -platform = stm32 +[env:disco_f407vg] +platform = ststm32 framework = opencm3 -board = stm32f4discovery +board = disco_f407vg -[env:stm32ldiscovery] -platform = stm32 +[env:disco_l152rb] +platform = ststm32 framework = opencm3 -board = stm32ldiscovery +board = disco_l152rb -[env:stm32f3discovery] -platform = stm32 +[env:disco_f303vc] +platform = ststm32 framework = opencm3 -board = stm32f3discovery +board = disco_f303vc diff --git a/examples/stm32/stm32-spl-blink/platformio.ini b/examples/stm32/stm32-spl-blink/platformio.ini index 6ba5b0c1..1324053c 100644 --- a/examples/stm32/stm32-spl-blink/platformio.ini +++ b/examples/stm32/stm32-spl-blink/platformio.ini @@ -17,17 +17,17 @@ # Automatic targets - enable auto-uploading # targets = upload -[env:stm32f4discovery] -platform = stm32 +[env:disco_f407vg] +platform = ststm32 framework = cmsis,spl -board = stm32f4discovery +board = disco_f407vg -[env:stm32ldiscovery] -platform = stm32 +[env:disco_l152rb] +platform = ststm32 framework = cmsis,spl -board = stm32ldiscovery +board = disco_l152rb -[env:stm32f3discovery] -platform = stm32 +[env:disco_f303vc] +platform = ststm32 framework = cmsis,spl -board = stm32f3discovery +board = disco_f303vc diff --git a/platformio/boards/adafruit.json b/platformio/boards/adafruit.json index 4e7832d0..3ace87a3 100644 --- a/platformio/boards/adafruit.json +++ b/platformio/boards/adafruit.json @@ -34,7 +34,7 @@ "variant": "tiny8" }, "framework": "arduino", - "name": "Adafruit Trinket 8MHz", + "name": "Adafruit Trinket 3V/8MHz", "platform": "atmelavr", "upload": { "maximum_ram_size": 512, @@ -52,7 +52,7 @@ "variant": "tiny8" }, "framework": "arduino", - "name": "Adafruit Trinket 16MHz", + "name": "Adafruit Trinket 5V/16MHz", "platform": "atmelavr", "upload": { "maximum_ram_size": 512, diff --git a/platformio/boards/freescalekinetis.json b/platformio/boards/freescalekinetis.json new file mode 100644 index 00000000..9eb9a25e --- /dev/null +++ b/platformio/boards/freescalekinetis.json @@ -0,0 +1,87 @@ +{ + "frdm_kl25z": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0plus", + "mcu": "mkl25z128vlk4" + }, + "framework": "mbed", + "name": "Freescale Kinetis FRDM-KL25Z", + "platform": "freescalekinetis", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 131072 + } + }, + "frdm_kl46z": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0plus", + "mcu": "mkl46z256vll4" + }, + "framework": "mbed", + "name": "Freescale Kinetis FRDM-KL46Z", + "platform": "freescalekinetis", + "upload": { + "maximum_ram_size": 32768, + "maximum_size": 262144 + } + }, + "frdm_k64f": { + "build": { + "f_cpu": "120000000L", + "cpu": "cortex-m4", + "mcu": "mk64fn1m0vll12" + }, + "framework": "mbed", + "name": "Freescale Kinetis FRDM-K64F", + "platform": "freescalekinetis", + "upload": { + "maximum_ram_size": 262144, + "maximum_size": 1048567 + } + }, + "frdm_kl05z": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0plus", + "mcu": "mkl05z32vfm4" + }, + "framework": "mbed", + "name": "Freescale Kinetis FRDM-KL05Z", + "platform": "freescalekinetis", + "upload": { + "maximum_ram_size": 4096, + "maximum_size": 32768 + } + }, + "frdm_k20d50m": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m4", + "mcu": "mk20dx128vlh5" + }, + "framework": "mbed", + "name": "Freescale Kinetis FRDM-K20D50M", + "platform": "freescalekinetis", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 131072 + } + } + , + "frdm_k22f": { + "build": { + "f_cpu": "120000000L", + "cpu": "cortex-m4", + "mcu": "mk22fn512vlh12" + }, + "framework": "mbed", + "name": "Freescale Kinetis FRDM-K22F", + "platform": "freescalekinetis", + "upload": { + "maximum_ram_size": 131072, + "maximum_size": 524288 + } + } +} \ No newline at end of file diff --git a/platformio/boards/nordicnrf51.json b/platformio/boards/nordicnrf51.json new file mode 100644 index 00000000..f7202b31 --- /dev/null +++ b/platformio/boards/nordicnrf51.json @@ -0,0 +1,102 @@ +{ + "nrf51_mkit": { + "build": { + "f_cpu": "16000000L", + "cpu": "cortex-m0", + "mcu": "nrf51822" + }, + "framework": "mbed", + "name": "Nordic nRF51822-mKIT", + "platform": "nordicnrf51", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 131072 + } + }, + "hrm1017": { + "build": { + "f_cpu": "16000000L", + "cpu": "cortex-m0", + "mcu": "nrf51822" + }, + "framework": "mbed", + "name": "Switch Science mbed HRM1017", + "platform": "nordicnrf51", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 262144 + } + }, + "redBearLab": { + "build": { + "f_cpu": "16000000L", + "cpu": "cortex-m0", + "mcu": "nrf51822" + }, + "framework": "mbed", + "name": "RedBearLab nRF51822", + "platform": "nordicnrf51", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 262144 + } + }, + "nrf51_dk": { + "build": { + "f_cpu": "32000000L", + "cpu": "cortex-m0", + "mcu": "nrf51822" + }, + "framework": "mbed", + "name": "Nordic nRF51-DK", + "platform": "nordicnrf51", + "upload": { + "maximum_ram_size": 32384, + "maximum_size": 262144 + } + }, + "redBearLabBLENano": { + "build": { + "f_cpu": "16000000L", + "cpu": "cortex-m0", + "mcu": "nrf51822" + }, + "framework": "mbed", + "name": "RedBearLab BLE Nano", + "platform": "nordicnrf51", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 262144 + } + }, + "nrf51_dongle": { + "build": { + "f_cpu": "32000000L", + "cpu": "cortex-m0", + "mcu": "nrf51822" + }, + "framework": "mbed", + "name": "Nordic nRF51-Dongle", + "platform": "nordicnrf51", + "upload": { + "maximum_ram_size": 32384, + "maximum_size": 262144 + } + } + , + "wallBotBLE": { + "build": { + "f_cpu": "16000000L", + "cpu": "cortex-m0", + "mcu": "nrf51822" + }, + "framework": "mbed", + "name": "JKSoft Wallbot BLE", + "platform": "nordicnrf51", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 131072 + } + } + +} \ No newline at end of file diff --git a/platformio/boards/nxplpc.json b/platformio/boards/nxplpc.json new file mode 100644 index 00000000..de012c48 --- /dev/null +++ b/platformio/boards/nxplpc.json @@ -0,0 +1,184 @@ +{ + "lpc1768": { + "build": { + "f_cpu": "96000000L", + "cpu": "cortex-m3", + "mcu": "lpc1768" + }, + "framework": "mbed", + "name": "mbed LPC1768", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 32768, + "maximum_size": 524288 + } + }, + "lpc11u24": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "lpc11u24" + }, + "framework": "mbed", + "name": "mbed LPC11U24", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 32768 + } + }, + "lpc4088": { + "build": { + "f_cpu": "120000000L", + "cpu": "cortex-m4", + "mcu": "lpc4088" + }, + "framework": "mbed", + "name": "EA LPC4088 QuickStart Board", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 98304, + "maximum_size": 524288 + } + }, + "dipcortexm0": { + "build": { + "f_cpu": "50000000L", + "cpu": "cortex-m0", + "mcu": "lpc11u24" + }, + "framework": "mbed", + "name": "DipCortex M0", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 32768 + } + }, + "blueboard_lpc11u24": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "lpc11u24" + }, + "framework": "mbed", + "name": "BlueBoard-LPC11U24", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 32768 + } + }, + "seeeduinoArchPro": { + "build": { + "f_cpu": "96000000L", + "cpu": "cortex-m3", + "mcu": "lpc1768" + }, + "framework": "mbed", + "name": "Seeeduino-Arch-Pro", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 32768, + "maximum_size": 524288 + } + }, + "ubloxc027": { + "build": { + "f_cpu": "96000000L", + "cpu": "cortex-m3", + "mcu": "lpc1768" + }, + "framework": "mbed", + "name": "u-blox C027", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 32768, + "maximum_size": 524288 + } + }, + "lpc1114fn28": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "lpc1114fn28" + }, + "framework": "mbed", + "name": "mbed LPC1114FN28", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 4096, + "maximum_size": 32768 + } + }, + "lpc11u35": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "lpc11u35" + }, + "framework": "mbed", + "name": "EA LPC11U35 QuickStart Board", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 10240, + "maximum_size": 65536 + } + }, + "lpc11u35_501": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "lpc11u35" + }, + "framework": "mbed", + "name": "TG-LPC11U35-501", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 10240, + "maximum_size": 65536 + } + }, + "lpc1549": { + "build": { + "f_cpu": "72000000L", + "cpu": "cortex-m3", + "mcu": "lpc1549" + }, + "framework": "mbed", + "name": "LPCXpresso1549", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 36864, + "maximum_size": 262144 + } + }, + "mbuino": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "lpc11u24" + }, + "framework": "mbed", + "name": "Outrageous Circuits mBuino", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 32768 + } + }, + "lpc4088_dm": { + "build": { + "f_cpu": "120000000L", + "cpu": "cortex-m4", + "mcu": "lpc4088" + }, + "framework": "mbed", + "name": "EA LPC4088 Display Module", + "platform": "nxplpc", + "upload": { + "maximum_ram_size": 98304, + "maximum_size": 524288 + } + } +} \ No newline at end of file diff --git a/platformio/boards/stm32.json b/platformio/boards/stm32.json deleted file mode 100644 index 2dae3544..00000000 --- a/platformio/boards/stm32.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "stm32f4discovery": { - "build": { - "core": "stm32", - "extra_flags": "-DSTM32F40_41xxx", - "f_cpu": "168000000L", - "ldscript": "stm32f405x6.ld", - "cpu": "cortex-m4", - "mcu": "stm32f407vgt6", - "variant": "stm32f4" - }, - "framework": "cmsis", - "name": "STM32F4Discovery (168 MHz) with digital accelerometer, digital microphone, audio DAC", - "platform": "stm32", - "upload": { - "maximum_ram_size": 131071, - "maximum_size": 1048575 - } - }, - "stm32ldiscovery": { - "build": { - "core": "stm32", - "extra_flags": "-DSTM32L1XX_MD", - "f_cpu": "32000000L", - "ldscript": "stm32l15xx6.ld", - "cpu": "cortex-m3", - "mcu": "stm32l152rbt6", - "variant": "stm32l1" - }, - "framework": "cmsis", - "name": "STM32LDiscovery (32 MHz) ultra low-power development kit", - "platform": "stm32", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 131072 - } - }, - "stm32f3discovery": { - "build": { - "core": "stm32", - "extra_flags": "-DSTM32F303xC", - "f_cpu": "72000000L", - "ldscript": "stm32f30xx.ld", - "cpu": "cortex-m4", - "mcu": "stm32f303vct6", - "variant": "stm32f3" - }, - "framework": "cmsis", - "name": "STM32F3Discovery (72 MHz) with accelerometer, gyroscope and e-compass", - "platform": "stm32", - "upload": { - "maximum_ram_size": 262144, - "maximum_size": 131072 - } - } -} \ No newline at end of file diff --git a/platformio/boards/ststm32.json b/platformio/boards/ststm32.json new file mode 100644 index 00000000..0f5f673d --- /dev/null +++ b/platformio/boards/ststm32.json @@ -0,0 +1,280 @@ +{ + "disco_f407vg": { + "build": { + "core": "stm32", + "extra_flags": "-DSTM32F40_41xxx", + "f_cpu": "168000000L", + "ldscript": "stm32f405x6.ld", + "cpu": "cortex-m4", + "mcu": "stm32f407vgt6", + "variant": "stm32f4" + }, + "framework": "cmsis", + "name": "STM32F4DISCOVERY", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 131072, + "maximum_size": 1048576 + } + }, + "disco_l152rb": { + "build": { + "core": "stm32", + "extra_flags": "-DSTM32L1XX_MD", + "f_cpu": "32000000L", + "ldscript": "stm32l15xx6.ld", + "cpu": "cortex-m3", + "mcu": "stm32l152rbt6", + "variant": "stm32l1" + }, + "framework": "cmsis", + "name": "STM32LDISCOVERY", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 131072 + } + }, + "disco_f303vc": { + "build": { + "core": "stm32", + "extra_flags": "-DSTM32F303xC", + "f_cpu": "72000000L", + "ldscript": "stm32f30xx.ld", + "cpu": "cortex-m4", + "mcu": "stm32f303vct6", + "variant": "stm32f3" + }, + "framework": "cmsis", + "name": "STM32F3DISCOVERY", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 49152, + "maximum_size": 262144 + } + }, + "disco_f100rb": { + "build": { + "f_cpu": "24000000L", + "cpu": "cortex-m3", + "mcu": "stm32f100rbt6" + }, + "framework": "mbed", + "name": "STM32VLDISCOVERY", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 131072 + } + }, + "disco_f051r8": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "stm32f051r8t6" + }, + "framework": "mbed", + "name": "STM32F0DISCOVERY", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 65536 + } + }, + "disco_f334c8": { + "build": { + "f_cpu": "72000000L", + "cpu": "cortex-m4", + "mcu": "stm32f334c8t6" + }, + "framework": "mbed", + "name": "32F3348DISCOVERY", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 65536 + } + }, + "disco_f401vc": { + "build": { + "f_cpu": "84000000L", + "cpu": "cortex-m4", + "mcu": "stm32f401vct6" + }, + "framework": "mbed", + "name": "32F401CDISCOVERY", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 65536, + "maximum_size": 262144 + } + }, + "disco_f429zi": { + "build": { + "f_cpu": "180000000L", + "cpu": "cortex-m4", + "mcu": "stm32f429zit6" + }, + "framework": "mbed", + "name": "32F429IDISCOVERY", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 262144, + "maximum_size": 2097152 + } + }, + "nucleo_f030r8": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "stm32f030r8t6" + }, + "framework": "mbed", + "name": "ST Nucleo F030R8", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 65536 + } + }, + "nucleo_f070rb": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "stm32f070rbt6" + }, + "framework": "mbed", + "name": "ST Nucleo F070RB", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 131072 + } + }, + "nucleo_f072rb": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "stm32f072rbt6" + }, + "framework": "mbed", + "name": "ST Nucleo F072RB", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 131072 + } + }, + "nucleo_f091rc": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "stm32f091rct6" + }, + "framework": "mbed", + "name": "ST Nucleo F091RC", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 32768, + "maximum_size": 262144 + } + }, + "nucleo_f103rb": { + "build": { + "f_cpu": "72000000L", + "cpu": "cortex-m3", + "mcu": "stm32f103rbt6" + }, + "framework": "mbed", + "name": "ST Nucleo F103RB", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 20480, + "maximum_size": 131072 + } + }, + "nucleo_f302r8": { + "build": { + "f_cpu": "72000000L", + "cpu": "cortex-m4", + "mcu": "stm32f302r8t6" + }, + "framework": "mbed", + "name": "ST Nucleo F302R8", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 65536 + } + }, + "nucleo_f334r8": { + "build": { + "f_cpu": "72000000L", + "cpu": "cortex-m4", + "mcu": "stm32f334r8t6" + }, + "framework": "mbed", + "name": "ST Nucleo F334R8", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 65536 + } + }, + "nucleo_f401re": { + "build": { + "f_cpu": "84000000L", + "cpu": "cortex-m4", + "mcu": "stm32f401ret6" + }, + "framework": "mbed", + "name": "ST Nucleo F401RE", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 98304, + "maximum_size": 524288 + } + }, + "nucleo_f411re": { + "build": { + "f_cpu": "100000000L", + "cpu": "cortex-m4", + "mcu": "stm32f411ret6" + }, + "framework": "mbed", + "name": "ST Nucleo F411RE", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 131072, + "maximum_size": 524288 + } + }, + "nucleo_l053r8": { + "build": { + "f_cpu": "48000000L", + "cpu": "cortex-m0", + "mcu": "stm32l053r8t6" + }, + "framework": "mbed", + "name": "ST Nucleo L053R8", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 65536 + } + }, + "nucleo_l152re": { + "build": { + "f_cpu": "32000000L", + "cpu": "cortex-m3", + "mcu": "stm32l152ret6" + }, + "framework": "mbed", + "name": "ST Nucleo L152RE", + "platform": "ststm32", + "upload": { + "maximum_ram_size": 81920, + "maximum_size": 524288 + } + } +} \ No newline at end of file diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index c32fe8b1..eacb925b 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -82,13 +82,11 @@ else: UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i' ) -CORELIBS = env.ProcessGeneral() - # # Target: Build executable and linkable firmware # -target_elf = env.BuildFirmware(["m"] + CORELIBS) +target_elf = env.BuildFirmware() # # Target: Extract EEPROM data (from EEMEM directive) to .eep file diff --git a/platformio/builder/scripts/atmelsam.py b/platformio/builder/scripts/atmelsam.py index 347cb75a..596872c8 100644 --- a/platformio/builder/scripts/atmelsam.py +++ b/platformio/builder/scripts/atmelsam.py @@ -68,13 +68,11 @@ env.Append( ] ) -CORELIBS = env.ProcessGeneral() - # # Target: Build executable and linkable firmware # -target_elf = env.BuildFirmware(["m", "gcc"] + CORELIBS) +target_elf = env.BuildFirmware() # # Target: Build the .bin file diff --git a/platformio/builder/scripts/basearm.py b/platformio/builder/scripts/basearm.py index 0cb81b83..9ae00990 100644 --- a/platformio/builder/scripts/basearm.py +++ b/platformio/builder/scripts/basearm.py @@ -50,16 +50,15 @@ env.Replace( "-mcpu=${BOARD_OPTIONS['build']['cpu']}" ], + LIBS=["c", "gcc", "m"], + SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES' ) -if env.get("BOARD_OPTIONS", {}).get("build", {}).get("cpu", "")[-2:] == "m4": +if env.get("BOARD_OPTIONS", {}).get("build", {}).get( + "cpu", "")[-2:] == "m4" and env.get("BOARD") != "frdm_k20d50m": env.Append( - ASFLAGS=[ - "-mfloat-abi=hard", - "-mfpu=fpv4-sp-d16" - ], - CCFLAGS=[ + CPPFLAGS=[ "-mfloat-abi=hard", "-mfpu=fpv4-sp-d16", "-fsingle-precision-constant" diff --git a/platformio/builder/scripts/baseavr.py b/platformio/builder/scripts/baseavr.py index bfe19df8..8a0384f1 100644 --- a/platformio/builder/scripts/baseavr.py +++ b/platformio/builder/scripts/baseavr.py @@ -47,6 +47,8 @@ env.Replace( "-Wl,--gc-sections" ], + LIBS=["m"], + SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES' ) diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index 77ef6c88..f154d5c9 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -8,7 +8,7 @@ from os import listdir, walk from os.path import isfile, join -from SCons.Script import DefaultEnvironment, Return +from SCons.Script import DefaultEnvironment env = DefaultEnvironment() @@ -178,4 +178,4 @@ if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam": join("$PLATFORMFW_DIR", "system", "libsam", "source") )) -Return("libs") +env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/frameworks/cmsis.py b/platformio/builder/scripts/frameworks/cmsis.py index 4af5b98a..66bc005c 100644 --- a/platformio/builder/scripts/frameworks/cmsis.py +++ b/platformio/builder/scripts/frameworks/cmsis.py @@ -7,7 +7,7 @@ from os.path import join -from SCons.Script import DefaultEnvironment, Return +from SCons.Script import DefaultEnvironment env = DefaultEnvironment() @@ -39,4 +39,4 @@ libs.append(envsafe.BuildLibrary( join("$PLATFORMFW_DIR", "variants", "${BOARD_OPTIONS['build']['variant']}") )) -Return("libs") +env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/frameworks/energia.py b/platformio/builder/scripts/frameworks/energia.py index a4f72a63..8e1e4901 100644 --- a/platformio/builder/scripts/frameworks/energia.py +++ b/platformio/builder/scripts/frameworks/energia.py @@ -7,7 +7,7 @@ from os.path import join -from SCons.Script import DefaultEnvironment, Return +from SCons.Script import DefaultEnvironment env = DefaultEnvironment() @@ -52,4 +52,4 @@ libs.append(env.BuildLibrary( join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}") )) -Return("libs") +env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/frameworks/mbed.py b/platformio/builder/scripts/frameworks/mbed.py new file mode 100644 index 00000000..03f54616 --- /dev/null +++ b/platformio/builder/scripts/frameworks/mbed.py @@ -0,0 +1,140 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +""" + Build script for Mbed Framework +""" + +import xml.etree.ElementTree as ElementTree +from binascii import crc32 +from os.path import join, normpath + +from SCons.Script import DefaultEnvironment + +env = DefaultEnvironment() + +BOARD_OPTS = env.get("BOARD_OPTIONS", {}).get("build", {}) + +env.Replace( + PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-mbed") +) + +MBED_VARIANTS = { + "stm32f3discovery": "DISCO_F303VC", + "stm32f4discovery": "DISCO_F407VG", + "stm32f429discovery": "DISCO_F429ZI", + "blueboard_lpc11u24": "LPC11U24", + "dipcortexm0": "LPC11U24", + "seeeduinoArchPro": "ARCH_PRO", + "ubloxc027": "UBLOX_C027", + "lpc1114fn28": "LPC1114", + "lpc11u35": "LPC11U35_401", + "mbuino": "LPC11U24", + "nrf51_mkit": "NRF51822", + "redBearLab": "NRF51822", + "nrf51-dt": "NRF51_DK", + "redBearLabBLENano": "NRF51822", + "wallBotBLE": "NRF51822", + "frdm_kl25z": "KL25Z", + "frdm_kl46z": "KL46Z", + "frdm_k64f": "K64F", + "frdm_kl05z": "KL05Z", + "frdm_k20d50m": "K20D50M", + "frdm_k22f": "K22F" +} + + +def parse_eix_file(filename): + result = {} + paths = ( + ("CFLAGS", "./Target/Source/CC/Switch"), + ("CXXFLAGS", "./Target/Source/CPPC/Switch"), + ("CPPDEFINES", "./Target/Source/Symbols/Symbol"), + ("FILES", "./Target/Files/File"), + ("LINKFLAGS", "./Target/Source/LD/Switch"), + ("STDLIBS", "./Target/Source/Syslibs/Library"), + ("LDSCRIPT_PATH", "./Target/Source/Scriptfile"), + ("CPPPATH", "./Target/Compiler/Includepaths/Includepath") + ) + + tree = ElementTree.parse(filename) + + for (key, path) in paths: + if key not in result: + result[key] = [] + + for node in tree.findall(path): + _nkeys = node.keys() + result[key].append( + node.get(_nkeys[0]) if len(_nkeys) == 1 else node.attrib) + + return result + + +def get_source_files(flist): + files = [] + for f in flist: + if f['type'] == "h" or not f['name'].startswith("mbed"): + continue + files.append(join("$BUILD_DIR", "FrameworkMBED", f['name'][5:])) + return files + + +def get_build_flags(data): + flags = {} + cflags = set(data.get("CFLAGS", [])) + cxxflags = set(data.get("CXXFLAGS", [])) + cppflags = set(cflags & cxxflags) + flags['CPPFLAGS'] = list(cppflags) + flags['CXXFLAGS'] = list(cxxflags - cppflags) + flags['CFLAGS'] = list(cflags - cppflags) + return flags + +board_type = env.subst("$BOARD") +variant = MBED_VARIANTS[ + board_type] if board_type in MBED_VARIANTS else board_type.upper() +eixdata = parse_eix_file( + join(env.subst("$PLATFORMFW_DIR"), "variant", variant, "%s.eix" % variant)) + +build_flags = get_build_flags(eixdata) +env.Replace( + CPPFLAGS=build_flags.get("CPPFLAGS", []), + CFLAGS=build_flags.get("CFLAGS", []), + CXXFLAGS=build_flags.get("CXXFLAGS", []), + LINKFLAGS=eixdata.get("LINKFLAGS", []), + CPPDEFINES=[define for define in eixdata.get("CPPDEFINES", [])], + LDSCRIPT_PATH=normpath(join( + "$PLATFORMFW_DIR", "core", eixdata.get("LDSCRIPT_PATH")[0][5:])) +) + +# Hook for K64F and K22F +if board_type in ("frdm_k22f", "frdm_k64f"): + env.Append( + LINKFLAGS=["-Wl,--start-group"] + ) + +for lib_path in eixdata.get("CPPPATH"): + _vdir = join("$BUILD_DIR", "FrameworkMbedInc%d" % crc32(lib_path)) + env.VariantDir( + _vdir, + join("$PLATFORMFW_DIR", "core", lib_path[5:]) + ) + env.Append(CPPPATH=[_vdir]) + + +# +# Target: Build MBED Library +# + +libs = [l for l in eixdata.get("STDLIBS", []) if l not in env.get("LIBS")] + +env.VariantDir( + join("$BUILD_DIR", "FrameworkMBED"), + join("$PLATFORMFW_DIR", "core") +) +libs.append(env.Library( + join("$BUILD_DIR", "FrameworkMBED"), + get_source_files(eixdata.get("FILES", [])) +)) + +env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/frameworks/opencm3.py b/platformio/builder/scripts/frameworks/opencm3.py index 5742429c..330fcd07 100644 --- a/platformio/builder/scripts/frameworks/opencm3.py +++ b/platformio/builder/scripts/frameworks/opencm3.py @@ -9,7 +9,7 @@ import re from os import listdir, sep, walk from os.path import isfile, join, normpath -from SCons.Script import DefaultEnvironment, Return +from SCons.Script import DefaultEnvironment from platformio.util import exec_command @@ -168,4 +168,4 @@ libs.append(env.Library( get_source_files(root_dir) )) -Return("libs") +env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/frameworks/spl.py b/platformio/builder/scripts/frameworks/spl.py index ee19fc0c..b4644678 100644 --- a/platformio/builder/scripts/frameworks/spl.py +++ b/platformio/builder/scripts/frameworks/spl.py @@ -7,7 +7,7 @@ from os.path import join -from SCons.Script import DefaultEnvironment, Return +from SCons.Script import DefaultEnvironment env = DefaultEnvironment() @@ -61,4 +61,4 @@ libs.append(envsafe.BuildLibrary( ignore_files )) -Return("libs") +env.Append(LIBS=libs) diff --git a/platformio/builder/scripts/freescalekinetis.py b/platformio/builder/scripts/freescalekinetis.py new file mode 100644 index 00000000..bb5f7048 --- /dev/null +++ b/platformio/builder/scripts/freescalekinetis.py @@ -0,0 +1,59 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +""" + Builder for Freescale Kinetis series ARM microcontrollers. +""" + +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"))) + +# +# Target: Build executable and linkable firmware +# + +target_elf = env.BuildFirmware() + +# +# Target: Build the .bin file +# + +if "uploadlazy" in COMMAND_LINE_TARGETS: + target_firm = join("$BUILD_DIR", "firmware.bin") +else: + target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) + +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") +AlwaysBuild(target_size) + +# +# Target: Upload by default .bin file +# + +upload = env.Alias(["upload", "uploadlazy"], target_firm, UploadToDisk) +AlwaysBuild(upload) + +# +# Target: Define targets +# + +Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/nordicnrf51.py b/platformio/builder/scripts/nordicnrf51.py new file mode 100644 index 00000000..1460b81d --- /dev/null +++ b/platformio/builder/scripts/nordicnrf51.py @@ -0,0 +1,59 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +""" + Builder for Nordic nRF51 series ARM microcontrollers. +""" + +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"))) + +# +# Target: Build executable and linkable firmware +# + +target_elf = env.BuildFirmware() + +# +# Target: Build the .bin file +# + +if "uploadlazy" in COMMAND_LINE_TARGETS: + target_firm = join("$BUILD_DIR", "firmware.bin") +else: + target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) + +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") +AlwaysBuild(target_size) + +# +# Target: Upload by default .bin file +# + +upload = env.Alias(["upload", "uploadlazy"], target_firm, UploadToDisk) +AlwaysBuild(upload) + +# +# Target: Define targets +# + +Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/nxplpc.py b/platformio/builder/scripts/nxplpc.py new file mode 100644 index 00000000..4782c81e --- /dev/null +++ b/platformio/builder/scripts/nxplpc.py @@ -0,0 +1,59 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +""" + Builder for NXP LPC series ARM microcontrollers. +""" + +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"))) + +# +# Target: Build executable and linkable firmware +# + +target_elf = env.BuildFirmware() + +# +# Target: Build the .bin file +# + +if "uploadlazy" in COMMAND_LINE_TARGETS: + target_firm = join("$BUILD_DIR", "firmware.bin") +else: + target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) + +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") +AlwaysBuild(target_size) + +# +# Target: Upload by default .bin file +# + +upload = env.Alias(["upload", "uploadlazy"], target_firm, UploadToDisk) +AlwaysBuild(upload) + +# +# Target: Define targets +# + +Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/stm32.py b/platformio/builder/scripts/ststm32.py similarity index 67% rename from platformio/builder/scripts/stm32.py rename to platformio/builder/scripts/ststm32.py index 4cd991af..9bc2f4c8 100644 --- a/platformio/builder/scripts/stm32.py +++ b/platformio/builder/scripts/ststm32.py @@ -2,15 +2,23 @@ # See LICENSE for details. """ - Builder for STMicroelectronics - STM32 Series ARM microcontrollers. + Builder for ST STM32 Series ARM microcontrollers. """ 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"))) @@ -38,13 +46,11 @@ env.Append( ] ) -CORELIBS = env.ProcessGeneral() - # # Target: Build executable and linkable firmware # -target_elf = env.BuildFirmware(["c", "gcc", "m", "nosys"] + CORELIBS) +target_elf = env.BuildFirmware() # # Target: Build the .bin file @@ -66,7 +72,10 @@ AlwaysBuild(target_size) # Target: Upload by default .bin file # -upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") +if "mbed" in env.subst("$FRAMEWORK"): + upload = env.Alias(["upload", "uploadlazy"], target_firm, UploadToDisk) +else: + upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") AlwaysBuild(upload) # diff --git a/platformio/builder/scripts/teensy.py b/platformio/builder/scripts/teensy.py index a6f9837c..140fa8fd 100644 --- a/platformio/builder/scripts/teensy.py +++ b/platformio/builder/scripts/teensy.py @@ -53,13 +53,11 @@ else: UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS' ) -CORELIBS = env.ProcessGeneral() - # # Target: Build executable and linkable firmware # -target_elf = env.BuildFirmware(["m"] + CORELIBS) +target_elf = env.BuildFirmware() # # Target: Build the firmware file diff --git a/platformio/builder/scripts/timsp430.py b/platformio/builder/scripts/timsp430.py index 98fbd1d1..90507539 100644 --- a/platformio/builder/scripts/timsp430.py +++ b/platformio/builder/scripts/timsp430.py @@ -48,6 +48,8 @@ env.Replace( "-Wl,-gc-sections,-u,main" ], + LIBS=["m"], + SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', UPLOADER=join("$PIOPACKAGES_DIR", "tool-mspdebug", "mspdebug"), @@ -74,13 +76,11 @@ env.Append( ) ) -CORELIBS = env.ProcessGeneral() - # # Target: Build executable and linkable firmware # -target_elf = env.BuildFirmware(["m"] + CORELIBS) +target_elf = env.BuildFirmware() # # Target: Build the .hex diff --git a/platformio/builder/scripts/titiva.py b/platformio/builder/scripts/titiva.py index b96d4b70..db14ecdf 100644 --- a/platformio/builder/scripts/titiva.py +++ b/platformio/builder/scripts/titiva.py @@ -27,13 +27,11 @@ env.Append( ] ) -CORELIBS = env.ProcessGeneral() - # # Target: Build executable and linkable firmware # -target_elf = env.BuildFirmware(["c", "gcc", "m"] + CORELIBS) +target_elf = env.BuildFirmware() # # Target: Build the .bin file diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index 130fd22f..512615b6 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -7,7 +7,7 @@ from time import sleep from SCons.Script import Exit from serial import Serial -from platformio.util import get_serialports +from platformio.util import get_logicaldisks, get_serialports def FlushSerialBuffer(env, port): @@ -52,16 +52,28 @@ def WaitForNewSerialPort(_, before): def AutodetectUploadPort(env): - if "UPLOAD_PORT" not in env: + if "UPLOAD_PORT" in env: + return + + if env.subst("$FRAMEWORK") == "mbed": + for item in get_logicaldisks(): + if not item['name'] or "mbed" != item['name'].lower(): + continue + print "Auto-detected UPLOAD_PORT: %s" % item['disk'] + env.Replace(UPLOAD_PORT=item['disk']) + break + else: for item in get_serialports(): - if "VID:PID" in item['hwid']: - print "Auto-detected UPLOAD_PORT: %s" % item['port'] - env.Replace(UPLOAD_PORT=item['port']) - break + if "VID:PID" not in item['hwid']: + continue + print "Auto-detected UPLOAD_PORT: %s" % item['port'] + env.Replace(UPLOAD_PORT=item['port']) + break if "UPLOAD_PORT" not in env: Exit("Error: Please specify `upload_port` for environment or use " - "global `--upload-port` option.\n") + "global `--upload-port` option.\n" + "For the some development platforms it can be USB flash drive\n") def exists(_): diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 37931953..e83bf8d4 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -10,7 +10,7 @@ from SCons.Script import SConscript, SConscriptChdir from SCons.Util import case_sensitive_suffixes -def ProcessGeneral(env): +def BuildFirmware(env): # fix ASM handling under non-casitive OS if not case_sensitive_suffixes('.s', '.S'): env.Replace( @@ -24,20 +24,8 @@ def ProcessGeneral(env): if "BUILD_FLAGS" in env: env.MergeFlags(env['BUILD_FLAGS']) - corelibs = [] - if "FRAMEWORK" in env: - if env['FRAMEWORK'] in ("arduino", "energia"): - env.ConvertInoToCpp() - for f in env['FRAMEWORK'].split(","): - SConscriptChdir(0) - corelibs += SConscript( - env.subst(join("$PIOBUILDER_DIR", "scripts", "frameworks", - "%s.py" % f.strip().lower())) - ) - return corelibs + env.BuildFramework() - -def BuildFirmware(env, corelibs): firmenv = env.Clone() vdirs = firmenv.VariantDirRecursive( join("$BUILD_DIR", "src"), "$PROJECTSRC_DIR") @@ -59,12 +47,15 @@ def BuildFirmware(env, corelibs): _LIBFLAGS=" -Wl,--end-group" ) - firmenv.MergeFlags(getenv("PLATFORMIO_SRCBUILD_FLAGS", "$SRCBUILD_FLAGS")) + _srcbuild_flags = getenv("PLATFORMIO_SRCBUILD_FLAGS", + env.subst("$SRCBUILD_FLAGS")) + if _srcbuild_flags: + firmenv.MergeFlags(_srcbuild_flags) return firmenv.Program( join("$BUILD_DIR", "firmware"), [firmenv.GlobCXXFiles(vdir) for vdir in vdirs], - LIBS=corelibs + deplibs, + LIBS=env.get("LIBS") + deplibs, LIBPATH="$BUILD_DIR", PROGSUFFIX=".elf" ) @@ -95,6 +86,21 @@ def VariantDirRecursive(env, variant_dir, src_dir, duplicate=True, return variants +def BuildFramework(env): + if "FRAMEWORK" not in env: + return + + if env['FRAMEWORK'].lower() in ("arduino", "energia"): + env.ConvertInoToCpp() + + for f in env['FRAMEWORK'].split(","): + SConscriptChdir(0) + SConscript( + env.subst(join("$PIOBUILDER_DIR", "scripts", "frameworks", + "%s.py" % f.strip().lower())) + ) + + def BuildLibrary(env, variant_dir, library_dir, ignore_files=None): lib = env.Clone() vdirs = lib.VariantDirRecursive( @@ -303,10 +309,10 @@ def exists(_): def generate(env): - env.AddMethod(ProcessGeneral) env.AddMethod(BuildFirmware) env.AddMethod(GlobCXXFiles) env.AddMethod(VariantDirRecursive) + env.AddMethod(BuildFramework) env.AddMethod(BuildLibrary) env.AddMethod(BuildDependentLibraries) env.AddMethod(ConvertInoToCpp) diff --git a/platformio/commands/boards.py b/platformio/commands/boards.py index 400a4ae4..1bb89f21 100644 --- a/platformio/commands/boards.py +++ b/platformio/commands/boards.py @@ -16,7 +16,7 @@ def cli(query, json_output): # pylint: disable=R0912 if json_output: return ouput_boards_json(query) - BOARDLIST_TPL = ("{type:<30} {mcu:<13} {frequency:<8} " + BOARDLIST_TPL = ("{type:<30} {mcu:<14} {frequency:<8} " " {flash:<7} {ram:<6} {name}") grpboards = {} diff --git a/platformio/platforms/freescalekinetis.py b/platformio/platforms/freescalekinetis.py new file mode 100644 index 00000000..09243ec8 --- /dev/null +++ b/platformio/platforms/freescalekinetis.py @@ -0,0 +1,23 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +from platformio.platforms.base import BasePlatform + + +class FreescalekinetisPlatform(BasePlatform): + + """ + An embedded platform for Freescale Kinetis series ARM microcontrollers + """ + + PACKAGES = { + + "toolchain-gccarmnoneeabi": { + "alias": "toolchain", + "default": True + }, + + "framework-mbed": { + "default": True + } + } diff --git a/platformio/platforms/nordicnrf51.py b/platformio/platforms/nordicnrf51.py new file mode 100644 index 00000000..17126aac --- /dev/null +++ b/platformio/platforms/nordicnrf51.py @@ -0,0 +1,23 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +from platformio.platforms.base import BasePlatform + + +class Nordicnrf51Platform(BasePlatform): + + """ + An embedded platform for Nordic nRF51 series ARM microcontrollers + """ + + PACKAGES = { + + "toolchain-gccarmnoneeabi": { + "alias": "toolchain", + "default": True + }, + + "framework-mbed": { + "default": True + } + } diff --git a/platformio/platforms/nxplpc.py b/platformio/platforms/nxplpc.py new file mode 100644 index 00000000..9c9e3152 --- /dev/null +++ b/platformio/platforms/nxplpc.py @@ -0,0 +1,23 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +from platformio.platforms.base import BasePlatform + + +class NxplpcPlatform(BasePlatform): + + """ + An embedded platform for NXP LPC series ARM microcontrollers + """ + + PACKAGES = { + + "toolchain-gccarmnoneeabi": { + "alias": "toolchain", + "default": True + }, + + "framework-mbed": { + "default": True + } + } diff --git a/platformio/platforms/stm32.py b/platformio/platforms/ststm32.py similarity index 79% rename from platformio/platforms/stm32.py rename to platformio/platforms/ststm32.py index 63607d95..bf1e99bf 100644 --- a/platformio/platforms/stm32.py +++ b/platformio/platforms/ststm32.py @@ -4,10 +4,10 @@ from platformio.platforms.base import BasePlatform -class Stm32Platform(BasePlatform): +class Ststm32Platform(BasePlatform): """ - An embedded platform for STMicroelectronics ARM microcontrollers + An embedded platform for ST STM32 ARM microcontrollers """ PACKAGES = { @@ -36,5 +36,9 @@ class Stm32Platform(BasePlatform): "framework-opencm3": { "default": True + }, + + "framework-mbed": { + "default": True } } diff --git a/platformio/util.py b/platformio/util.py index b4f0473c..9c1007b8 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -3,8 +3,10 @@ import json import os +import re import subprocess -from os.path import abspath, dirname, expanduser, isdir, isfile, join, realpath +from os.path import (abspath, basename, dirname, expanduser, isdir, isfile, + join, realpath) from platform import system, uname from threading import Thread @@ -173,7 +175,30 @@ def get_serialports(): from serial.tools.list_ports_posix import comports else: raise exception.GetSerialPortsError(os.name) - return[{"port": p, "description": d, "hwid": h} for p, d, h in comports()] + return [{"port": p, "description": d, "hwid": h} for p, d, h in comports()] + + +def get_logicaldisks(): + disks = [] + if system() == "Windows": + result = exec_command( + ["wmic", "logicaldisk", "get", "name,VolumeName"]).get("out") + disknamere = re.compile(r"^([A-Z]{1}\:)\s*(\S+)?") + for line in result.split("\n"): + match = disknamere.match(line.strip()) + if not match: + continue + disks.append({"disk": match.group(1), "name": match.group(2)}) + else: + result = exec_command(["df"]).get("out") + disknamere = re.compile(r"\d+\%\s+([a-z\d\-_/]+)$", flags=re.I) + for line in result.split("\n"): + match = disknamere.search(line.strip()) + if not match: + continue + disks.append({"disk": match.group(1), + "name": basename(match.group(1))}) + return disks def get_api_result(path, params=None, data=None): diff --git a/scripts/mbed_to_package.py b/scripts/mbed_to_package.py new file mode 100644 index 00000000..e56d0f05 --- /dev/null +++ b/scripts/mbed_to_package.py @@ -0,0 +1,64 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +from os import getcwd, mkdir, makedirs, listdir +from os.path import isfile, isdir, join +from shutil import copy2, rmtree, copytree +from sys import exit as sys_exit +from sys import path +import zipfile + + +MBED_DIR = "/home/valeros/mbed-master" +OUTPUT_DIR = "/home/valeros/mbed-framework" +CORE_DIR = join(OUTPUT_DIR, "core") +VARIANT_DIR = join(OUTPUT_DIR, "variant") + +path.append("..") +path.append(MBED_DIR) +from workspace_tools.export import gccarm +from platformio.util import exec_command + + +def _unzip_generated_file(mcu): + filename = join( + MBED_DIR, "build", "export", "MBED_A1_emblocks_%s.zip" % mcu) + variant_dir = join(VARIANT_DIR, mcu) + if isfile(filename): + print "Processing board: %s" % mcu + with zipfile.ZipFile(filename) as zfile: + mkdir(variant_dir) + file_data = zfile.read("MBED_A1/MBED_A1.eix") + with open(join(variant_dir, "%s.eix" % mcu), "w") as f: + f.write(file_data) + else: + print "Warning! Skipped board: %s" % mcu + + +def main(): + print "Starting..." + if isdir(OUTPUT_DIR): + rmtree(OUTPUT_DIR) + print "Delete previous framework dir" + makedirs(VARIANT_DIR) + # copy MBED library + mbedlib_dir = join(MBED_DIR, "libraries", "mbed") + for item in listdir(mbedlib_dir): + src = join(mbedlib_dir, item) + dst = join(CORE_DIR, item) + if isdir(src): + copytree(src, dst) + else: + copy2(src, dst) + # make .eix files + for mcu in set(gccarm.GccArm.TARGETS): + exec_command( + ["python", join(MBED_DIR, "workspace_tools", "project.py"), + "--mcu", mcu, "-i", "emblocks", "-p", "0"], cwd=getcwd() + ) + _unzip_generated_file(mcu) + print "Complete!" + + +if __name__ == "__main__": + sys_exit(main()) diff --git a/tests/commands/test_boards.py b/tests/commands/test_boards.py index 3dfd1a11..dfeef591 100644 --- a/tests/commands/test_boards.py +++ b/tests/commands/test_boards.py @@ -44,7 +44,7 @@ def test_board_options(platformio_setup, clirunner, validate_cliresult): def test_board_ldscripts(platformio_setup, clirunner, validate_cliresult): result = clirunner.invoke( install_cli, [ - "stm32", + "ststm32", "--skip-default-package", "--with-package=ldscripts" ])