From 53475fc5ac8366743dc7816d998997dd0e49e17c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 27 Mar 2015 21:53:34 +0200 Subject: [PATCH 01/38] Add links to PlatformIO Reddit --- README.rst | 1 + docs/index.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 516606ed..635c80ad 100644 --- a/README.rst +++ b/README.rst @@ -21,6 +21,7 @@ PlatformIO `Documentation `_ | `Project Examples `_ | `Blog `_ | +`Reddit `_ | `Twitter `_ *Atmel AVR & SAM, Freescale Kinetis, Nordic nRF51, NXP LPC, ST STM32, diff --git a/docs/index.rst b/docs/index.rst index 2f46d604..01279b49 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -14,6 +14,7 @@ TI MSP430 & Tiva, Teensy, Arduino, mbed, libOpenCM3, etc.* * `Source Code `_ | `Issues `_ * `Blog `_ | + `Reddit `_ | `Twitter `_ You have no need to install any *IDE* or compile any tool chains. *PlatformIO* From 450ee3234f52f1f280ea4b53a904582341041677 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 27 Mar 2015 21:54:47 +0200 Subject: [PATCH 02/38] Add "url" field to "library.json" --- docs/librarymanager/config.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index fe6e573f..5c5e873e 100644 --- a/docs/librarymanager/config.rst +++ b/docs/librarymanager/config.rst @@ -167,6 +167,16 @@ A version of the current library source code. |PIOAPICR| will use the *CVS*-revision from the latest commit. +.. _libjson_url: + +``url`` +------- + +*Optional* | Type: ``String`` | Max. Length: 255 + +Home page of library (if different from :ref:`libjson_repository` url). + + .. _libjson_include: ``include`` From 989acf54407c0b36913db9d95f1fccbb876d0d4a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 27 Mar 2015 21:55:30 +0200 Subject: [PATCH 03/38] Typo fix --- docs/librarymanager/config.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index 5c5e873e..1d0d64d2 100644 --- a/docs/librarymanager/config.rst +++ b/docs/librarymanager/config.rst @@ -174,7 +174,7 @@ A version of the current library source code. *Optional* | Type: ``String`` | Max. Length: 255 -Home page of library (if different from :ref:`libjson_repository` url). +Home page of library (if is different from :ref:`libjson_repository` url). .. _libjson_include: From 52660aeb86a6ebe65121c04f4a85a08ca3af5aa8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 29 Mar 2015 23:19:50 +0300 Subject: [PATCH 04/38] Add FAQ page --- README.rst | 6 +++-- docs/faq.rst | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 14 ++++------- 3 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 docs/faq.rst diff --git a/README.rst b/README.rst index 635c80ad..9045e308 100644 --- a/README.rst +++ b/README.rst @@ -42,11 +42,13 @@ and the missing library manager. * `User Guide `_ * `IDE Integration `_ * `Articles about us `_ +* `FAQ `_ * `Release History `_ You have **no need** to install any *IDE* or compile any tool chains. *PlatformIO* -has pre-built different development platforms including: compiler, debugger, -uploader (for embedded boards) and many other useful tools. +has pre-built different development platforms and pre-configured settings for +the most popular embedded boards. For further details, please +refer to `What is PlatformIO? `_ Use whenever. *Run everywhere.* ------------------------------- diff --git a/docs/faq.rst b/docs/faq.rst new file mode 100644 index 00000000..e92038fd --- /dev/null +++ b/docs/faq.rst @@ -0,0 +1,68 @@ +.. _faq: + +Frequently Asked Questions +========================== + +.. contents:: + +General +------- + +.. _faq_what_is_platformio: + +What is PlatformIO? +~~~~~~~~~~~~~~~~~~~ + +`PlatformIO `_ is a cross-platform code builder +and the missing library manager. + +PlatformIO is independent from the platform, in which it is running. In fact, +the only requirement is Python, which exists pretty much everywhere. What this +means is that PlatformIO projects can be easily moved from one computer to +another, as well as that PlatformIO allows for the easy sharing of projects +between team members, regardless of operating system they prefer to work with. +Beyond that, PlatformIO can be run not only on commonly used desktops/laptops +but also on the servers without X Window System. While PlatformIO itself is a +console application, it can be used in combination with one's favorite +:ref:`ide` or text editor such as :ref:`ide_arduino`, :ref:`ide_eclipse`, +:ref:`ide_visualstudio`, :ref:`ide_vim`, :ref:`ide_sublimetext`, etc. + +Alright, so PlatformIO can run on different operating systems. But more +importantly, from development perspective at least, is a list of supported +boards and MCUs. To keep things short: PlatformIO supports over 100 +:ref:`Embedded Boards ` and all major +:ref:`Development Platforms `. + +PlatformIO allows users to: + +* Decide which operation system they want to run development process on. + You can even use one OS at home and another at work. +* Choose which editor to use for writing the code. It can be pretty simple + editor or powerful favorite :ref:`ide`. +* Focus on the code development, significantly simplifying support for the + :ref:`platforms` and MCUs. + + +How does it work? +~~~~~~~~~~~~~~~~~ + +Without going too deep into PlatformIO implementation details, work cycle of +the project developed using PlatformIO is as follows: + +* Users choose board(s) interested in :ref:`projectconf` +* Based on this list of boards, PlatformIO downloads required toolchains and + installs them automatically. +* Users develop code and PlatformIO makes sure that it is compiled, prepared + and uploaded to all the boards of interest. + + +Troubleshooting +--------------- + +Serial does not work with panStampAVR board +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Answered in an +`issue #144 `_. + + diff --git a/docs/index.rst b/docs/index.rst index 01279b49..692057d7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -17,15 +17,10 @@ TI MSP430 & Tiva, Teensy, Arduino, mbed, libOpenCM3, etc.* `Reddit `_ | `Twitter `_ -You have no need to install any *IDE* or compile any tool chains. *PlatformIO* -has pre-built different development platforms including: compiler, debugger, -uploader (for embedded) and many other useful tools. - -**PlatformIO** allows developer to compile the same code with different -platforms using only one command :ref:`cmd_run`. This happens due to -:ref:`projectconf` where you can setup different environments with specific -options: platform type, firmware uploading settings, pre-built framework -and many more. +You have **no need** to install any *IDE* or compile any tool chains. *PlatformIO* +has pre-built different development platforms and pre-configured settings for +the most popular embedded boards. For further details, please +refer to :ref:`faq_what_is_platformio` Embedded Development. *Easier Than Ever.* ----------------------------------------- @@ -70,4 +65,5 @@ Contents userguide/index ide articles + FAQ history From 6b2af149dc87bcd9eec4c310e8f29ff3d8c9ef4e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 30 Mar 2015 21:30:52 +0300 Subject: [PATCH 05/38] Update link to Travis.CI --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 9045e308..ae0375df 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ PlatformIO ========== .. image:: https://travis-ci.org/platformio/platformio.svg?branch=develop - :target: https://travis-ci.org/profile/platformio + :target: https://travis-ci.org/platformio/platformio :alt: Build Status .. image:: https://gemnasium.com/ivankravets/platformio.png :target: https://gemnasium.com/ivankravets/platformio From a55f97a34e3ba487ae79107ca9d98f917e507bd9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 31 Mar 2015 15:27:04 +0300 Subject: [PATCH 06/38] Improve FAQ page and relatives --- docs/faq.rst | 37 +++++++++++++++++++++++++++++++++++-- docs/installation.rst | 36 ++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index e92038fd..445eb775 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -55,14 +55,47 @@ the project developed using PlatformIO is as follows: * Users develop code and PlatformIO makes sure that it is compiled, prepared and uploaded to all the boards of interest. +.. _faq_troubleshooting: Troubleshooting --------------- +.. _faq_troubleshooting_pioblocksprompt: + +PlatformIO blocks command execution using user propmt +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you are going to run *PlatformIO* from **subprocess**, you **MUST +DISABLE** all prompts. It will allow you to avoid blocking. +There are a few options: + +- using environment variable :ref:`PLATFORMIO_SETTING_ENABLE_PROMPTS=No ` +- disable global setting ``enable_prompts`` via :ref:`cmd_settings` command +- masking under Continuous Integration system via environment variable + :ref:`CI=true `. + + +Windows: ``UnicodeDecodeError: 'ascii' codec can't decode byte`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Answered in `issue #143 `_. + Serial does not work with panStampAVR board ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Answered in an -`issue #144 `_. +Answered in `issue #144 `_. +An error ``pkg_resources.DistributionNotFound`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Please upgrade *SetupTools* package: + +.. code-block:: bash + + $ [sudo] pip uninstall setuptools + $ [sudo] pip install setuptools + + # Then re-install PlatformIO + $ [sudo] pip uninstall platformio + $ [sudo] pip install platformio diff --git a/docs/installation.rst b/docs/installation.rst index 75e566a5..619253e7 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -30,19 +30,23 @@ application: application. .. warning:: - If you are going to run *PlatformIO* from **subprocess**, you **MUST - DISABLE** all prompts. It will allow you to avoid blocking. - There are a few options: + If you are going to run *PlatformIO* from **subprocess**, you + :ref:`MUST DISABLE ` all prompts. + It will allow you to avoid blocking. - - using environment variable :ref:`PLATFORMIO_SETTING_ENABLE_PROMPTS=No ` - - disable global setting ``enable_prompts`` via :ref:`cmd_settings` command - - masking under Continuous Integration system via environment variable - :ref:`CI=true `. -Please *choose one of* the following: +Troubleshooting +--------------- + +For further details, frequently questions, please refer to :ref:`faq`. + +Installation Methods +-------------------- + +Please *choose one of* the following installation methods: Super-Quick (Mac / Linux) -------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~ To install or upgrade *PlatformIO* paste that at a *Terminal* prompt (**you might need** to run ``sudo`` first): @@ -53,7 +57,7 @@ To install or upgrade *PlatformIO* paste that at a *Terminal* prompt Installer Script (Mac / Linux / Windows) ----------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To install or upgrade *PlatformIO*, download `get-platformio.py `_ @@ -70,16 +74,8 @@ On *Windows OS* it may look like: C:\Python27\python.exe get-platformio.py -.. warning:: - If you have an error ``pkg_resources.DistributionNotFound`` please - upgrade *SetupTools* package: ``$ [sudo] pip uninstall setuptools`` - and ``$ [sudo] pip install setuptools``. - Then re-install *PlatformIO*: ``$ [sudo] pip uninstall platformio`` - and ``$ [sudo] pip install platformio``. - - Full Guide ----------- +~~~~~~~~~~ 1. Check a ``python`` version (only 2.6-2.7 is supported): @@ -121,7 +117,7 @@ For upgrading the ``platformio`` to new version please use this command: Development Version -------------------- +~~~~~~~~~~~~~~~~~~~ .. warning:: We don't recommend to use ``develop`` version in production. From 9085399d8ec4c3525a015f130ac15fa18007c3c0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 31 Mar 2015 15:56:35 +0300 Subject: [PATCH 07/38] Correct links to the answered comments --- docs/faq.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index 445eb775..1b69f45d 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -78,12 +78,12 @@ There are a few options: Windows: ``UnicodeDecodeError: 'ascii' codec can't decode byte`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Answered in `issue #143 `_. +Answered in `issue #143 `_. Serial does not work with panStampAVR board ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Answered in `issue #144 `_. +Answered in `issue #144 `_. An error ``pkg_resources.DistributionNotFound`` From aa86cbb51f7ff893bd15bad6b0b3e6caa169a5f0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Apr 2015 13:18:36 +0300 Subject: [PATCH 08/38] Initial support for AppVeyor CI and Py27 test --- appveyor.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..351fe371 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,24 @@ +version: '{build}' +build: off +environment: + global: + # https://packaging.python.org/en/latest/appveyor.html + WITH_COMPILER: "cmd /E:ON /V:ON /C .\\ci\\appveyor-with-compiler.cmd" + matrix: + - TOXENV: "py27" + TOXPYTHON: "C:\\Python27-x64\\python.exe" + WINDOWS_SDK_VERSION: "v7.0" + PYTHON_HOME: "C:\\Python27-x64" + PYTHON_VERSION: "2.7" + PYTHON_ARCH: "64" +init: + - "ECHO %TOXENV%" + - ps: "ls C:\\Python*" +install: + # https://packaging.python.org/en/latest/appveyor.html + - "powershell ci\\appveyor-bootstrap.ps1" +test_script: + - "%PYTHON_HOME%\\Scripts\\tox --version" + - "%PYTHON_HOME%\\Scripts\\pip --version" + - "scons --version" + - "%WITH_COMPILER% %PYTHON_HOME%\\Scripts\\tox" From 8c89944adbf1432fdeef1771686a2e6dad6f07d2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Apr 2015 13:32:43 +0300 Subject: [PATCH 09/38] Add AppVeyor CI scripts/hooks --- appveyor.yml | 6 +- scripts/appveyor/install.ps1 | 86 ++++++++++++++++++++++++++ scripts/appveyor/run_with_compiler.cmd | 48 ++++++++++++++ 3 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 scripts/appveyor/install.ps1 create mode 100644 scripts/appveyor/run_with_compiler.cmd diff --git a/appveyor.yml b/appveyor.yml index 351fe371..4fbc620c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,8 +2,7 @@ version: '{build}' build: off environment: global: - # https://packaging.python.org/en/latest/appveyor.html - WITH_COMPILER: "cmd /E:ON /V:ON /C .\\ci\\appveyor-with-compiler.cmd" + WITH_COMPILER: "cmd /E:ON /V:ON /C .\\scripts\\appveyor\\run_with_compiler.cmd" matrix: - TOXENV: "py27" TOXPYTHON: "C:\\Python27-x64\\python.exe" @@ -15,8 +14,7 @@ init: - "ECHO %TOXENV%" - ps: "ls C:\\Python*" install: - # https://packaging.python.org/en/latest/appveyor.html - - "powershell ci\\appveyor-bootstrap.ps1" + - "powershell scripts\\appveyor\\install.ps1" test_script: - "%PYTHON_HOME%\\Scripts\\tox --version" - "%PYTHON_HOME%\\Scripts\\pip --version" diff --git a/scripts/appveyor/install.ps1 b/scripts/appveyor/install.ps1 new file mode 100644 index 00000000..3eafeaf9 --- /dev/null +++ b/scripts/appveyor/install.ps1 @@ -0,0 +1,86 @@ +# https://packaging.python.org/en/latest/appveyor.html +# Sample script to install Python and pip under Windows +# Authors: Olivier Grisel and Kyle Kastner +# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ + +$BASE_URL = "https://www.python.org/ftp/python/" +$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py" +$GET_PIP_PATH = "C:\get-pip.py" + + +function DownloadPython ($python_version, $platform_suffix) { + $webclient = New-Object System.Net.WebClient + $filename = "python-" + $python_version + $platform_suffix + ".msi" + $url = $BASE_URL + $python_version + "/" + $filename + + $basedir = $pwd.Path + "\" + $filepath = $basedir + $filename + if (Test-Path $filename) { + Write-Host "Reusing" $filepath + return $filepath + } + + # Download and retry up to 5 times in case of network transient errors. + Write-Host "Downloading" $filename "from" $url + $retry_attempts = 3 + for($i=0; $i -lt $retry_attempts; $i++){ + try { + $webclient.DownloadFile($url, $filepath) + break + } + Catch [Exception]{ + Start-Sleep 1 + } + } + Write-Host "File saved at" $filepath + return $filepath +} + + +function InstallPython ($python_version, $architecture, $python_home) { + Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home + if (Test-Path $python_home) { + Write-Host $python_home "already exists, skipping." + return $false + } + if ($architecture -eq "32") { + $platform_suffix = "" + } else { + $platform_suffix = ".amd64" + } + $filepath = DownloadPython $python_version $platform_suffix + Write-Host "Installing" $filepath "to" $python_home + $args = "/qn /i $filepath TARGETDIR=$python_home" + Write-Host "msiexec.exe" $args + Start-Process -FilePath "msiexec.exe" -ArgumentList $args -Wait -Passthru + Write-Host "Python $python_version ($architecture) installation complete" + return $true +} + + +function InstallPip ($python_home) { + $pip_path = $python_home + "/Scripts/pip.exe" + $python_path = $python_home + "/python.exe" + if (-not(Test-Path $pip_path)) { + Write-Host "Installing pip..." + $webclient = New-Object System.Net.WebClient + $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH) + Write-Host "Executing:" $python_path $GET_PIP_PATH + Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH" -Wait -Passthru + } else { + Write-Host "pip already installed." + } +} + +function InstallPackage ($python_home, $pkg) { + $pip_path = $python_home + "/Scripts/pip.exe" + & $pip_path install $pkg +} + +function main () { + InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON + InstallPip $env:PYTHON + InstallPackage $env:PYTHON wheel +} + +main \ No newline at end of file diff --git a/scripts/appveyor/run_with_compiler.cmd b/scripts/appveyor/run_with_compiler.cmd new file mode 100644 index 00000000..7a75d18c --- /dev/null +++ b/scripts/appveyor/run_with_compiler.cmd @@ -0,0 +1,48 @@ +:: https://packaging.python.org/en/latest/appveyor.html +:: To build extensions for 64 bit Python 3, we need to configure environment +:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of: +:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1) +:: +:: To build extensions for 64 bit Python 2, we need to configure environment +:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of: +:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0) +:: +:: 32 bit builds do not require specific environment configurations. +:: +:: Note: this script needs to be run with the /E:ON and /V:ON flags for the +:: cmd interpreter, at least for (SDK v7.0) +:: +:: More details at: +:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows +:: http://stackoverflow.com/a/13751649/163740 +:: +:: Author: Olivier Grisel +:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ +@ECHO OFF + +SET COMMAND_TO_RUN=%* +SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows + +SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%" +IF %MAJOR_PYTHON_VERSION% == "2" ( + SET WINDOWS_SDK_VERSION="v7.0" +) ELSE IF %MAJOR_PYTHON_VERSION% == "3" ( + SET WINDOWS_SDK_VERSION="v7.1" +) ELSE ( + ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%" + EXIT 1 +) + +IF "%PYTHON_ARCH%"=="64" ( + ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture + SET DISTUTILS_USE_SDK=1 + SET MSSdk=1 + "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION% + "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release + ECHO Executing: %COMMAND_TO_RUN% + call %COMMAND_TO_RUN% || EXIT 1 +) ELSE ( + ECHO Using default MSVC build environment for 32 bit architecture + ECHO Executing: %COMMAND_TO_RUN% + call %COMMAND_TO_RUN% || EXIT 1 +) \ No newline at end of file From e9a476d640ffec8730a3812cada6d5166cff32b2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Apr 2015 13:34:35 +0300 Subject: [PATCH 10/38] Update Adafruit-PCD8544 lib for example --- .../lib/Adafruit-PCD8544-Nokia-5110-LCD-library | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/atmelavr-and-arduino/arduino-external-libs/lib/Adafruit-PCD8544-Nokia-5110-LCD-library b/examples/atmelavr-and-arduino/arduino-external-libs/lib/Adafruit-PCD8544-Nokia-5110-LCD-library index 23d30dc4..065c2999 160000 --- a/examples/atmelavr-and-arduino/arduino-external-libs/lib/Adafruit-PCD8544-Nokia-5110-LCD-library +++ b/examples/atmelavr-and-arduino/arduino-external-libs/lib/Adafruit-PCD8544-Nokia-5110-LCD-library @@ -1 +1 @@ -Subproject commit 23d30dc48029a543918e5ecdff7c505558c313e3 +Subproject commit 065c29997b151429f33f0802b8efcb97ec6b7519 From b455cab6b0382b347a612332582e1d8115e8f048 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Apr 2015 13:38:42 +0300 Subject: [PATCH 11/38] Remove build version --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 4fbc620c..f33de82e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,3 @@ -version: '{build}' build: off environment: global: From 59cb537db94df8f5046bffff38a7bd0bc46f2617 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Apr 2015 13:57:57 +0300 Subject: [PATCH 12/38] Automatically install "tox" package --- scripts/appveyor/install.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/appveyor/install.ps1 b/scripts/appveyor/install.ps1 index 3eafeaf9..3fb6cf28 100644 --- a/scripts/appveyor/install.ps1 +++ b/scripts/appveyor/install.ps1 @@ -78,9 +78,10 @@ function InstallPackage ($python_home, $pkg) { } function main () { - InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON - InstallPip $env:PYTHON - InstallPackage $env:PYTHON wheel + InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON_HOME + InstallPip $env:PYTHON_HOME + InstallPackage $env:PYTHON_HOME setuptools + InstallPackage $env:PYTHON_HOME tox } main \ No newline at end of file From 3dd0ceb8e056704aa747f9023ca4926a8669acfa Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Apr 2015 14:05:02 +0300 Subject: [PATCH 13/38] Remove "scons" version, because it isn't installed by default --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index f33de82e..fcb16184 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,5 +17,4 @@ install: test_script: - "%PYTHON_HOME%\\Scripts\\tox --version" - "%PYTHON_HOME%\\Scripts\\pip --version" - - "scons --version" - "%WITH_COMPILER% %PYTHON_HOME%\\Scripts\\tox" From 432ca80c599f8449aa9b0d1c225a478401003db7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Apr 2015 15:58:26 +0300 Subject: [PATCH 14/38] Fetch project submodules --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index fcb16184..a213b1f2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,6 +13,7 @@ init: - "ECHO %TOXENV%" - ps: "ls C:\\Python*" install: + - "git submodule update --init --recursive" - "powershell scripts\\appveyor\\install.ps1" test_script: - "%PYTHON_HOME%\\Scripts\\tox --version" From d558480d11d976758bb47538e9c66af512bfe7f3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Apr 2015 16:33:51 +0300 Subject: [PATCH 15/38] Integrate PlatformIO with AppVeyor Windows based Continuous Integration system // Resolve #149 --- README.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index ae0375df..ac5ade89 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,10 @@ PlatformIO .. image:: https://travis-ci.org/platformio/platformio.svg?branch=develop :target: https://travis-ci.org/platformio/platformio - :alt: Build Status + :alt: Travis.CI Build Status +.. image:: https://ci.appveyor.com/api/projects/status/ee26e58de798rctd/branch/develop?svg=true + :target: https://ci.appveyor.com/project/ivankravets/platformio + :alt: AppVeyor.CI Build Status .. image:: https://gemnasium.com/ivankravets/platformio.png :target: https://gemnasium.com/ivankravets/platformio :alt: Dependency Status From f072a10e9ab991a51a50c39b5bb547322ddcf1c4 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Thu, 2 Apr 2015 20:15:34 +0300 Subject: [PATCH 16/38] Add new Arduino based boards --- platformio/boards/misc.json | 267 ++++++++++++++++++++++++++++++++ platformio/boards/sparkfun.json | 43 +++++ 2 files changed, 310 insertions(+) diff --git a/platformio/boards/misc.json b/platformio/boards/misc.json index 495fa4ef..14d71cfa 100644 --- a/platformio/boards/misc.json +++ b/platformio/boards/misc.json @@ -226,5 +226,272 @@ }, "url": "https://code.google.com/p/sanguino/", "vendor": "Sanguino" + }, + + "tinyduino": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_LILYPAD", + "f_cpu": "8000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "frameworks": ["arduino"], + "name": "TinyCircuits TinyDuino Processor Board", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 57600 + }, + "url": "https://tiny-circuits.com/tinyduino-processor-board.html", + "vendor": "TinyCircuits" + }, + + "wildfirev3": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "16000000L", + "mcu": "atmega1284p", + "variant": "wildfirev3" + }, + "frameworks": ["arduino"], + "name": "WickedDevice WildFire v3 [optiboot]", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 130048, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 115200 + }, + "url": "http://shop.wickeddevice.com/resources/wildfire/", + "vendor": "WickedDevice" + }, + + "wildfirev2": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "16000000L", + "mcu": "atmega1284p", + "variant": "wildfirev2" + }, + "frameworks": ["arduino"], + "name": "WickedDevice WildFire v2 [stk500]", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 122878, + "protocol": "wiring", + "require_upload_port" : true, + "speed": 38400 + }, + "url": "http://shop.wickeddevice.com/resources/wildfire/#arduinoidesetup", + "vendor": "WickedDevice" + }, + + "blend": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "16000000L", + "mcu": "atmega32u4", + "pid": "0x8036", + "usb_product": "RedBearLab Blend", + "variant": "leonardo", + "vid": "0x2341" + }, + "frameworks": ["arduino"], + "name": "RedBearLab Blend", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "require_upload_port" : true, + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + }, + "url": "http://redbearlab.com/blend/", + "vendor": "RedBearLab" + }, + + "blendmicro8": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "8000000L", + "mcu": "atmega32u4", + "pid": "0x2404", + "usb_product": "RedBearLab Blend", + "variant": "micro", + "vid": "0x03EB" + }, + "frameworks": ["arduino"], + "name": "RedBearLab Blend Micro 3.3V/8MHz", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "require_upload_port" : true, + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + }, + "url": "http://redbearlab.com/blendmicro/", + "vendor": "RedBearLab" + }, + + "blendmicro16": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "16000000L", + "mcu": "atmega32u4", + "pid": "0x2404", + "usb_product": "RedBearLab Blend", + "variant": "micro", + "vid": "0x03EB" + }, + "frameworks": ["arduino"], + "name": "RedBearLab Blend Micro 3.3V/16MHz (overclock)", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "require_upload_port" : true, + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + }, + "url": "http://redbearlab.com/blendmicro/", + "vendor": "RedBearLab" + }, + + "tinylily": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_LILYPAD", + "f_cpu": "8000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "frameworks": ["arduino"], + "name": "TinyCircuits TinyLily Mini Processor", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 57600 + }, + "url": "https://tiny-circuits.com/tiny-lily-mini-processor.html", + "vendor": "TinyCircuits" + }, + + "lightup": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_LEONARDO", + "f_cpu": "8000000L", + "mcu": "atmega32u4", + "pid": "0x6096", + "usb_product": "LightUp", + "variant": "leonardo", + "vid": "0x1d50" + }, + "frameworks": ["arduino"], + "name": "LightUp", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "require_upload_port" : true, + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + }, + "url": "https://www.lightup.io/", + "vendor": "LightUp" + }, + + "moteino": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_MOTEINO", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "frameworks": ["arduino"], + "name": "LowPowerLab Moteino", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 31744, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 115200 + }, + "url": "https://lowpowerlab.com/shop/moteino-r4", + "vendor": "LowPowerLab" + }, + + "moteinomega": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_MOTEINOMEGA", + "f_cpu": "16000000L", + "mcu": "atmega1284p", + "variant": "moteinoMega" + }, + "frameworks": ["arduino"], + "name": "LowPowerLab MoteinoMEGA", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 16384, + "maximum_size": 130048, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 115200 + }, + "url": "http://lowpowerlab.com/blog/2014/08/09/moteinomega-available-now/", + "vendor": "LowPowerLab" + }, + + "zumbt328": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_BT", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "frameworks": ["arduino"], + "name": "BQ ZUM BT-328 board", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2048, + "maximum_size": 28672, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 19200 + }, + "url": "http://www.bq.com/gb/products/zum.html", + "vendor": "BQ" } } diff --git a/platformio/boards/sparkfun.json b/platformio/boards/sparkfun.json index 88240040..79285509 100644 --- a/platformio/boards/sparkfun.json +++ b/platformio/boards/sparkfun.json @@ -187,5 +187,48 @@ }, "url": "https://www.sparkfun.com/products/10743", "vendor": "SparkFun" + }, + "sparkfun_digitalsandbox": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "frameworks": ["arduino"], + "name": "SparkFun Digital Sandbox", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32256, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 115200 + }, + "url": "https://www.sparkfun.com/products/12651", + "vendor": "SparkFun" + }, + + "uview": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "frameworks": ["arduino"], + "name": "SparkFun MicroView", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32256, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 115200 + }, + "url": "https://www.sparkfun.com/products/12923", + "vendor": "SparkFun" } } \ No newline at end of file From 6594601932f3dabf36c02cd57ac583656c3c45f9 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Thu, 2 Apr 2015 20:24:22 +0300 Subject: [PATCH 17/38] Initial support for ESP8266 // Issue #119 --- examples/espressif/esp8266-native/README.rst | 21 ++ .../espressif/esp8266-native/platformio.ini | 22 ++ .../espressif/esp8266-native/src/at_upgrade.c | 288 ++++++++++++++++++ .../esp8266-native/src/user_config.h | 6 + .../espressif/esp8266-native/src/user_main.c | 113 +++++++ .../espressif/esp8266-webserver/README.rst | 21 ++ .../esp8266-webserver/platformio.ini | 23 ++ .../esp8266-webserver/src/HelloServer.ino | 54 ++++ .../espressif/esp8266-wifiscan/README.rst | 21 ++ .../espressif/esp8266-wifiscan/platformio.ini | 23 ++ .../esp8266-wifiscan/src/WiFiScan.ino | 48 +++ platformio/boards/espressif.json | 25 ++ platformio/builder/scripts/espressif.py | 161 ++++++++++ .../builder/scripts/frameworks/arduino.py | 14 + platformio/platforms/base.py | 14 + platformio/platforms/espressif.py | 39 +++ 16 files changed, 893 insertions(+) create mode 100644 examples/espressif/esp8266-native/README.rst create mode 100644 examples/espressif/esp8266-native/platformio.ini create mode 100644 examples/espressif/esp8266-native/src/at_upgrade.c create mode 100644 examples/espressif/esp8266-native/src/user_config.h create mode 100644 examples/espressif/esp8266-native/src/user_main.c create mode 100644 examples/espressif/esp8266-webserver/README.rst create mode 100644 examples/espressif/esp8266-webserver/platformio.ini create mode 100644 examples/espressif/esp8266-webserver/src/HelloServer.ino create mode 100644 examples/espressif/esp8266-wifiscan/README.rst create mode 100644 examples/espressif/esp8266-wifiscan/platformio.ini create mode 100644 examples/espressif/esp8266-wifiscan/src/WiFiScan.ino create mode 100644 platformio/boards/espressif.json create mode 100644 platformio/builder/scripts/espressif.py create mode 100644 platformio/platforms/espressif.py diff --git a/examples/espressif/esp8266-native/README.rst b/examples/espressif/esp8266-native/README.rst new file mode 100644 index 00000000..ab31e6cf --- /dev/null +++ b/examples/espressif/esp8266-native/README.rst @@ -0,0 +1,21 @@ +How to build 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/espressif/esp8266-native/ + + # Process example project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/espressif/esp8266-native/platformio.ini b/examples/espressif/esp8266-native/platformio.ini new file mode 100644 index 00000000..304bd86f --- /dev/null +++ b/examples/espressif/esp8266-native/platformio.ini @@ -0,0 +1,22 @@ +# +# 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 + +[env:esp01_8266] +platform = espressif +board = esp01 diff --git a/examples/espressif/esp8266-native/src/at_upgrade.c b/examples/espressif/esp8266-native/src/at_upgrade.c new file mode 100644 index 00000000..59ecdea2 --- /dev/null +++ b/examples/espressif/esp8266-native/src/at_upgrade.c @@ -0,0 +1,288 @@ +/****************************************************************************** + * Copyright 2015-2018 Espressif Systems (Wuxi) + * + * FileName: user_main.c + * + * Description: entry file of user application + * + * Modification history: + * 2015/3/06, v1.0 create this file. +*******************************************************************************/ +#include "c_types.h" +#include "user_interface.h" +#include "espconn.h" +#include "mem.h" +#include "osapi.h" +#include "upgrade.h" + +#ifdef AT_CUSTOM_UPGRADE + +#define UPGRADE_FRAME "{\"path\": \"/v1/messages/\", \"method\": \"POST\", \"meta\": {\"Authorization\": \"token %s\"},\ +\"get\":{\"action\":\"%s\"},\"body\":{\"pre_rom_version\":\"%s\",\"rom_version\":\"%s\"}}\n" + +#define pheadbuffer "Connection: keep-alive\r\n\ +Cache-Control: no-cache\r\n\ +User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 \r\n\ +Accept: */*\r\n\ +Accept-Encoding: gzip,deflate\r\n\ +Accept-Language: zh-CN,eb-US;q=0.8\r\n\r\n" + +/**/ + + +struct espconn *pespconn = NULL; +struct upgrade_server_info *upServer = NULL; + +static os_timer_t at_delay_check; +static struct espconn *pTcpServer = NULL; +static ip_addr_t host_ip; +/****************************************************************************** + * FunctionName : user_esp_platform_upgrade_cb + * Description : Processing the downloaded data from the server + * Parameters : pespconn -- the espconn used to connetion with the host + * Returns : none +*******************************************************************************/ +LOCAL void ICACHE_FLASH_ATTR +at_upDate_rsp(void *arg) +{ + struct upgrade_server_info *server = arg; + + + if(server->upgrade_flag == true) + { + os_printf("device_upgrade_success\r\n"); + at_response_ok(); + system_upgrade_reboot(); + } + else + { + os_printf("device_upgrade_failed\r\n"); + at_response_error(); + } + + os_free(server->url); + server->url = NULL; + os_free(server); + server = NULL; +} +/** + * @brief Tcp client disconnect success callback function. + * @param arg: contain the ip link information + * @retval None + */ +static void ICACHE_FLASH_ATTR +at_upDate_discon_cb(void *arg) +{ + struct espconn *pespconn = (struct espconn *)arg; + uint8_t idTemp = 0; + + if(pespconn->proto.tcp != NULL) + { + os_free(pespconn->proto.tcp); + } + if(pespconn != NULL) + { + os_free(pespconn); + } + + os_printf("disconnect\r\n"); + + if(system_upgrade_start(upServer) == false) + { + at_response_error(); + } + else + { + at_port_print("+CIPUPDATE:4\r\n"); + } +} + +/** + * @brief Udp server receive data callback function. + * @param arg: contain the ip link information + * @retval None + */ +LOCAL void ICACHE_FLASH_ATTR +at_upDate_recv(void *arg, char *pusrdata, unsigned short len) +{ + struct espconn *pespconn = (struct espconn *)arg; + char temp[32] = {0}; + uint8_t user_bin[12] = {0}; + uint8_t i = 0; + + os_timer_disarm(&at_delay_check); + at_port_print("+CIPUPDATE:3\r\n"); + + upServer = (struct upgrade_server_info *)os_zalloc(sizeof(struct upgrade_server_info)); + + upServer->upgrade_version[5] = '\0'; + + upServer->pespconn = pespconn; + + os_memcpy(upServer->ip, pespconn->proto.tcp->remote_ip, 4); + + upServer->port = 80; + + upServer->check_cb = at_upDate_rsp; + upServer->check_times = 60000; + + if(upServer->url == NULL) + { + upServer->url = (uint8 *) os_zalloc(1024); + } + + if(system_upgrade_userbin_check() == UPGRADE_FW_BIN1) + { + os_memcpy(user_bin, "user2.bin", 10); + } + else if(system_upgrade_userbin_check() == UPGRADE_FW_BIN2) + { + os_memcpy(user_bin, "user1.bin", 10); + } + + os_sprintf(upServer->url, + "GET /%s HTTP/1.1\r\nHost: "IPSTR"\r\n"pheadbuffer"", + user_bin, IP2STR(upServer->ip)); +} + +LOCAL void ICACHE_FLASH_ATTR +at_upDate_wait(void *arg) +{ + struct espconn *pespconn = arg; + os_timer_disarm(&at_delay_check); + if(pespconn != NULL) + { + espconn_disconnect(pespconn); + } + else + { + at_response_error(); + } +} + +/****************************************************************************** + * FunctionName : user_esp_platform_sent_cb + * Description : Data has been sent successfully and acknowledged by the remote host. + * Parameters : arg -- Additional argument to pass to the callback function + * Returns : none +*******************************************************************************/ +LOCAL void ICACHE_FLASH_ATTR +at_upDate_sent_cb(void *arg) +{ + struct espconn *pespconn = arg; + os_timer_disarm(&at_delay_check); + os_timer_setfn(&at_delay_check, (os_timer_func_t *)at_upDate_wait, pespconn); + os_timer_arm(&at_delay_check, 5000, 0); + os_printf("at_upDate_sent_cb\r\n"); +} + +/** + * @brief Tcp client connect success callback function. + * @param arg: contain the ip link information + * @retval None + */ +static void ICACHE_FLASH_ATTR +at_upDate_connect_cb(void *arg) +{ + struct espconn *pespconn = (struct espconn *)arg; + uint8_t user_bin[9] = {0}; + char *temp = NULL; + + at_port_print("+CIPUPDATE:2\r\n"); + + + espconn_regist_disconcb(pespconn, at_upDate_discon_cb); + espconn_regist_recvcb(pespconn, at_upDate_recv);//////// + espconn_regist_sentcb(pespconn, at_upDate_sent_cb); + + temp = (uint8 *) os_zalloc(512); + + os_sprintf(temp,"GET /v1/device/rom/?is_format_simple=true HTTP/1.0\r\nHost: "IPSTR"\r\n"pheadbuffer"", + IP2STR(pespconn->proto.tcp->remote_ip)); + + espconn_sent(pespconn, temp, os_strlen(temp)); + os_free(temp); +} + +/** + * @brief Tcp client connect repeat callback function. + * @param arg: contain the ip link information + * @retval None + */ +static void ICACHE_FLASH_ATTR +at_upDate_recon_cb(void *arg, sint8 errType) +{ + struct espconn *pespconn = (struct espconn *)arg; + + at_response_error(); + if(pespconn->proto.tcp != NULL) + { + os_free(pespconn->proto.tcp); + } + os_free(pespconn); + os_printf("disconnect\r\n"); + + if(upServer != NULL) + { + os_free(upServer); + upServer = NULL; + } + at_response_error(); + +} + +/****************************************************************************** + * FunctionName : upServer_dns_found + * Description : dns found callback + * Parameters : name -- pointer to the name that was looked up. + * ipaddr -- pointer to an ip_addr_t containing the IP address of + * the hostname, or NULL if the name could not be found (or on any + * other error). + * callback_arg -- a user-specified callback argument passed to + * dns_gethostbyname + * Returns : none +*******************************************************************************/ +LOCAL void ICACHE_FLASH_ATTR +upServer_dns_found(const char *name, ip_addr_t *ipaddr, void *arg) +{ + struct espconn *pespconn = (struct espconn *) arg; +// char temp[32]; + + if(ipaddr == NULL) + { + at_response_error(); + return; + } + at_port_print("+CIPUPDATE:1\r\n"); + + + if(host_ip.addr == 0 && ipaddr->addr != 0) + { + if(pespconn->type == ESPCONN_TCP) + { + os_memcpy(pespconn->proto.tcp->remote_ip, &ipaddr->addr, 4); + espconn_regist_connectcb(pespconn, at_upDate_connect_cb); + espconn_regist_reconcb(pespconn, at_upDate_recon_cb); + espconn_connect(pespconn); + } + } +} + +void ICACHE_FLASH_ATTR +at_exeCmdCiupdate(uint8_t id) +{ + pespconn = (struct espconn *)os_zalloc(sizeof(struct espconn)); + pespconn->type = ESPCONN_TCP; + pespconn->state = ESPCONN_NONE; + pespconn->proto.tcp = (esp_tcp *)os_zalloc(sizeof(esp_tcp)); + pespconn->proto.tcp->local_port = espconn_port(); + pespconn->proto.tcp->remote_port = 80; + + host_ip.addr = ipaddr_addr("192.168.10.9"); + at_port_print("+CIPUPDATE:1\r\n"); + os_memcpy(pespconn->proto.tcp->remote_ip, &host_ip.addr, 4); + espconn_regist_connectcb(pespconn, at_upDate_connect_cb); + espconn_regist_reconcb(pespconn, at_upDate_recon_cb); + espconn_connect(pespconn); +} +#endif diff --git a/examples/espressif/esp8266-native/src/user_config.h b/examples/espressif/esp8266-native/src/user_config.h new file mode 100644 index 00000000..4a573ebe --- /dev/null +++ b/examples/espressif/esp8266-native/src/user_config.h @@ -0,0 +1,6 @@ +#ifndef __USER_CONFIG_H__ +#define __USER_CONFIG_H__ + +#define AT_CUSTOM_UPGRADE + +#endif diff --git a/examples/espressif/esp8266-native/src/user_main.c b/examples/espressif/esp8266-native/src/user_main.c new file mode 100644 index 00000000..953bf00e --- /dev/null +++ b/examples/espressif/esp8266-native/src/user_main.c @@ -0,0 +1,113 @@ +/****************************************************************************** + * Copyright 2013-2014 Espressif Systems (Wuxi) + * + * FileName: user_main.c + * + * Description: entry file of user application + * + * Modification history: + * 2015/1/23, v1.0 create this file. +*******************************************************************************/ + +#include "osapi.h" +#include "at_custom.h" +#include "user_interface.h" + +// test :AT+TEST=1,"abc"<,3> +void ICACHE_FLASH_ATTR +at_setupCmdTest(uint8_t id, char *pPara) +{ + int result = 0, err = 0, flag = 0; + uint8 buffer[32] = {0}; + pPara++; // skip '=' + + //get the first parameter + // digit + flag = at_get_next_int_dec(&pPara, &result, &err); + + // flag must be ture because there are more parameter + if (flag == FALSE) { + at_response_error(); + return; + } + + if (*pPara++ != ',') { // skip ',' + at_response_error(); + return; + } + + os_sprintf(buffer, "the first parameter:%d\r\n", result); + at_port_print(buffer); + + //get the second parameter + // string + at_data_str_copy(buffer, &pPara, 10); + at_port_print("the second parameter:"); + at_port_print(buffer); + at_port_print("\r\n"); + + if (*pPara == ',') { + pPara++; // skip ',' + result = 0; + //there is the third parameter + // digit + flag = at_get_next_int_dec(&pPara, &result, &err); + // we donot care of flag + os_sprintf(buffer, "the third parameter:%d\r\n", result); + at_port_print(buffer); + } + + if (*pPara != '\r') { + at_response_error(); + return; + } + + at_response_ok(); +} + +void ICACHE_FLASH_ATTR +at_testCmdTest(uint8_t id) +{ + uint8 buffer[32] = {0}; + + os_sprintf(buffer, "%s\r\n", "at_testCmdTest"); + at_port_print(buffer); + at_response_ok(); +} + +void ICACHE_FLASH_ATTR +at_queryCmdTest(uint8_t id) +{ + uint8 buffer[32] = {0}; + + os_sprintf(buffer, "%s\r\n", "at_queryCmdTest"); + at_port_print(buffer); + at_response_ok(); +} + +void ICACHE_FLASH_ATTR +at_exeCmdTest(uint8_t id) +{ + uint8 buffer[32] = {0}; + + os_sprintf(buffer, "%s\r\n", "at_exeCmdTest"); + at_port_print(buffer); + at_response_ok(); +} + +extern void at_exeCmdCiupdate(uint8_t id); +at_funcationType at_custom_cmd[] = { + {"+TEST", 5, at_testCmdTest, at_queryCmdTest, at_setupCmdTest, at_exeCmdTest}, + {"+CIUPDATE", 9, NULL, NULL, NULL, at_exeCmdCiupdate} +}; + +void user_init(void) +{ + char buf[64] = {0}; + at_customLinkMax = 5; + at_init(); + os_sprintf(buf,"compile time:%s %s",__DATE__,__TIME__); + at_set_custom_info(buf); + at_port_print("\r\nready\r\n"); + at_cmd_array_regist(&at_custom_cmd[0], sizeof(at_custom_cmd)/sizeof(at_custom_cmd[0])); +} diff --git a/examples/espressif/esp8266-webserver/README.rst b/examples/espressif/esp8266-webserver/README.rst new file mode 100644 index 00000000..cf185df7 --- /dev/null +++ b/examples/espressif/esp8266-webserver/README.rst @@ -0,0 +1,21 @@ +How to build 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/espressif/esp8266-webserver + + # Process example project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/espressif/esp8266-webserver/platformio.ini b/examples/espressif/esp8266-webserver/platformio.ini new file mode 100644 index 00000000..e79ce81c --- /dev/null +++ b/examples/espressif/esp8266-webserver/platformio.ini @@ -0,0 +1,23 @@ +# +# 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 + +[env:esp01_8266] +platform = espressif +framework = arduino +board = esp01 diff --git a/examples/espressif/esp8266-webserver/src/HelloServer.ino b/examples/espressif/esp8266-webserver/src/HelloServer.ino new file mode 100644 index 00000000..55cdf043 --- /dev/null +++ b/examples/espressif/esp8266-webserver/src/HelloServer.ino @@ -0,0 +1,54 @@ +#include +#include +#include + +const char* ssid = "*****"; +const char* password = "*****"; + + +ESP8266WebServer server(80); + +const int led = 13; + +void handle_root() { + digitalWrite(led, 1); + server.send(200, "text/plain", "hello from esp8266!"); + delay(100); + digitalWrite(led, 0); +} + +void setup(void) +{ + Serial.begin(115200); + pinMode(led, OUTPUT); + digitalWrite(led, 0); + + // Connect to WiFi network + WiFi.begin(ssid, password); + Serial.println(""); + + // Wait for connection + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + Serial.println(""); + Serial.print("Connected to "); + Serial.println(ssid); + Serial.print("IP address: "); + Serial.println(WiFi.localIP()); + + server.on("/", handle_root); + + server.on("/inline", [](){ + server.send(200, "text/plain", "this works as well"); + }); + + server.begin(); + Serial.println("HTTP server started"); +} + +void loop(void) +{ + server.handleClient(); +} diff --git a/examples/espressif/esp8266-wifiscan/README.rst b/examples/espressif/esp8266-wifiscan/README.rst new file mode 100644 index 00000000..44f46cf9 --- /dev/null +++ b/examples/espressif/esp8266-wifiscan/README.rst @@ -0,0 +1,21 @@ +How to build 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/espressif/esp8266-wifiscan + + # Process example project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/espressif/esp8266-wifiscan/platformio.ini b/examples/espressif/esp8266-wifiscan/platformio.ini new file mode 100644 index 00000000..e79ce81c --- /dev/null +++ b/examples/espressif/esp8266-wifiscan/platformio.ini @@ -0,0 +1,23 @@ +# +# 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 + +[env:esp01_8266] +platform = espressif +framework = arduino +board = esp01 diff --git a/examples/espressif/esp8266-wifiscan/src/WiFiScan.ino b/examples/espressif/esp8266-wifiscan/src/WiFiScan.ino new file mode 100644 index 00000000..3e6ff736 --- /dev/null +++ b/examples/espressif/esp8266-wifiscan/src/WiFiScan.ino @@ -0,0 +1,48 @@ +/* + * This sketch demonstrates how to scan WiFi networks. + * The API is almost the same as with the WiFi Shield library, + * the most obvious difference being the different file you need to include: + */ +#include "ESP8266WiFi.h" + +void setup() { + Serial.begin(115200); + + // Set WiFi to station mode and disconnect from an AP if it was previously connected + WiFi.mode(WIFI_STA); + WiFi.disconnect(); + delay(100); + + Serial.println("Setup done"); +} + +void loop() { + Serial.println("scan start"); + + // WiFi.scanNetworks will return the number of networks found + int n = WiFi.scanNetworks(); + Serial.println("scan done"); + if (n == 0) + Serial.println("no networks found"); + else + { + Serial.print(n); + Serial.println(" networks found"); + for (int i = 0; i < n; ++i) + { + // Print SSID and RSSI for each network found + Serial.print(i + 1); + Serial.print(": "); + Serial.print(WiFi.SSID(i)); + Serial.print(" ("); + Serial.print(WiFi.RSSI(i)); + Serial.print(")"); + Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*"); + delay(10); + } + } + Serial.println(""); + + // Wait a bit before scanning again + delay(5000); +} diff --git a/platformio/boards/espressif.json b/platformio/boards/espressif.json new file mode 100644 index 00000000..2fa1d39c --- /dev/null +++ b/platformio/boards/espressif.json @@ -0,0 +1,25 @@ +{ + "esp01": { + "build": { + "core": "esp8266", + "extra_flags": "-DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266", + "f_cpu": "80000000L", + "ldscript": "esp8266.ld", + "mcu": "esp8266", + "variant": "esp01" + }, + "frameworks": ["arduino"], + "name": "Espressif ESP8266 board", + "platform": "espressif", + "upload": { + "maximum_ram_size": 32768, + "maximum_size": 524288, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 115200, + "wait_for_upload_port": true + }, + "url": "https://nurdspace.nl/ESP8266", + "vendor": "Espressif" + } +} \ No newline at end of file diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py new file mode 100644 index 00000000..7a654832 --- /dev/null +++ b/platformio/builder/scripts/espressif.py @@ -0,0 +1,161 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +""" + Builder for Espressif MCUs +""" + +from os.path import join + +from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, + DefaultEnvironment) + + +def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 + env.AutodetectUploadPort() + + +env = DefaultEnvironment() + +env.Replace( + AR="xtensa-lx106-elf-ar", + AS="xtensa-lx106-elf-as", + CC="xtensa-lx106-elf-gcc", + CXX="xtensa-lx106-elf-g++", + OBJCOPY="xtensa-lx106-elf-objcopy", + RANLIB="xtensa-lx106-elf-ranlib", + SIZETOOL="xtensa-lx106-elf-size", + + ARFLAGS=["rcs"], + + ASPPFLAGS=["-x", "assembler-with-cpp"], + + CFLAGS=[ + "-std=c99", + "-Wpointer-arith", + "-Wno-implicit-function-declaration", + "-Wl,-EL", + "-nostdlib" + ], + + CPPFLAGS=[ + "-Os", # optimize for size + "-mlongcalls", + "-mtext-section-literals", + "-MMD" # output dependancy info + ], + + CXXFLAGS=[ + "-fno-rtti", + "-fno-exceptions", + "-std=c++11" + ], + + CPPDEFINES=[ + "F_CPU=$BOARD_F_CPU", + "__ets__", + "ICACHE_FLASH" + ], + + LINKFLAGS=[ + "-nostdlib", + "-Wl,--no-check-section", + "-u", "call_user_start", + "-Wl,-static" + ], + + LIBS=["c", "gcc"], + + SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', + + UPLOADER=join("$PIOPACKAGES_DIR", "tool-esptool", "esptool"), + UPLOADERFLAGS=[ + "-vv", + "-cd", "none", + "-cb", "$UPLOAD_SPEED", + "-cp", "$UPLOAD_PORT", + "-ca", "0x00000", + "-cf", "${SOURCES[0]}", + "-ca", "0x40000", + "-cf", "${SOURCES[1]}" + ], + UPLOADCMD='$UPLOADER $UPLOADERFLAGS' +) + +env.Append( + BUILDERS=dict( + ElfToBin=Builder( + action=" ".join([ + "$UPLOADER", + "-eo", "$SOURCES", + "-bo", "${TARGETS[0]}", + "-bs", ".text", + "-bs", ".data", + "-bs", ".rodata", + "-bc", "-ec", + "-eo", "$SOURCES", + "-es", ".irom0.text", "${TARGETS[1]}", + "-ec", "-v" + ]), + suffix=".bin" + ) + ) +) + +# +# Configure SDK +# + +if "FRAMEWORK" not in env: + env.Append( + CPPPATH=[ + join("$PIOPACKAGES_DIR", "sdk-esp8266", "include"), + "$PROJECTSRC_DIR" + ], + LIBPATH=[join("$PIOPACKAGES_DIR", "sdk-esp8266", "lib")], + LIBS=["at", "json", "lwip", "main", "net80211", "phy", "pp", + "smartconfig", "ssl", "upgrade", "wpa"] + ) + env.Replace( + LDSCRIPT_PATH=join( + "$PIOPACKAGES_DIR", "sdk-esp8266", "ld", "eagle.app.v6.ld") + ) + + +# +# Target: Build executable and linkable firmware +# + +target_elf = env.BuildFirmware() + +# +# Target: Build the .hex +# + +if "uploadlazy" in COMMAND_LINE_TARGETS: + target_firm = join("$BUILD_DIR", "firmware.bin") +else: + target_firm = env.ElfToBin( + [join("$BUILD_DIR", "firmware_00000"), + join("$BUILD_DIR", "firmware_40000")], target_elf) + +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") +AlwaysBuild(target_size) + +# +# Target: Upload firmware +# + +upload = env.Alias(["upload", "uploadlazy"], target_firm, + [BeforeUpload, "$UPLOADCMD"]) +AlwaysBuild(upload) + +# +# Target: Define targets +# + +Default([target_firm, target_size]) diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index 1fa6d456..5c4846bb 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -42,6 +42,14 @@ elif env.get("PLATFORM") == "timsp430": "$PIOPACKAGES_DIR", "framework-arduinomsp430" ) +elif env.get("PLATFORM") == "espressif": + PLATFORMFW_DIR = join( + "$PIOPACKAGES_DIR", + "framework-arduinoespressif" + ) + env.Append( + CPPPATH=[join("$PLATFORMFW_DIR", "sdk", "include")] + ) env.Replace(PLATFORMFW_DIR=PLATFORMFW_DIR) @@ -210,4 +218,10 @@ if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam": ) libs.append("sam_sam3x8e_gcc_rel") +elif env.get("PLATFORM") == "espressif": + env.Append( + LIBPATH=[join("$PLATFORMFW_DIR", "sdk", "lib")] + ) + libs.extend(["hal", "phy", "net80211", "lwip", "wpa", "main", "pp"]) + env.Append(LIBS=libs) diff --git a/platformio/platforms/base.py b/platformio/platforms/base.py index 72f7c77d..42398753 100644 --- a/platformio/platforms/base.py +++ b/platformio/platforms/base.py @@ -30,6 +30,10 @@ PLATFORM_PACKAGES = { ("Arduino Wiring-based Framework (MSP430 Core)", "http://arduino.cc/en/Reference/HomePage") ], + "framework-arduinoespressif": [ + ("Arduino Wiring-based Framework (ESP8266 Core)", + "https://github.com/esp8266/Arduino") + ], "framework-energiamsp430": [ ("Energia Wiring-based Framework (MSP430 Core)", "http://energia.nu/reference/") @@ -55,6 +59,9 @@ PLATFORM_PACKAGES = { "framework-mbed": [ ("mbed Framework", "http://mbed.org") ], + "sdk-esp8266": [ + ("ESP8266 SDK", "http://bbs.espressif.com") + ], "ldscripts": [ ("Linker Scripts", "https://sourceware.org/binutils/docs/ld/Scripts.html") @@ -69,6 +76,10 @@ PLATFORM_PACKAGES = { ("gcc-arm-embedded", "https://launchpad.net/gcc-arm-embedded"), ("GDB", "http://www.gnu.org/software/gdb/") ], + "toolchain-xtensa": [ + ("xtensa-gcc", "https://github.com/jcmvbkbc/gcc-xtensa"), + ("GDB", "http://www.gnu.org/software/gdb/") + ], "toolchain-timsp430": [ ("msp-gcc", "http://sourceforge.net/projects/mspgcc/"), ("GDB", "http://www.gnu.org/software/gdb/") @@ -93,6 +104,9 @@ PLATFORM_PACKAGES = { ], "tool-mspdebug": [ ("MSPDebug", "http://mspdebug.sourceforge.net/") + ], + "tool-esptool": [ + ("esptool-ck", "https://github.com/igrr/esptool-ck") ] } diff --git a/platformio/platforms/espressif.py b/platformio/platforms/espressif.py new file mode 100644 index 00000000..5752d44d --- /dev/null +++ b/platformio/platforms/espressif.py @@ -0,0 +1,39 @@ +# Copyright (C) Ivan Kravets +# See LICENSE for details. + +from platformio.platforms.base import BasePlatform + + +class EspressifPlatform(BasePlatform): + + """ + Espressif Systems is a privately held fabless semiconductor company. + They provide wireless communications and Wi-Fi chips which are widely + used in mobile devices and the Internet of Things applications. + + https://espressif.com/ + """ + + PACKAGES = { + + "toolchain-xtensa": { + "alias": "toolchain", + "default": True + }, + + "tool-esptool": { + "alias": "uploader", + "default": True + }, + + "sdk-esp8266": { + "default": True + }, + + "framework-arduinoespressif": { + "default": True + } + } + + def get_name(self): + return "Espressif" From b86dd33d6ece571975db138edb456a24565e04ff Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Apr 2015 00:15:54 +0300 Subject: [PATCH 18/38] Typo fix --- docs/faq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/faq.rst b/docs/faq.rst index 1b69f45d..7801504c 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -62,7 +62,7 @@ Troubleshooting .. _faq_troubleshooting_pioblocksprompt: -PlatformIO blocks command execution using user propmt +PlatformIO blocks command execution using user prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you are going to run *PlatformIO* from **subprocess**, you **MUST From 380937c5881a31dec94d64671d70fd65b631e3ec Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Apr 2015 17:41:21 +0300 Subject: [PATCH 19/38] Start 1.4.0 --- HISTORY.rst | 11 +++++++++++ platformio/__init__.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index aa9550ef..cfbedee1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,17 @@ Release History =============== +1.4.0 (2015-??-??) +------------------ + +* Integrated PlatformIO with AppVeyor Windows based Continuous Integration system + (`issue #149 `_) +* Added support for new Arduino based boards by *SparkFun, BQ, LightUp, + LowPowerLab, RedBearLab, TinyCircuits, WickedDevice* to + `atmelavr `__ + platform + + 1.3.0 (2015-03-27) ------------------ diff --git a/platformio/__init__.py b/platformio/__init__.py index d8d3b7ba..a2b64bbb 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (1, 3, 0) +VERSION = (1, 4, "0.dev0") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From cdd7167e240e8e8b909864ec1faa32b942af30b1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Apr 2015 17:42:00 +0300 Subject: [PATCH 20/38] Improve firmware detecting for system tests --- .isort.cfg | 2 +- tests/test_examples.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index c905e9ca..72280366 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,3 +1,3 @@ [settings] line_length=79 -known_third_party=click,requests,serial,SCons +known_third_party=click,requests,serial,SCons,pytest diff --git a/tests/test_examples.py b/tests/test_examples.py index 2677ccfc..9ababba2 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -1,6 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. +from glob import glob from os import listdir, walk from os.path import dirname, getsize, isdir, isfile, join, normpath from shutil import rmtree @@ -39,12 +40,11 @@ def test_run(platformio_setup, pioproject_dir): pioenvs_dir = join(pioproject_dir, ".pioenvs") for item in listdir(pioenvs_dir): assert isfile(join(pioenvs_dir, item, "firmware.elf")) - # check .hex or .bin file - bin_file = join(pioenvs_dir, item, "firmware.bin") - hex_file = join(pioenvs_dir, item, "firmware.hex") - if not isfile(bin_file): - if not isfile(hex_file): - pytest.fail("Missed firmware file") - assert getsize(hex_file) > 0 - else: - assert getsize(bin_file) > 0 + # check .hex or .bin files + firmwares = [] + for ext in ("bin", "hex"): + firmwares += glob(join(pioenvs_dir, item, "firmware*.%s" % ext)) + if not firmwares: + pytest.fail("Missed firmware file") + for firmware in firmwares: + assert getsize(firmware) > 0 From 3af181428588c1c56df89625f0e634af7e2201de Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Apr 2015 17:45:20 +0300 Subject: [PATCH 21/38] Add support for new Arduino based boards to "atmelavr" platform SparkFun, BQ, LightUp, LowPowerLab, RedBearLab, TinyCircuits, WickedDevice --- docs/frameworks/arduino.rst | 169 ++++++++++++++++++++++++++++++++++++ docs/platforms/atmelavr.rst | 169 ++++++++++++++++++++++++++++++++++++ 2 files changed, 338 insertions(+) diff --git a/docs/frameworks/arduino.rst b/docs/frameworks/arduino.rst index 1b4610b6..360d656c 100644 --- a/docs/frameworks/arduino.rst +++ b/docs/frameworks/arduino.rst @@ -328,6 +328,26 @@ Arduino - 32 Kb - 2.5 Kb +BQ +~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``zumbt328`` + - `BQ ZUM BT-328 board `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + BitWizard ~~~~~~~~~ @@ -430,6 +450,53 @@ Engduino - 32 Kb - 2.5 Kb +LightUp +~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``lightup`` + - `LightUp `_ + - ATMEGA32U4 + - 8 MHz + - 32 Kb + - 2.5 Kb + +LowPowerLab +~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``moteino`` + - `LowPowerLab Moteino `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + + * - ``moteinomega`` + - `LowPowerLab MoteinoMEGA `_ + - ATMEGA1284P + - 16 MHz + - 128 Kb + - 16 Kb + Microduino ~~~~~~~~~~ @@ -533,6 +600,40 @@ PanStamp - 32 Kb - 4 Kb +RedBearLab +~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``blend`` + - `RedBearLab Blend `_ + - ATMEGA32U4 + - 16 MHz + - 32 Kb + - 2.5 Kb + + * - ``blendmicro16`` + - `RedBearLab Blend Micro 3.3V/16MHz (overclock) `_ + - ATMEGA32U4 + - 16 MHz + - 32 Kb + - 2.5 Kb + + * - ``blendmicro8`` + - `RedBearLab Blend Micro 3.3V/8MHz `_ + - ATMEGA32U4 + - 8 MHz + - 32 Kb + - 2.5 Kb + RepRap ~~~~~~ @@ -634,6 +735,13 @@ SparkFun - Flash - RAM + * - ``sparkfun_digitalsandbox`` + - `SparkFun Digital Sandbox `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + * - ``sparkfun_fiov3`` - `SparkFun Fio V3 3.3V/8MHz `_ - ATMEGA32U4 @@ -690,6 +798,13 @@ SparkFun - 32 Kb - 2 Kb + * - ``uview`` + - `SparkFun MicroView `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + Teensy ~~~~~~ @@ -730,3 +845,57 @@ Teensy - 72 MHz - 256 Kb - 64 Kb + +TinyCircuits +~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``tinyduino`` + - `TinyCircuits TinyDuino Processor Board `_ + - ATMEGA328P + - 8 MHz + - 32 Kb + - 2 Kb + + * - ``tinylily`` + - `TinyCircuits TinyLily Mini Processor `_ + - ATMEGA328P + - 8 MHz + - 32 Kb + - 2 Kb + +WickedDevice +~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``wildfirev2`` + - `WickedDevice WildFire v2 [stk500] `_ + - ATMEGA1284P + - 16 MHz + - 128 Kb + - 16 Kb + + * - ``wildfirev3`` + - `WickedDevice WildFire v3 [optiboot] `_ + - ATMEGA1284P + - 16 MHz + - 128 Kb + - 16 Kb diff --git a/docs/platforms/atmelavr.rst b/docs/platforms/atmelavr.rst index fbbf6cc0..45605eaa 100644 --- a/docs/platforms/atmelavr.rst +++ b/docs/platforms/atmelavr.rst @@ -333,6 +333,26 @@ Arduino - 32 Kb - 2.5 Kb +BQ +~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``zumbt328`` + - `BQ ZUM BT-328 board `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + BitWizard ~~~~~~~~~ @@ -428,6 +448,53 @@ Engduino - 32 Kb - 2.5 Kb +LightUp +~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``lightup`` + - `LightUp `_ + - ATMEGA32U4 + - 8 MHz + - 32 Kb + - 2.5 Kb + +LowPowerLab +~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``moteino`` + - `LowPowerLab Moteino `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + + * - ``moteinomega`` + - `LowPowerLab MoteinoMEGA `_ + - ATMEGA1284P + - 16 MHz + - 128 Kb + - 16 Kb + Microduino ~~~~~~~~~~ @@ -524,6 +591,40 @@ PanStamp - 32 Kb - 2 Kb +RedBearLab +~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``blend`` + - `RedBearLab Blend `_ + - ATMEGA32U4 + - 16 MHz + - 32 Kb + - 2.5 Kb + + * - ``blendmicro16`` + - `RedBearLab Blend Micro 3.3V/16MHz (overclock) `_ + - ATMEGA32U4 + - 16 MHz + - 32 Kb + - 2.5 Kb + + * - ``blendmicro8`` + - `RedBearLab Blend Micro 3.3V/8MHz `_ + - ATMEGA32U4 + - 8 MHz + - 32 Kb + - 2.5 Kb + RepRap ~~~~~~ @@ -598,6 +699,13 @@ SparkFun - Flash - RAM + * - ``sparkfun_digitalsandbox`` + - `SparkFun Digital Sandbox `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + * - ``sparkfun_fiov3`` - `SparkFun Fio V3 3.3V/8MHz `_ - ATMEGA32U4 @@ -653,3 +761,64 @@ SparkFun - 16 MHz - 32 Kb - 2 Kb + + * - ``uview`` + - `SparkFun MicroView `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + +TinyCircuits +~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``tinyduino`` + - `TinyCircuits TinyDuino Processor Board `_ + - ATMEGA328P + - 8 MHz + - 32 Kb + - 2 Kb + + * - ``tinylily`` + - `TinyCircuits TinyLily Mini Processor `_ + - ATMEGA328P + - 8 MHz + - 32 Kb + - 2 Kb + +WickedDevice +~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``wildfirev2`` + - `WickedDevice WildFire v2 [stk500] `_ + - ATMEGA1284P + - 16 MHz + - 128 Kb + - 16 Kb + + * - ``wildfirev3`` + - `WickedDevice WildFire v3 [optiboot] `_ + - ATMEGA1284P + - 16 MHz + - 128 Kb + - 16 Kb From fd0448532c55d323c7624e287841d429822b1712 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Apr 2015 18:09:58 +0300 Subject: [PATCH 22/38] Fix libs order for linker --- platformio/builder/tools/platformio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 9913c91a..8402e6e3 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -63,7 +63,7 @@ def BuildFirmware(env): return firmenv.Program( join("$BUILD_DIR", "firmware"), [firmenv.GlobCXXFiles(vdir) for vdir in vdirs], - LIBS=env.get("LIBS", []) + deplibs, + LIBS=list(env.get("LIBS", []) + deplibs)[::-1], LIBPATH=env.get("LIBPATH", []) + ["$BUILD_DIR"], PROGSUFFIX=".elf" ) From bf19dc936b5c20be315d6b97c2001e9aec07eeb7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 6 Apr 2015 11:43:56 +0300 Subject: [PATCH 23/38] Add "ldscripts" package to required list of Espressif platform // Issue #119 --- platformio/platforms/espressif.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platformio/platforms/espressif.py b/platformio/platforms/espressif.py index 5752d44d..4336aeb3 100644 --- a/platformio/platforms/espressif.py +++ b/platformio/platforms/espressif.py @@ -21,6 +21,10 @@ class EspressifPlatform(BasePlatform): "default": True }, + "ldscripts": { + "default": True + }, + "tool-esptool": { "alias": "uploader", "default": True From 22e2cec1025fe425bf7ee1c00ff68283654016a7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 6 Apr 2015 11:44:45 +0300 Subject: [PATCH 24/38] Update Adafruit GFX Library in examples for the latest version --- .../arduino-external-libs/lib/Adafruit-GFX-Library | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/atmelavr-and-arduino/arduino-external-libs/lib/Adafruit-GFX-Library b/examples/atmelavr-and-arduino/arduino-external-libs/lib/Adafruit-GFX-Library index a9e5bc47..b346ad0d 160000 --- a/examples/atmelavr-and-arduino/arduino-external-libs/lib/Adafruit-GFX-Library +++ b/examples/atmelavr-and-arduino/arduino-external-libs/lib/Adafruit-GFX-Library @@ -1 +1 @@ -Subproject commit a9e5bc470736ffe9c9ef11d778bc4dcd47169d42 +Subproject commit b346ad0df569c3b5d27c7e64656a3e1408fb8aa8 From b23a8a7075c8f0981e2d19e1566f9562fdc78d84 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Mon, 6 Apr 2015 20:22:03 +0300 Subject: [PATCH 25/38] Add support for Teensy LC board // Resolve #155 --- .../teensy-internal-libs/platformio.ini | 6 ++++++ platformio/boards/teensy.json | 20 +++++++++++++++++++ platformio/builder/scripts/teensy.py | 9 ++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/examples/teensy/teensy-internal-libs/platformio.ini b/examples/teensy/teensy-internal-libs/platformio.ini index ced3cf02..18ce5b16 100644 --- a/examples/teensy/teensy-internal-libs/platformio.ini +++ b/examples/teensy/teensy-internal-libs/platformio.ini @@ -40,3 +40,9 @@ platform = teensy framework = arduino board = teensy31 build_flags = -DTEENSY31 + +[env:teensylc] +platform = teensy +framework = arduino +board = teensylc +build_flags = -DTEENSYLC diff --git a/platformio/boards/teensy.json b/platformio/boards/teensy.json index bb3b4a88..c0e39961 100644 --- a/platformio/boards/teensy.json +++ b/platformio/boards/teensy.json @@ -71,5 +71,25 @@ }, "url": "https://www.pjrc.com/store/teensy31.html", "vendor": "Teensy" + }, + + "teensylc": { + "build": { + "core": "teensy3", + "extra_flags": "-D__MKL26Z64__", + "f_cpu": "48000000L", + "ldscript": "mkl26z64.ld", + "mcu": "mkl26z64", + "cpu": "cortex-m0plus" + }, + "frameworks": ["arduino"], + "name": "Teensy LC", + "platform": "teensy", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 63488 + }, + "url": "http://www.pjrc.com/teensy/teensyLC.html", + "vendor": "Teensy" } } diff --git a/platformio/builder/scripts/teensy.py b/platformio/builder/scripts/teensy.py index 140fa8fd..4d97a54e 100644 --- a/platformio/builder/scripts/teensy.py +++ b/platformio/builder/scripts/teensy.py @@ -26,7 +26,14 @@ env.Append( CXXFLAGS=[ "-std=gnu++0x", "-felide-constructors" - ] + ], + + LINKFLAGS=[ + "-Wl,--gc-sections,--relax,--defsym=__rtc_localtime=$UNIX_TIME", + "--specs=nano.specs" + ], + + LIBS=["m"] ) if isfile(env.subst(join( From 960eccad8c132b00a0b59b303f85151a99dd2e6f Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Mon, 6 Apr 2015 21:16:10 +0300 Subject: [PATCH 26/38] Add "nano.specs" for ARM linker --- platformio/builder/scripts/basearm.py | 5 +++-- platformio/builder/scripts/baseavr.py | 2 +- platformio/builder/scripts/teensy.py | 12 ++++-------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/platformio/builder/scripts/basearm.py b/platformio/builder/scripts/basearm.py index 9ae00990..cc947a32 100644 --- a/platformio/builder/scripts/basearm.py +++ b/platformio/builder/scripts/basearm.py @@ -45,9 +45,10 @@ env.Replace( LINKFLAGS=[ "-Os", - "-Wl,--gc-sections", + "-Wl,--gc-sections,--relax", "-mthumb", - "-mcpu=${BOARD_OPTIONS['build']['cpu']}" + "-mcpu=${BOARD_OPTIONS['build']['cpu']}", + "--specs=nano.specs" ], LIBS=["c", "gcc", "m"], diff --git a/platformio/builder/scripts/baseavr.py b/platformio/builder/scripts/baseavr.py index 8a0384f1..3ac52b00 100644 --- a/platformio/builder/scripts/baseavr.py +++ b/platformio/builder/scripts/baseavr.py @@ -44,7 +44,7 @@ env.Replace( LINKFLAGS=[ "-Os", "-mmcu=$BOARD_MCU", - "-Wl,--gc-sections" + "-Wl,--gc-sections,--relax" ], LIBS=["m"], diff --git a/platformio/builder/scripts/teensy.py b/platformio/builder/scripts/teensy.py index 4d97a54e..ba657713 100644 --- a/platformio/builder/scripts/teensy.py +++ b/platformio/builder/scripts/teensy.py @@ -16,6 +16,9 @@ if env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy": SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "baseavr.py"))) elif env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy3": SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) + env.Append( + LINKFLAGS=["-Wl,--defsym=__rtc_localtime=$UNIX_TIME"] + ) env.Append( CPPDEFINES=[ @@ -26,14 +29,7 @@ env.Append( CXXFLAGS=[ "-std=gnu++0x", "-felide-constructors" - ], - - LINKFLAGS=[ - "-Wl,--gc-sections,--relax,--defsym=__rtc_localtime=$UNIX_TIME", - "--specs=nano.specs" - ], - - LIBS=["m"] + ] ) if isfile(env.subst(join( From 469ae260ca4874cdaed9730d8b5c7ce2a632da9e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 6 Apr 2015 22:28:16 +0300 Subject: [PATCH 27/38] Add link to free Visual Studio --- docs/ide/visualstudio.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ide/visualstudio.rst b/docs/ide/visualstudio.rst index 385f91da..c5fc28d3 100644 --- a/docs/ide/visualstudio.rst +++ b/docs/ide/visualstudio.rst @@ -3,7 +3,7 @@ Visual Studio ============= -The `Microsoft Visual Studio `_ is an integrated development environment (IDE) from Microsoft. Visual Studio includes a code editor supporting IntelliSense (the code completion component) as well as code refactoring. +The `Microsoft Visual Studio (Free) `_ is an integrated development environment (IDE) from Microsoft. Visual Studio includes a code editor supporting IntelliSense (the code completion component) as well as code refactoring. This software can be used with: From 0ff3e8a9ebaaa52c458bd63080eedce2a19bbb5d Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Tue, 7 Apr 2015 19:44:28 +0300 Subject: [PATCH 28/38] Update espressif platform --- examples/espressif/esp8266-native/README.rst | 21 -- .../espressif/esp8266-native/platformio.ini | 22 -- .../espressif/esp8266-native/src/at_upgrade.c | 288 ------------------ .../esp8266-native/src/user_config.h | 6 - .../espressif/esp8266-native/src/user_main.c | 113 ------- platformio/builder/scripts/espressif.py | 29 +- .../builder/scripts/frameworks/arduino.py | 16 - 7 files changed, 8 insertions(+), 487 deletions(-) delete mode 100644 examples/espressif/esp8266-native/README.rst delete mode 100644 examples/espressif/esp8266-native/platformio.ini delete mode 100644 examples/espressif/esp8266-native/src/at_upgrade.c delete mode 100644 examples/espressif/esp8266-native/src/user_config.h delete mode 100644 examples/espressif/esp8266-native/src/user_main.c diff --git a/examples/espressif/esp8266-native/README.rst b/examples/espressif/esp8266-native/README.rst deleted file mode 100644 index ab31e6cf..00000000 --- a/examples/espressif/esp8266-native/README.rst +++ /dev/null @@ -1,21 +0,0 @@ -How to build 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/espressif/esp8266-native/ - - # Process example project - > platformio run - - # Upload firmware - > platformio run --target upload - - # Clean build files - > platformio run --target clean diff --git a/examples/espressif/esp8266-native/platformio.ini b/examples/espressif/esp8266-native/platformio.ini deleted file mode 100644 index 304bd86f..00000000 --- a/examples/espressif/esp8266-native/platformio.ini +++ /dev/null @@ -1,22 +0,0 @@ -# -# 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 - -[env:esp01_8266] -platform = espressif -board = esp01 diff --git a/examples/espressif/esp8266-native/src/at_upgrade.c b/examples/espressif/esp8266-native/src/at_upgrade.c deleted file mode 100644 index 59ecdea2..00000000 --- a/examples/espressif/esp8266-native/src/at_upgrade.c +++ /dev/null @@ -1,288 +0,0 @@ -/****************************************************************************** - * Copyright 2015-2018 Espressif Systems (Wuxi) - * - * FileName: user_main.c - * - * Description: entry file of user application - * - * Modification history: - * 2015/3/06, v1.0 create this file. -*******************************************************************************/ -#include "c_types.h" -#include "user_interface.h" -#include "espconn.h" -#include "mem.h" -#include "osapi.h" -#include "upgrade.h" - -#ifdef AT_CUSTOM_UPGRADE - -#define UPGRADE_FRAME "{\"path\": \"/v1/messages/\", \"method\": \"POST\", \"meta\": {\"Authorization\": \"token %s\"},\ -\"get\":{\"action\":\"%s\"},\"body\":{\"pre_rom_version\":\"%s\",\"rom_version\":\"%s\"}}\n" - -#define pheadbuffer "Connection: keep-alive\r\n\ -Cache-Control: no-cache\r\n\ -User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 \r\n\ -Accept: */*\r\n\ -Accept-Encoding: gzip,deflate\r\n\ -Accept-Language: zh-CN,eb-US;q=0.8\r\n\r\n" - -/**/ - - -struct espconn *pespconn = NULL; -struct upgrade_server_info *upServer = NULL; - -static os_timer_t at_delay_check; -static struct espconn *pTcpServer = NULL; -static ip_addr_t host_ip; -/****************************************************************************** - * FunctionName : user_esp_platform_upgrade_cb - * Description : Processing the downloaded data from the server - * Parameters : pespconn -- the espconn used to connetion with the host - * Returns : none -*******************************************************************************/ -LOCAL void ICACHE_FLASH_ATTR -at_upDate_rsp(void *arg) -{ - struct upgrade_server_info *server = arg; - - - if(server->upgrade_flag == true) - { - os_printf("device_upgrade_success\r\n"); - at_response_ok(); - system_upgrade_reboot(); - } - else - { - os_printf("device_upgrade_failed\r\n"); - at_response_error(); - } - - os_free(server->url); - server->url = NULL; - os_free(server); - server = NULL; -} -/** - * @brief Tcp client disconnect success callback function. - * @param arg: contain the ip link information - * @retval None - */ -static void ICACHE_FLASH_ATTR -at_upDate_discon_cb(void *arg) -{ - struct espconn *pespconn = (struct espconn *)arg; - uint8_t idTemp = 0; - - if(pespconn->proto.tcp != NULL) - { - os_free(pespconn->proto.tcp); - } - if(pespconn != NULL) - { - os_free(pespconn); - } - - os_printf("disconnect\r\n"); - - if(system_upgrade_start(upServer) == false) - { - at_response_error(); - } - else - { - at_port_print("+CIPUPDATE:4\r\n"); - } -} - -/** - * @brief Udp server receive data callback function. - * @param arg: contain the ip link information - * @retval None - */ -LOCAL void ICACHE_FLASH_ATTR -at_upDate_recv(void *arg, char *pusrdata, unsigned short len) -{ - struct espconn *pespconn = (struct espconn *)arg; - char temp[32] = {0}; - uint8_t user_bin[12] = {0}; - uint8_t i = 0; - - os_timer_disarm(&at_delay_check); - at_port_print("+CIPUPDATE:3\r\n"); - - upServer = (struct upgrade_server_info *)os_zalloc(sizeof(struct upgrade_server_info)); - - upServer->upgrade_version[5] = '\0'; - - upServer->pespconn = pespconn; - - os_memcpy(upServer->ip, pespconn->proto.tcp->remote_ip, 4); - - upServer->port = 80; - - upServer->check_cb = at_upDate_rsp; - upServer->check_times = 60000; - - if(upServer->url == NULL) - { - upServer->url = (uint8 *) os_zalloc(1024); - } - - if(system_upgrade_userbin_check() == UPGRADE_FW_BIN1) - { - os_memcpy(user_bin, "user2.bin", 10); - } - else if(system_upgrade_userbin_check() == UPGRADE_FW_BIN2) - { - os_memcpy(user_bin, "user1.bin", 10); - } - - os_sprintf(upServer->url, - "GET /%s HTTP/1.1\r\nHost: "IPSTR"\r\n"pheadbuffer"", - user_bin, IP2STR(upServer->ip)); -} - -LOCAL void ICACHE_FLASH_ATTR -at_upDate_wait(void *arg) -{ - struct espconn *pespconn = arg; - os_timer_disarm(&at_delay_check); - if(pespconn != NULL) - { - espconn_disconnect(pespconn); - } - else - { - at_response_error(); - } -} - -/****************************************************************************** - * FunctionName : user_esp_platform_sent_cb - * Description : Data has been sent successfully and acknowledged by the remote host. - * Parameters : arg -- Additional argument to pass to the callback function - * Returns : none -*******************************************************************************/ -LOCAL void ICACHE_FLASH_ATTR -at_upDate_sent_cb(void *arg) -{ - struct espconn *pespconn = arg; - os_timer_disarm(&at_delay_check); - os_timer_setfn(&at_delay_check, (os_timer_func_t *)at_upDate_wait, pespconn); - os_timer_arm(&at_delay_check, 5000, 0); - os_printf("at_upDate_sent_cb\r\n"); -} - -/** - * @brief Tcp client connect success callback function. - * @param arg: contain the ip link information - * @retval None - */ -static void ICACHE_FLASH_ATTR -at_upDate_connect_cb(void *arg) -{ - struct espconn *pespconn = (struct espconn *)arg; - uint8_t user_bin[9] = {0}; - char *temp = NULL; - - at_port_print("+CIPUPDATE:2\r\n"); - - - espconn_regist_disconcb(pespconn, at_upDate_discon_cb); - espconn_regist_recvcb(pespconn, at_upDate_recv);//////// - espconn_regist_sentcb(pespconn, at_upDate_sent_cb); - - temp = (uint8 *) os_zalloc(512); - - os_sprintf(temp,"GET /v1/device/rom/?is_format_simple=true HTTP/1.0\r\nHost: "IPSTR"\r\n"pheadbuffer"", - IP2STR(pespconn->proto.tcp->remote_ip)); - - espconn_sent(pespconn, temp, os_strlen(temp)); - os_free(temp); -} - -/** - * @brief Tcp client connect repeat callback function. - * @param arg: contain the ip link information - * @retval None - */ -static void ICACHE_FLASH_ATTR -at_upDate_recon_cb(void *arg, sint8 errType) -{ - struct espconn *pespconn = (struct espconn *)arg; - - at_response_error(); - if(pespconn->proto.tcp != NULL) - { - os_free(pespconn->proto.tcp); - } - os_free(pespconn); - os_printf("disconnect\r\n"); - - if(upServer != NULL) - { - os_free(upServer); - upServer = NULL; - } - at_response_error(); - -} - -/****************************************************************************** - * FunctionName : upServer_dns_found - * Description : dns found callback - * Parameters : name -- pointer to the name that was looked up. - * ipaddr -- pointer to an ip_addr_t containing the IP address of - * the hostname, or NULL if the name could not be found (or on any - * other error). - * callback_arg -- a user-specified callback argument passed to - * dns_gethostbyname - * Returns : none -*******************************************************************************/ -LOCAL void ICACHE_FLASH_ATTR -upServer_dns_found(const char *name, ip_addr_t *ipaddr, void *arg) -{ - struct espconn *pespconn = (struct espconn *) arg; -// char temp[32]; - - if(ipaddr == NULL) - { - at_response_error(); - return; - } - at_port_print("+CIPUPDATE:1\r\n"); - - - if(host_ip.addr == 0 && ipaddr->addr != 0) - { - if(pespconn->type == ESPCONN_TCP) - { - os_memcpy(pespconn->proto.tcp->remote_ip, &ipaddr->addr, 4); - espconn_regist_connectcb(pespconn, at_upDate_connect_cb); - espconn_regist_reconcb(pespconn, at_upDate_recon_cb); - espconn_connect(pespconn); - } - } -} - -void ICACHE_FLASH_ATTR -at_exeCmdCiupdate(uint8_t id) -{ - pespconn = (struct espconn *)os_zalloc(sizeof(struct espconn)); - pespconn->type = ESPCONN_TCP; - pespconn->state = ESPCONN_NONE; - pespconn->proto.tcp = (esp_tcp *)os_zalloc(sizeof(esp_tcp)); - pespconn->proto.tcp->local_port = espconn_port(); - pespconn->proto.tcp->remote_port = 80; - - host_ip.addr = ipaddr_addr("192.168.10.9"); - at_port_print("+CIPUPDATE:1\r\n"); - os_memcpy(pespconn->proto.tcp->remote_ip, &host_ip.addr, 4); - espconn_regist_connectcb(pespconn, at_upDate_connect_cb); - espconn_regist_reconcb(pespconn, at_upDate_recon_cb); - espconn_connect(pespconn); -} -#endif diff --git a/examples/espressif/esp8266-native/src/user_config.h b/examples/espressif/esp8266-native/src/user_config.h deleted file mode 100644 index 4a573ebe..00000000 --- a/examples/espressif/esp8266-native/src/user_config.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __USER_CONFIG_H__ -#define __USER_CONFIG_H__ - -#define AT_CUSTOM_UPGRADE - -#endif diff --git a/examples/espressif/esp8266-native/src/user_main.c b/examples/espressif/esp8266-native/src/user_main.c deleted file mode 100644 index 953bf00e..00000000 --- a/examples/espressif/esp8266-native/src/user_main.c +++ /dev/null @@ -1,113 +0,0 @@ -/****************************************************************************** - * Copyright 2013-2014 Espressif Systems (Wuxi) - * - * FileName: user_main.c - * - * Description: entry file of user application - * - * Modification history: - * 2015/1/23, v1.0 create this file. -*******************************************************************************/ - -#include "osapi.h" -#include "at_custom.h" -#include "user_interface.h" - -// test :AT+TEST=1,"abc"<,3> -void ICACHE_FLASH_ATTR -at_setupCmdTest(uint8_t id, char *pPara) -{ - int result = 0, err = 0, flag = 0; - uint8 buffer[32] = {0}; - pPara++; // skip '=' - - //get the first parameter - // digit - flag = at_get_next_int_dec(&pPara, &result, &err); - - // flag must be ture because there are more parameter - if (flag == FALSE) { - at_response_error(); - return; - } - - if (*pPara++ != ',') { // skip ',' - at_response_error(); - return; - } - - os_sprintf(buffer, "the first parameter:%d\r\n", result); - at_port_print(buffer); - - //get the second parameter - // string - at_data_str_copy(buffer, &pPara, 10); - at_port_print("the second parameter:"); - at_port_print(buffer); - at_port_print("\r\n"); - - if (*pPara == ',') { - pPara++; // skip ',' - result = 0; - //there is the third parameter - // digit - flag = at_get_next_int_dec(&pPara, &result, &err); - // we donot care of flag - os_sprintf(buffer, "the third parameter:%d\r\n", result); - at_port_print(buffer); - } - - if (*pPara != '\r') { - at_response_error(); - return; - } - - at_response_ok(); -} - -void ICACHE_FLASH_ATTR -at_testCmdTest(uint8_t id) -{ - uint8 buffer[32] = {0}; - - os_sprintf(buffer, "%s\r\n", "at_testCmdTest"); - at_port_print(buffer); - at_response_ok(); -} - -void ICACHE_FLASH_ATTR -at_queryCmdTest(uint8_t id) -{ - uint8 buffer[32] = {0}; - - os_sprintf(buffer, "%s\r\n", "at_queryCmdTest"); - at_port_print(buffer); - at_response_ok(); -} - -void ICACHE_FLASH_ATTR -at_exeCmdTest(uint8_t id) -{ - uint8 buffer[32] = {0}; - - os_sprintf(buffer, "%s\r\n", "at_exeCmdTest"); - at_port_print(buffer); - at_response_ok(); -} - -extern void at_exeCmdCiupdate(uint8_t id); -at_funcationType at_custom_cmd[] = { - {"+TEST", 5, at_testCmdTest, at_queryCmdTest, at_setupCmdTest, at_exeCmdTest}, - {"+CIUPDATE", 9, NULL, NULL, NULL, at_exeCmdCiupdate} -}; - -void user_init(void) -{ - char buf[64] = {0}; - at_customLinkMax = 5; - at_init(); - os_sprintf(buf,"compile time:%s %s",__DATE__,__TIME__); - at_set_custom_info(buf); - at_port_print("\r\nready\r\n"); - at_cmd_array_regist(&at_custom_cmd[0], sizeof(at_custom_cmd)/sizeof(at_custom_cmd[0])); -} diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index 7a654832..5d2d3c85 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -35,6 +35,7 @@ env.Replace( "-Wpointer-arith", "-Wno-implicit-function-declaration", "-Wl,-EL", + "-fno-inline-functions", "-nostdlib" ], @@ -57,6 +58,11 @@ env.Replace( "ICACHE_FLASH" ], + CPPPATH=[ + join("$PIOPACKAGES_DIR", "sdk-esp8266", "include"), + "$PROJECTSRC_DIR" + ], + LINKFLAGS=[ "-nostdlib", "-Wl,--no-check-section", @@ -64,7 +70,8 @@ env.Replace( "-Wl,-static" ], - LIBS=["c", "gcc"], + LIBPATH=[join("$PIOPACKAGES_DIR", "sdk-esp8266", "lib")], + LIBS=["c", "gcc", "hal", "phy", "net80211", "lwip", "wpa", "main", "pp"], SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', @@ -102,26 +109,6 @@ env.Append( ) ) -# -# Configure SDK -# - -if "FRAMEWORK" not in env: - env.Append( - CPPPATH=[ - join("$PIOPACKAGES_DIR", "sdk-esp8266", "include"), - "$PROJECTSRC_DIR" - ], - LIBPATH=[join("$PIOPACKAGES_DIR", "sdk-esp8266", "lib")], - LIBS=["at", "json", "lwip", "main", "net80211", "phy", "pp", - "smartconfig", "ssl", "upgrade", "wpa"] - ) - env.Replace( - LDSCRIPT_PATH=join( - "$PIOPACKAGES_DIR", "sdk-esp8266", "ld", "eagle.app.v6.ld") - ) - - # # Target: Build executable and linkable firmware # diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index 5c4846bb..cbeb1e42 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -42,14 +42,6 @@ elif env.get("PLATFORM") == "timsp430": "$PIOPACKAGES_DIR", "framework-arduinomsp430" ) -elif env.get("PLATFORM") == "espressif": - PLATFORMFW_DIR = join( - "$PIOPACKAGES_DIR", - "framework-arduinoespressif" - ) - env.Append( - CPPPATH=[join("$PLATFORMFW_DIR", "sdk", "include")] - ) env.Replace(PLATFORMFW_DIR=PLATFORMFW_DIR) @@ -203,14 +195,12 @@ libs.append(envsafe.BuildLibrary( )) if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam": - env.Append( LIBPATH=[ join("$PLATFORMFW_DIR", "variants", "${BOARD_OPTIONS['build']['variant']}") ] ) - envsafe.Append( CFLAGS=[ "-std=gnu99" @@ -218,10 +208,4 @@ if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam": ) libs.append("sam_sam3x8e_gcc_rel") -elif env.get("PLATFORM") == "espressif": - env.Append( - LIBPATH=[join("$PLATFORMFW_DIR", "sdk", "lib")] - ) - libs.extend(["hal", "phy", "net80211", "lwip", "wpa", "main", "pp"]) - env.Append(LIBS=libs) From 0a76df910d49d70d3f434a45140c61ce594bbf85 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 7 Apr 2015 23:13:34 +0300 Subject: [PATCH 29/38] Bump up to 1.4.0.dev1 Support for TeensyLC --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index a2b64bbb..1ff17790 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (1, 4, "0.dev0") +VERSION = (1, 4, "0.dev1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 44c78525ee886a369be66d671523dd3258ba37d5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 8 Apr 2015 19:45:24 +0300 Subject: [PATCH 30/38] Remove hard FPU for Cortex M4 // Resolve #162 --- platformio/builder/scripts/basearm.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/platformio/builder/scripts/basearm.py b/platformio/builder/scripts/basearm.py index cc947a32..bae7db23 100644 --- a/platformio/builder/scripts/basearm.py +++ b/platformio/builder/scripts/basearm.py @@ -56,21 +56,6 @@ env.Replace( SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES' ) -if env.get("BOARD_OPTIONS", {}).get("build", {}).get( - "cpu", "")[-2:] == "m4" and env.get("BOARD") != "frdm_k20d50m": - env.Append( - CPPFLAGS=[ - "-mfloat-abi=hard", - "-mfpu=fpv4-sp-d16", - "-fsingle-precision-constant" - ], - LINKFLAGS=[ - "-mfloat-abi=hard", - "-mfpu=fpv4-sp-d16", - "-fsingle-precision-constant" - ] - ) - env.Append( BUILDERS=dict( ElfToBin=Builder( From 6cf2ab29daaa522834186afe53f9f951bf6fd6f0 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Wed, 8 Apr 2015 20:49:48 +0300 Subject: [PATCH 31/38] Improve ESP8266 platform support --- platformio/builder/scripts/espressif.py | 11 +++-------- platformio/builder/scripts/frameworks/arduino.py | 4 ++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index 5d2d3c85..78dfced8 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -58,20 +58,15 @@ env.Replace( "ICACHE_FLASH" ], - CPPPATH=[ - join("$PIOPACKAGES_DIR", "sdk-esp8266", "include"), - "$PROJECTSRC_DIR" - ], - LINKFLAGS=[ "-nostdlib", - "-Wl,--no-check-section", + "-Wl,--no-check-sections", "-u", "call_user_start", "-Wl,-static" ], - LIBPATH=[join("$PIOPACKAGES_DIR", "sdk-esp8266", "lib")], - LIBS=["c", "gcc", "hal", "phy", "net80211", "lwip", "wpa", "main", "pp"], + LIBPATH=[join("$PLATFORMFW_DIR", "sdk", "lib")], + LIBS=["hal", "phy", "net80211", "lwip", "wpa", "main", "pp", "c", "gcc"], SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index cbeb1e42..4b6acde2 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -42,6 +42,10 @@ elif env.get("PLATFORM") == "timsp430": "$PIOPACKAGES_DIR", "framework-arduinomsp430" ) +elif env.get("PLATFORM") == "espressif": + env.Prepend( + CPPPATH=[join("$PLATFORMFW_DIR", "sdk", "include")] + ) env.Replace(PLATFORMFW_DIR=PLATFORMFW_DIR) From be3e7ccdddda91c432936865cd3fb2f97a485b7f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 8 Apr 2015 21:01:55 +0300 Subject: [PATCH 32/38] Bump up to 1.4.0.dev2 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 1ff17790..b78a8f83 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (1, 4, "0.dev1") +VERSION = (1, 4, "0.dev2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 181959f1debf3f72a4e053a1b3d688c9e1f15885 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Thu, 9 Apr 2015 18:50:03 +0300 Subject: [PATCH 33/38] Add support for ESP8266 // Resolve #119 --- examples/espressif/esp8266-native/README.rst | 21 ++++++ .../espressif/esp8266-native/platformio.ini | 22 +++++++ .../esp8266-native/src/user_config.h | 5 ++ .../espressif/esp8266-native/src/user_main.c | 33 ++++++++++ platformio/boards/espressif.json | 3 +- platformio/builder/scripts/espressif.py | 66 +++++++++++-------- .../builder/scripts/frameworks/arduino.py | 5 +- 7 files changed, 126 insertions(+), 29 deletions(-) create mode 100644 examples/espressif/esp8266-native/README.rst create mode 100644 examples/espressif/esp8266-native/platformio.ini create mode 100644 examples/espressif/esp8266-native/src/user_config.h create mode 100644 examples/espressif/esp8266-native/src/user_main.c diff --git a/examples/espressif/esp8266-native/README.rst b/examples/espressif/esp8266-native/README.rst new file mode 100644 index 00000000..2704e158 --- /dev/null +++ b/examples/espressif/esp8266-native/README.rst @@ -0,0 +1,21 @@ +How to build 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/espressif/esp8266-native + + # Process example project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/espressif/esp8266-native/platformio.ini b/examples/espressif/esp8266-native/platformio.ini new file mode 100644 index 00000000..304bd86f --- /dev/null +++ b/examples/espressif/esp8266-native/platformio.ini @@ -0,0 +1,22 @@ +# +# 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 + +[env:esp01_8266] +platform = espressif +board = esp01 diff --git a/examples/espressif/esp8266-native/src/user_config.h b/examples/espressif/esp8266-native/src/user_config.h new file mode 100644 index 00000000..35e838d5 --- /dev/null +++ b/examples/espressif/esp8266-native/src/user_config.h @@ -0,0 +1,5 @@ +#ifndef __USER_CONFIG_H__ +#define __USER_CONFIG_H__ + +#endif + diff --git a/examples/espressif/esp8266-native/src/user_main.c b/examples/espressif/esp8266-native/src/user_main.c new file mode 100644 index 00000000..b6f4d027 --- /dev/null +++ b/examples/espressif/esp8266-native/src/user_main.c @@ -0,0 +1,33 @@ +/****************************************************************************** + * Copyright 2013-2014 Espressif Systems (Wuxi) + * + * FileName: user_main.c + * + * Description: entry file of user application + * + * Modification history: + * 2014/1/1, v1.0 create this file. +*******************************************************************************/ +#include "ets_sys.h" +#include "osapi.h" + +#include "user_interface.h" +#include "smartconfig.h" + +void ICACHE_FLASH_ATTR +smartconfig_done(void *data) +{ + struct station_config *sta_conf = data; + + wifi_station_set_config(sta_conf); + wifi_station_disconnect(); + wifi_station_connect(); +} + +void user_init(void) +{ + os_printf("SDK version:%s\n", system_get_sdk_version()); + + wifi_set_opmode(STATION_MODE); + smartconfig_start(SC_TYPE_AIRKISS, smartconfig_done); +} diff --git a/platformio/boards/espressif.json b/platformio/boards/espressif.json index 2fa1d39c..6c2b226c 100644 --- a/platformio/boards/espressif.json +++ b/platformio/boards/espressif.json @@ -16,8 +16,7 @@ "maximum_size": 524288, "protocol": "arduino", "require_upload_port" : true, - "speed": 115200, - "wait_for_upload_port": true + "speed": 115200 }, "url": "https://nurdspace.nl/ESP8266", "vendor": "Espressif" diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index 78dfced8..310648ab 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -5,7 +5,9 @@ Builder for Espressif MCUs """ +import os from os.path import join +from platform import system from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, DefaultEnvironment) @@ -65,45 +67,59 @@ env.Replace( "-Wl,-static" ], - LIBPATH=[join("$PLATFORMFW_DIR", "sdk", "lib")], - LIBS=["hal", "phy", "net80211", "lwip", "wpa", "main", "pp", "c", "gcc"], - SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', - UPLOADER=join("$PIOPACKAGES_DIR", "tool-esptool", "esptool"), + UPLOADER=join("$PIOPACKAGES_DIR", "tool-esptool", "esptool.py"), UPLOADERFLAGS=[ - "-vv", - "-cd", "none", - "-cb", "$UPLOAD_SPEED", - "-cp", "$UPLOAD_PORT", - "-ca", "0x00000", - "-cf", "${SOURCES[0]}", - "-ca", "0x40000", - "-cf", "${SOURCES[1]}" + "--port", "$UPLOAD_PORT", + "--baud", "$UPLOAD_SPEED", + "write_flash", + "0x00000", join("$BUILD_DIR", "firmware.elf-0x00000.bin"), + "0x40000", join("$BUILD_DIR", "firmware.elf-0x40000.bin") ], - UPLOADCMD='$UPLOADER $UPLOADERFLAGS' + UPLOADCMD='python $UPLOADER $UPLOADERFLAGS' ) env.Append( BUILDERS=dict( ElfToBin=Builder( action=" ".join([ - "$UPLOADER", - "-eo", "$SOURCES", - "-bo", "${TARGETS[0]}", - "-bs", ".text", - "-bs", ".data", - "-bs", ".rodata", - "-bc", "-ec", - "-eo", "$SOURCES", - "-es", ".irom0.text", "${TARGETS[1]}", - "-ec", "-v" + "python", "$UPLOADER", "elf2image", "$SOURCES" ]), suffix=".bin" ) ) ) +if system() == "Windows": + paths = [] + for path in os.environ['PATH'].split(";"): + if "python" in path.lower(): + paths.append(path) + + env.AppendENVPath( + "PATH", ";".join(paths) + ) + +# +# Configure SDK +# + +if "FRAMEWORK" not in env: + env.Append( + CPPPATH=[ + join("$PIOPACKAGES_DIR", "sdk-esp8266", "include"), + "$PROJECTSRC_DIR" + ], + LIBPATH=[join("$PIOPACKAGES_DIR", "sdk-esp8266", "lib")] + ) + env.Replace( + LDSCRIPT_PATH=join( + "$PIOPACKAGES_DIR", "sdk-esp8266", "ld", "eagle.app.v6.ld"), + LIBS=["c", "gcc", "phy", "pp", "net80211", "lwip", "wpa", "main", + "json", "upgrade", "smartconfig", "at", "ssl"] + ) + # # Target: Build executable and linkable firmware # @@ -117,9 +133,7 @@ target_elf = env.BuildFirmware() if "uploadlazy" in COMMAND_LINE_TARGETS: target_firm = join("$BUILD_DIR", "firmware.bin") else: - target_firm = env.ElfToBin( - [join("$BUILD_DIR", "firmware_00000"), - join("$BUILD_DIR", "firmware_40000")], target_elf) + target_firm = env.ElfToBin(target_elf) # # Target: Print binary size diff --git a/platformio/builder/scripts/frameworks/arduino.py b/platformio/builder/scripts/frameworks/arduino.py index 4b6acde2..efded5f3 100644 --- a/platformio/builder/scripts/frameworks/arduino.py +++ b/platformio/builder/scripts/frameworks/arduino.py @@ -44,7 +44,10 @@ elif env.get("PLATFORM") == "timsp430": ) elif env.get("PLATFORM") == "espressif": env.Prepend( - CPPPATH=[join("$PLATFORMFW_DIR", "sdk", "include")] + CPPPATH=[join("$PLATFORMFW_DIR", "sdk", "include")], + LIBPATH=[join("$PLATFORMFW_DIR", "sdk", "lib")], + LIBS=["hal", "phy", "net80211", "lwip", + "wpa", "main", "pp", "c", "gcc"] ) env.Replace(PLATFORMFW_DIR=PLATFORMFW_DIR) From 3fda4920383a9c0231b897b1c2c2c0803f8cd43a Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Fri, 10 Apr 2015 18:23:21 +0300 Subject: [PATCH 34/38] Return to esptool-mk uploader. --- platformio/builder/scripts/espressif.py | 45 +++++++++++++------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index 310648ab..289f9955 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -5,9 +5,7 @@ Builder for Espressif MCUs """ -import os from os.path import join -from platform import system from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, DefaultEnvironment) @@ -69,38 +67,40 @@ env.Replace( SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', - UPLOADER=join("$PIOPACKAGES_DIR", "tool-esptool", "esptool.py"), + UPLOADER=join("$PIOPACKAGES_DIR", "tool-esptool", "esptool"), UPLOADERFLAGS=[ - "--port", "$UPLOAD_PORT", - "--baud", "$UPLOAD_SPEED", - "write_flash", - "0x00000", join("$BUILD_DIR", "firmware.elf-0x00000.bin"), - "0x40000", join("$BUILD_DIR", "firmware.elf-0x40000.bin") + "-vv", + "-cd", "none", + "-cb", "$UPLOAD_SPEED", + "-cp", "$UPLOAD_PORT", + "-ca", "0x00000", + "-cf", "${SOURCES[0]}", + "-ca", "0x40000", + "-cf", "${SOURCES[1]}" ], - UPLOADCMD='python $UPLOADER $UPLOADERFLAGS' + UPLOADCMD='$UPLOADER $UPLOADERFLAGS' ) env.Append( BUILDERS=dict( ElfToBin=Builder( action=" ".join([ - "python", "$UPLOADER", "elf2image", "$SOURCES" + "$UPLOADER", + "-eo", "$SOURCES", + "-bo", "${TARGETS[0]}", + "-bs", ".text", + "-bs", ".data", + "-bs", ".rodata", + "-bc", "-ec", + "-eo", "$SOURCES", + "-es", ".irom0.text", "${TARGETS[1]}", + "-ec", "-v" ]), suffix=".bin" ) ) ) -if system() == "Windows": - paths = [] - for path in os.environ['PATH'].split(";"): - if "python" in path.lower(): - paths.append(path) - - env.AppendENVPath( - "PATH", ";".join(paths) - ) - # # Configure SDK # @@ -133,7 +133,10 @@ target_elf = env.BuildFirmware() if "uploadlazy" in COMMAND_LINE_TARGETS: target_firm = join("$BUILD_DIR", "firmware.bin") else: - target_firm = env.ElfToBin(target_elf) + target_firm = env.ElfToBin( + [join("$BUILD_DIR", "firmware_00000"), + join("$BUILD_DIR", "firmware_40000")], target_elf) + # # Target: Print binary size From 52e5f7ac2e02fa850cfb6dbda1e131b002d6be35 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Fri, 10 Apr 2015 18:24:03 +0300 Subject: [PATCH 35/38] Add Quirkbot board. --- platformio/boards/misc.json | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/platformio/boards/misc.json b/platformio/boards/misc.json index 14d71cfa..b9f7dba6 100644 --- a/platformio/boards/misc.json +++ b/platformio/boards/misc.json @@ -493,5 +493,33 @@ }, "url": "http://www.bq.com/gb/products/zum.html", "vendor": "BQ" + }, + + "quirkbot": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DQUIRKBOT", + "f_cpu": "8000000L", + "mcu": "atmega32u4", + "variant" : "quirkbot", + "vid": "0xf055", + "pid": "0xf055", + "usb_product": "Quirkbot" + }, + "frameworks": ["arduino"], + "name": "Quirkbot", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "require_upload_port" : true, + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": true + }, + "url": "http://quirkbot.com", + "vendor": "Quirkbot" } } From 04b5aa7d865748fdae462ae1c0946e9250ec7faa Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 10 Apr 2015 21:33:20 +0300 Subject: [PATCH 36/38] Fix exceptions with auto-updates when isn't active Internet connection --- platformio/maintenance.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 4a8da390..87d673d4 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -10,12 +10,11 @@ from time import time import click -from platformio import __version__, app, telemetry +from platformio import __version__, app, exception, telemetry from platformio.commands.install import cli as cmd_install from platformio.commands.lib import lib_update as cmd_libraries_update from platformio.commands.update import cli as cli_update from platformio.commands.upgrade import get_latest_version -from platformio.exception import GetLatestVersionError, UpgraderFailed from platformio.libmanager import LibraryManager from platformio.platforms.base import PlatformFactory from platformio.util import get_home_dir, get_lib_dir @@ -24,9 +23,14 @@ from platformio.util import get_home_dir, get_lib_dir def on_platformio_start(ctx): telemetry.on_command(ctx) after_upgrade(ctx) - check_platformio_upgrade() - check_internal_updates(ctx, "platforms") - check_internal_updates(ctx, "libraries") + + try: + check_platformio_upgrade() + check_internal_updates(ctx, "platforms") + check_internal_updates(ctx, "libraries") + except (exception.GetLatestVersionError, exception.APIRequestError): + click.secho("Failed to check for PlatformIO upgrades. " + "Please check your Internet connection.", fg="red") def on_platformio_end(ctx, result): # pylint: disable=W0613 @@ -135,7 +139,7 @@ def after_upgrade(ctx): telemetry.on_event(category="Auto", action="Upgrade", label="%s > %s" % (last_version, __version__)) else: - raise UpgraderFailed() + raise exception.UpgraderFailed() click.echo("") @@ -148,12 +152,7 @@ def check_platformio_upgrade(): last_check['platformio_upgrade'] = int(time()) app.set_state_item("last_check", last_check) - try: - latest_version = get_latest_version() - except GetLatestVersionError: - click.secho("Failed to check for PlatformIO upgrades", fg="red") - return - + latest_version = get_latest_version() if (latest_version == __version__ or Upgrader.version_to_int(latest_version) < Upgrader.version_to_int(__version__)): From cdaaf592166e438d81433552c895a980f3d2b93c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 11 Apr 2015 19:49:18 +0300 Subject: [PATCH 37/38] Prepare for 1.4.0 release --- HISTORY.rst | 18 ++++++- docs/frameworks/arduino.rst | 50 ++++++++++++++++++ docs/platforms/atmelavr.rst | 20 +++++++ docs/platforms/creating_platform.rst | 12 +++++ docs/platforms/espressif.rst | 79 ++++++++++++++++++++++++++++ docs/platforms/index.rst | 1 + docs/platforms/teensy.rst | 7 +++ 7 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 docs/platforms/espressif.rst diff --git a/HISTORY.rst b/HISTORY.rst index cfbedee1..9bbcf11f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,15 +1,29 @@ Release History =============== -1.4.0 (2015-??-??) +1.4.0 (2015-04-11) ------------------ +* Added `espressif `_ + development platform with ESP01 board * Integrated PlatformIO with AppVeyor Windows based Continuous Integration system (`issue #149 `_) +* Added support for Teensy LC board to + `teensy `__ + platform * Added support for new Arduino based boards by *SparkFun, BQ, LightUp, - LowPowerLab, RedBearLab, TinyCircuits, WickedDevice* to + LowPowerLab, Quirkbot, RedBearLab, TinyCircuits, WickedDevice* to `atmelavr `__ platform +* Upgraded `Arduino Framework `__ to + 1.6.3 version (`issue #156 `_) +* Upgraded `Energia Framework `__ to + 0101E0015 version (`issue #146 `_) +* Upgraded `Arduino Framework with Teensy Core `_ to + 1.22 version (`issue #162 `_, + `issue #170 `_) +* Fixed exceptions with PlatformIO auto-updates when Internet connection isn't + active 1.3.0 (2015-03-27) diff --git a/docs/frameworks/arduino.rst b/docs/frameworks/arduino.rst index 360d656c..5804f7f7 100644 --- a/docs/frameworks/arduino.rst +++ b/docs/frameworks/arduino.rst @@ -22,6 +22,9 @@ Platforms * - :ref:`platform_atmelsam` - Atmel | SMART offers Flash- based ARM products based on the ARM Cortex-M0+, Cortex-M3 and Cortex-M4 architectures, ranging from 8KB to 2MB of Flash including a rich peripheral and feature mix. + * - :ref:`platform_espressif` + - Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications. + * - :ref:`platform_teensy` - Teensy is a complete USB-based microcontroller development system, in a very small footprint, capable of implementing many types of projects. All programming is done via the USB port. No special programmer is needed, only a standard "Mini-B" USB cable and a PC or Macintosh with a USB port. @@ -450,6 +453,26 @@ Engduino - 32 Kb - 2.5 Kb +Espressif +~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``esp01`` + - `Espressif ESP8266 board `_ + - ESP8266 + - 80 MHz + - 512 Kb + - 32 Kb + LightUp ~~~~~~~ @@ -600,6 +623,26 @@ PanStamp - 32 Kb - 4 Kb +Quirkbot +~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``quirkbot`` + - `Quirkbot `_ + - ATMEGA32U4 + - 8 MHz + - 32 Kb + - 2.5 Kb + RedBearLab ~~~~~~~~~~ @@ -846,6 +889,13 @@ Teensy - 256 Kb - 64 Kb + * - ``teensylc`` + - `Teensy LC `_ + - MKL26Z64 + - 48 MHz + - 64 Kb + - 8 Kb + TinyCircuits ~~~~~~~~~~~~ diff --git a/docs/platforms/atmelavr.rst b/docs/platforms/atmelavr.rst index 45605eaa..5cc1c84e 100644 --- a/docs/platforms/atmelavr.rst +++ b/docs/platforms/atmelavr.rst @@ -591,6 +591,26 @@ PanStamp - 32 Kb - 2 Kb +Quirkbot +~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``quirkbot`` + - `Quirkbot `_ + - ATMEGA32U4 + - 8 MHz + - 32 Kb + - 2.5 Kb + RedBearLab ~~~~~~~~~~ diff --git a/docs/platforms/creating_platform.rst b/docs/platforms/creating_platform.rst index 42555ffd..811a4038 100644 --- a/docs/platforms/creating_platform.rst +++ b/docs/platforms/creating_platform.rst @@ -45,6 +45,9 @@ Packages * - ``framework-arduinoavr`` - `Arduino Wiring-based Framework (AVR Core, 1.6) `_ + * - ``framework-arduinoespressif`` + - `Arduino Wiring-based Framework (ESP8266 Core) `_ + * - ``framework-arduinomsp430`` - `Arduino Wiring-based Framework (MSP430 Core) `_ @@ -75,12 +78,18 @@ Packages * - ``ldscripts`` - `Linker Scripts `_ + * - ``sdk-esp8266`` + - `ESP8266 SDK `_ + * - ``tool-avrdude`` - `AVRDUDE `_ * - ``tool-bossac`` - `BOSSA CLI `_ + * - ``tool-esptool`` + - `esptool-ck `_ + * - ``tool-lm4flash`` - `Flash Programmer `_ @@ -105,6 +114,9 @@ Packages * - ``toolchain-timsp430`` - `msp-gcc `_, `GDB `_ + * - ``toolchain-xtensa`` + - `xtensa-gcc `_, `GDB `_ + .. _platform_creating_manifest_file: Manifest File diff --git a/docs/platforms/espressif.rst b/docs/platforms/espressif.rst new file mode 100644 index 00000000..2e159da3 --- /dev/null +++ b/docs/platforms/espressif.rst @@ -0,0 +1,79 @@ +.. _platform_espressif: + +Platform ``espressif`` +====================== +Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications. + +For more detailed information please visit `vendor site `_. + +.. contents:: + +Packages +-------- + +.. list-table:: + :header-rows: 1 + + * - Name + - Contents + + * - ``ldscripts`` + - `Linker Scripts `_ + + * - ``sdk-esp8266`` + - `ESP8266 SDK `_ + + * - ``tool-esptool`` + - `esptool-ck `_ + + * - ``framework-arduinoespressif`` + - `Arduino Wiring-based Framework (ESP8266 Core) `_ + + * - ``toolchain-xtensa`` + - `xtensa-gcc `_, `GDB `_ + +.. warning:: + **Linux Users:** Don't forget to install "udev" rules file + `99-platformio-udev.rules `_ (an instruction is located in the file). + + + +Frameworks +---------- +.. list-table:: + :header-rows: 1 + + * - Name + - Description + + * - :ref:`framework_arduino` + - Arduino Framework allows writing cross-platform software to control devices attached to a wide range of Arduino boards to create all kinds of creative coding, interactive objects, spaces or physical experiences. + +Boards +------ + +.. note:: + * You can list pre-configured boards by :ref:`cmd_boards` command or + `PlatformIO Boards Explorer `_ + * For more detailed ``board`` information please scroll tables below by + horizontal. + +Espressif +~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``esp01`` + - `Espressif ESP8266 board `_ + - ESP8266 + - 80 MHz + - 512 Kb + - 32 Kb diff --git a/docs/platforms/index.rst b/docs/platforms/index.rst index 220c3a67..00ec1e6e 100644 --- a/docs/platforms/index.rst +++ b/docs/platforms/index.rst @@ -16,6 +16,7 @@ MCU, upload protocol or etc. Please use ``board`` option. atmelavr atmelsam + espressif freescalekinetis nordicnrf51 nxplpc diff --git a/docs/platforms/teensy.rst b/docs/platforms/teensy.rst index 88b2fc05..11d25e24 100644 --- a/docs/platforms/teensy.rst +++ b/docs/platforms/teensy.rst @@ -98,3 +98,10 @@ Teensy - 72 MHz - 256 Kb - 64 Kb + + * - ``teensylc`` + - `Teensy LC `_ + - MKL26Z64 + - 48 MHz + - 64 Kb + - 8 Kb From 7aba4274d34ca163435415eebdee6d2436fa3bd8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 11 Apr 2015 19:53:32 +0300 Subject: [PATCH 38/38] Version bump to 1.4.0 (issues #143, #144, #145, #146, #149, #156, #162, #170) --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index b78a8f83..76c10d5a 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (1, 4, "0.dev2") +VERSION = (1, 4, 0) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio"