From 6f9f4e43bcab5e2c995b0e5ae2fec1c43dac8513 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 22 Nov 2021 18:32:52 +0200 Subject: [PATCH 1/5] Convert README to markdown --- examples/arduino-blink/README.md | 27 ++++++++++++++++ examples/arduino-blink/README.rst | 38 ----------------------- examples/arduino-hid-usb-mouse/README.md | 21 +++++++++++++ examples/arduino-hid-usb-mouse/README.rst | 32 ------------------- examples/arduino-internal-libs/README.md | 27 ++++++++++++++++ examples/arduino-internal-libs/README.rst | 38 ----------------------- examples/mbed-blink/README.md | 21 +++++++++++++ examples/mbed-blink/README.rst | 32 ------------------- examples/mbed-dsp/README.md | 21 +++++++++++++ examples/mbed-dsp/README.rst | 32 ------------------- examples/mbed-events/README.md | 21 +++++++++++++ examples/mbed-events/README.rst | 32 ------------------- examples/mbed-serial/README.md | 21 +++++++++++++ examples/mbed-serial/README.rst | 32 ------------------- 14 files changed, 159 insertions(+), 236 deletions(-) create mode 100644 examples/arduino-blink/README.md delete mode 100644 examples/arduino-blink/README.rst create mode 100644 examples/arduino-hid-usb-mouse/README.md delete mode 100644 examples/arduino-hid-usb-mouse/README.rst create mode 100644 examples/arduino-internal-libs/README.md delete mode 100644 examples/arduino-internal-libs/README.rst create mode 100644 examples/mbed-blink/README.md delete mode 100644 examples/mbed-blink/README.rst create mode 100644 examples/mbed-dsp/README.md delete mode 100644 examples/mbed-dsp/README.rst create mode 100644 examples/mbed-events/README.md delete mode 100644 examples/mbed-events/README.rst create mode 100644 examples/mbed-serial/README.md delete mode 100644 examples/mbed-serial/README.rst diff --git a/examples/arduino-blink/README.md b/examples/arduino-blink/README.md new file mode 100644 index 0000000..23662d2 --- /dev/null +++ b/examples/arduino-blink/README.md @@ -0,0 +1,27 @@ +How to build PlatformIO based project +===================================== + +1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html) +2. Download [development platform with examples](https://github.com/platformio/platform-teensy/archive/develop.zip) +3. Extract ZIP archive +4. Run these commands: + +```shell +# Change directory to example +$ cd platform-teensy/examples/arduino-blink + +# Build project +$ pio run + +# Upload firmware +$ pio run --target upload + +# Build specific environment +$ pio run -e teensy31 + +# Upload firmware for the specific environment +$ pio run -e teensy31 --target upload + +# Clean build files +$ pio run --target clean +``` diff --git a/examples/arduino-blink/README.rst b/examples/arduino-blink/README.rst deleted file mode 100644 index e99e8ba..0000000 --- a/examples/arduino-blink/README.rst +++ /dev/null @@ -1,38 +0,0 @@ -.. Copyright 2014-present PlatformIO - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -How to build PlatformIO based project -===================================== - -1. `Install PlatformIO Core `_ -2. Download `development platform with examples `_ -3. Extract ZIP archive -4. Run these commands: - -.. code-block:: bash - - # Change directory to example - > cd platform-teensy/examples/arduino-blink - - # Build project - > platformio run - - # Upload firmware - > platformio run --target upload - - # Build specific environment - > platformio run -e teensy31 - - # Upload firmware for the specific environment - > platformio run -e teensy31 --target upload - - # Clean build files - > platformio run --target clean diff --git a/examples/arduino-hid-usb-mouse/README.md b/examples/arduino-hid-usb-mouse/README.md new file mode 100644 index 0000000..250a0be --- /dev/null +++ b/examples/arduino-hid-usb-mouse/README.md @@ -0,0 +1,21 @@ +How to build PlatformIO based project +===================================== + +1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html) +2. Download [development platform with examples](https://github.com/platformio/platform-teensy/archive/develop.zip) +3. Extract ZIP archive +4. Run these commands: + +```shell +# Change directory to example +$ cd platform-teensy/examples/arduino-hid-usb-mouse + +# Build project +$ pio run + +# Upload firmware +$ pio run --target upload + +# Clean build files +$ pio run --target clean +``` diff --git a/examples/arduino-hid-usb-mouse/README.rst b/examples/arduino-hid-usb-mouse/README.rst deleted file mode 100644 index 0875f82..0000000 --- a/examples/arduino-hid-usb-mouse/README.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. Copyright 2014-present PlatformIO - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -How to build PlatformIO based project -===================================== - -1. `Install PlatformIO Core `_ -2. Download `development platform with examples `_ -3. Extract ZIP archive -4. Run these commands: - -.. code-block:: bash - - # Change directory to example - > cd platform-teensy/examples/arduino-hid-usb-mouse - - # Build project - > platformio run - - # Upload firmware - > platformio run --target upload - - # Clean build files - > platformio run --target clean diff --git a/examples/arduino-internal-libs/README.md b/examples/arduino-internal-libs/README.md new file mode 100644 index 0000000..1e488ee --- /dev/null +++ b/examples/arduino-internal-libs/README.md @@ -0,0 +1,27 @@ +How to build PlatformIO based project +===================================== + +1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html) +2. Download [development platform with examples](https://github.com/platformio/platform-teensy/archive/develop.zip) +3. Extract ZIP archive +4. Run these commands: + +```shell +# Change directory to example +$ cd platform-teensy/examples/arduino-internal-libs + +# Build project +$ pio run + +# Upload firmware +$ pio run --target upload + +# Build specific environment +$ pio run -e teensy31 + +# Upload firmware for the specific environment +$ pio run -e teensy31 --target upload + +# Clean build files +$ pio run --target clean +``` diff --git a/examples/arduino-internal-libs/README.rst b/examples/arduino-internal-libs/README.rst deleted file mode 100644 index 6fb49ab..0000000 --- a/examples/arduino-internal-libs/README.rst +++ /dev/null @@ -1,38 +0,0 @@ -.. Copyright 2014-present PlatformIO - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -How to build PlatformIO based project -===================================== - -1. `Install PlatformIO Core `_ -2. Download `development platform with examples `_ -3. Extract ZIP archive -4. Run these commands: - -.. code-block:: bash - - # Change directory to example - > cd platform-teensy/examples/arduino-internal-libs - - # Build project - > platformio run - - # Upload firmware - > platformio run --target upload - - # Build specific environment - > platformio run -e teensy31 - - # Upload firmware for the specific environment - > platformio run -e teensy31 --target upload - - # Clean build files - > platformio run --target clean diff --git a/examples/mbed-blink/README.md b/examples/mbed-blink/README.md new file mode 100644 index 0000000..5c66478 --- /dev/null +++ b/examples/mbed-blink/README.md @@ -0,0 +1,21 @@ +How to build PlatformIO based project +===================================== + +1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html) +2. Download [development platform with examples](https://github.com/platformio/platform-teensy/archive/develop.zip) +3. Extract ZIP archive +4. Run these commands: + +```shell +# Change directory to example +$ cd platform-teensy/examples/mbed-blink + +# Build project +$ pio run + +# Upload firmware +$ pio run --target upload + +# Clean build files +$ pio run --target clean +``` diff --git a/examples/mbed-blink/README.rst b/examples/mbed-blink/README.rst deleted file mode 100644 index 3b50dc5..0000000 --- a/examples/mbed-blink/README.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. Copyright 2014-present PlatformIO - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -How to build PlatformIO based project -===================================== - -1. `Install PlatformIO Core `_ -2. Download `development platform with examples `_ -3. Extract ZIP archive -4. Run these commands: - -.. code-block:: bash - - # Change directory to example - > cd platform-teensy/examples/mbed-blink - - # Build project - > platformio run - - # Upload firmware - > platformio run --target upload - - # Clean build files - > platformio run --target clean diff --git a/examples/mbed-dsp/README.md b/examples/mbed-dsp/README.md new file mode 100644 index 0000000..cef0493 --- /dev/null +++ b/examples/mbed-dsp/README.md @@ -0,0 +1,21 @@ +How to build PlatformIO based project +===================================== + +1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html) +2. Download [development platform with examples](https://github.com/platformio/platform-teensy/archive/develop.zip) +3. Extract ZIP archive +4. Run these commands: + +```shell +# Change directory to example +$ cd platform-teensy/examples/mbed-dsp + +# Build project +$ pio run + +# Upload firmware +$ pio run --target upload + +# Clean build files +$ pio run --target clean +``` diff --git a/examples/mbed-dsp/README.rst b/examples/mbed-dsp/README.rst deleted file mode 100644 index c2d1dcd..0000000 --- a/examples/mbed-dsp/README.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. Copyright 2014-present PlatformIO - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -How to build PlatformIO based project -===================================== - -1. `Install PlatformIO Core `_ -2. Download `development platform with examples `_ -3. Extract ZIP archive -4. Run these commands: - -.. code-block:: bash - - # Change directory to example - > cd platform-teensy/examples/mbed-dsp - - # Build project - > platformio run - - # Upload firmware - > platformio run --target upload - - # Clean build files - > platformio run --target clean diff --git a/examples/mbed-events/README.md b/examples/mbed-events/README.md new file mode 100644 index 0000000..e3cf941 --- /dev/null +++ b/examples/mbed-events/README.md @@ -0,0 +1,21 @@ +How to build PlatformIO based project +===================================== + +1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html) +2. Download [development platform with examples](https://github.com/platformio/platform-teensy/archive/develop.zip) +3. Extract ZIP archive +4. Run these commands: + +```shell +# Change directory to example +$ cd platform-teensy/examples/mbed-events + +# Build project +$ pio run + +# Upload firmware +$ pio run --target upload + +# Clean build files +$ pio run --target clean +``` diff --git a/examples/mbed-events/README.rst b/examples/mbed-events/README.rst deleted file mode 100644 index f8f2bba..0000000 --- a/examples/mbed-events/README.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. Copyright 2014-present PlatformIO - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -How to build PlatformIO based project -===================================== - -1. `Install PlatformIO Core `_ -2. Download `development platform with examples `_ -3. Extract ZIP archive -4. Run these commands: - -.. code-block:: bash - - # Change directory to example - > cd platform-teensy/examples/mbed-events - - # Build project - > platformio run - - # Upload firmware - > platformio run --target upload - - # Clean build files - > platformio run --target clean diff --git a/examples/mbed-serial/README.md b/examples/mbed-serial/README.md new file mode 100644 index 0000000..ae2c200 --- /dev/null +++ b/examples/mbed-serial/README.md @@ -0,0 +1,21 @@ +How to build PlatformIO based project +===================================== + +1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html) +2. Download [development platform with examples](https://github.com/platformio/platform-teensy/archive/develop.zip) +3. Extract ZIP archive +4. Run these commands: + +```shell +# Change directory to example +$ cd platform-teensy/examples/mbed-serial + +# Build project +$ pio run + +# Upload firmware +$ pio run --target upload + +# Clean build files +$ pio run --target clean +``` diff --git a/examples/mbed-serial/README.rst b/examples/mbed-serial/README.rst deleted file mode 100644 index 5bc61c5..0000000 --- a/examples/mbed-serial/README.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. Copyright 2014-present PlatformIO - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -How to build PlatformIO based project -===================================== - -1. `Install PlatformIO Core `_ -2. Download `development platform with examples `_ -3. Extract ZIP archive -4. Run these commands: - -.. code-block:: bash - - # Change directory to example - > cd platform-teensy/examples/mbed-serial - - # Build project - > platformio run - - # Upload firmware - > platformio run --target upload - - # Clean build files - > platformio run --target clean From 2f3c423061e44322fc051f8f85657fb0657889fb Mon Sep 17 00:00:00 2001 From: valeros Date: Wed, 22 Dec 2021 16:38:23 +0200 Subject: [PATCH 2/5] Exclude irrelevant source file from teeny4 Arduino core // Resolve #82 --- builder/frameworks/arduino.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 40a7965..5952afb 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -344,7 +344,8 @@ libs.append(env.BuildLibrary( join("$BUILD_DIR", "FrameworkArduino"), - join(FRAMEWORK_DIR, "cores", BUILD_CORE) + join(FRAMEWORK_DIR, "cores", BUILD_CORE), + src_filter="+<*> -" )) env.Prepend(LIBS=libs) From acbb405f5deee58ac444f5b1d1d7bfa951110adb Mon Sep 17 00:00:00 2001 From: valeros Date: Mon, 27 Dec 2021 12:13:15 +0200 Subject: [PATCH 3/5] Update Teensyduino to v1.56 // Resolve #84 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index c896f19..3953efd 100644 --- a/platform.json +++ b/platform.json @@ -48,7 +48,7 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~1.155.0" + "version": "~1.156.0" }, "framework-mbed": { "type": "framework", From 01fe964d4e7a1bd22da64fc29f9992bc7c703644 Mon Sep 17 00:00:00 2001 From: Benjamin Jensrud Date: Fri, 14 Jan 2022 05:46:48 -0500 Subject: [PATCH 4/5] Implement Zephyr support for Teensy (#83) Co-authored-by: Valerii Koval --- .github/workflows/examples.yml | 2 + boards/teensy40.json | 8 +- boards/teensy41.json | 8 +- builder/frameworks/zephyr.py | 29 +++++ builder/main.py | 7 ++ examples/zephyr-blink/.gitignore | 1 + examples/zephyr-blink/.travis.yml | 67 ++++++++++ examples/zephyr-blink/README.md | 32 +++++ examples/zephyr-blink/include/README | 39 ++++++ examples/zephyr-blink/lib/README | 46 +++++++ examples/zephyr-blink/platformio.ini | 18 +++ examples/zephyr-blink/src/main.c | 51 ++++++++ examples/zephyr-blink/test/README | 11 ++ examples/zephyr-blink/zephyr/CMakeLists.txt | 7 ++ examples/zephyr-blink/zephyr/prj.conf | 2 + examples/zephyr-synchronization/.gitignore | 1 + examples/zephyr-synchronization/.travis.yml | 67 ++++++++++ examples/zephyr-synchronization/README.md | 32 +++++ .../zephyr-synchronization/include/README | 39 ++++++ examples/zephyr-synchronization/lib/README | 46 +++++++ .../zephyr-synchronization/platformio.ini | 18 +++ examples/zephyr-synchronization/src/main.c | 115 ++++++++++++++++++ examples/zephyr-synchronization/test/README | 11 ++ .../zephyr/CMakeLists.txt | 8 ++ .../zephyr-synchronization/zephyr/prj.conf | 3 + platform.json | 30 +++++ platform.py | 8 ++ 27 files changed, 702 insertions(+), 4 deletions(-) create mode 100644 builder/frameworks/zephyr.py create mode 100644 examples/zephyr-blink/.gitignore create mode 100644 examples/zephyr-blink/.travis.yml create mode 100644 examples/zephyr-blink/README.md create mode 100644 examples/zephyr-blink/include/README create mode 100644 examples/zephyr-blink/lib/README create mode 100644 examples/zephyr-blink/platformio.ini create mode 100644 examples/zephyr-blink/src/main.c create mode 100644 examples/zephyr-blink/test/README create mode 100644 examples/zephyr-blink/zephyr/CMakeLists.txt create mode 100644 examples/zephyr-blink/zephyr/prj.conf create mode 100644 examples/zephyr-synchronization/.gitignore create mode 100644 examples/zephyr-synchronization/.travis.yml create mode 100644 examples/zephyr-synchronization/README.md create mode 100644 examples/zephyr-synchronization/include/README create mode 100644 examples/zephyr-synchronization/lib/README create mode 100644 examples/zephyr-synchronization/platformio.ini create mode 100644 examples/zephyr-synchronization/src/main.c create mode 100644 examples/zephyr-synchronization/test/README create mode 100644 examples/zephyr-synchronization/zephyr/CMakeLists.txt create mode 100644 examples/zephyr-synchronization/zephyr/prj.conf diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index af3c30b..99a2fd0 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -16,6 +16,8 @@ jobs: - "examples/mbed-blink" - "examples/mbed-dsp" - "examples/mbed-serial" + - "examples/zephyr-blink" + - "examples/zephyr-synchronization" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 diff --git a/boards/teensy40.json b/boards/teensy40.json index e0f034b..d8fc57b 100644 --- a/boards/teensy40.json +++ b/boards/teensy40.json @@ -7,7 +7,10 @@ "cpu": "cortex-m7", "extra_flags": "-D__IMXRT1062__ -DARDUINO_TEENSY40", "f_cpu": "600000000", - "mcu": "imxrt1062" + "mcu": "imxrt1062", + "zephyr": { + "variant": "teensy40" + } }, "connectivity": [ "can" @@ -16,7 +19,8 @@ "jlink_device": "MIMXRT1062xxxxA" }, "frameworks": [ - "arduino" + "arduino", + "zephyr" ], "name": "Teensy 4.0", "upload": { diff --git a/boards/teensy41.json b/boards/teensy41.json index f403c8a..7fbb3f1 100644 --- a/boards/teensy41.json +++ b/boards/teensy41.json @@ -7,7 +7,10 @@ "cpu": "cortex-m7", "extra_flags": "-D__IMXRT1062__ -DARDUINO_TEENSY41", "f_cpu": "600000000", - "mcu": "imxrt1062" + "mcu": "imxrt1062", + "zephyr": { + "variant": "teensy41" + } }, "connectivity": [ "can" @@ -16,7 +19,8 @@ "jlink_device": "MIMXRT1062xxxxA" }, "frameworks": [ - "arduino" + "arduino", + "zephyr" ], "name": "Teensy 4.1", "upload": { diff --git a/builder/frameworks/zephyr.py b/builder/frameworks/zephyr.py new file mode 100644 index 0000000..fc26c29 --- /dev/null +++ b/builder/frameworks/zephyr.py @@ -0,0 +1,29 @@ +# Copyright 2019-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +The Zephyr Project is a scalable real-time operating system (RTOS) supporting multiple +hardware architectures, optimized for resource constrained devices, and built with +safety and security in mind. +https://github.com/zephyrproject-rtos/zephyr +""" + +from os.path import join + +from SCons.Script import Import, SConscript + +Import("env") + +SConscript( + join(env.PioPlatform().get_package_dir("framework-zephyr"), "scripts", + "platformio", "platformio-build.py"), exports="env") \ No newline at end of file diff --git a/builder/main.py b/builder/main.py index 230d079..9ff6490 100644 --- a/builder/main.py +++ b/builder/main.py @@ -147,6 +147,13 @@ # Target: Build executable and linkable firmware # +if "zephyr" in env.get("PIOFRAMEWORK", []): + env.SConscript( + join(platform.get_package_dir( + "framework-zephyr"), "scripts", "platformio", "platformio-build-pre.py"), + exports={"env": env} + ) + target_elf = None if "nobuild" in COMMAND_LINE_TARGETS: target_elf = join("$BUILD_DIR", "${PROGNAME}.elf") diff --git a/examples/zephyr-blink/.gitignore b/examples/zephyr-blink/.gitignore new file mode 100644 index 0000000..aeaebb2 --- /dev/null +++ b/examples/zephyr-blink/.gitignore @@ -0,0 +1 @@ +.pio \ No newline at end of file diff --git a/examples/zephyr-blink/.travis.yml b/examples/zephyr-blink/.travis.yml new file mode 100644 index 0000000..7c486f1 --- /dev/null +++ b/examples/zephyr-blink/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/zephyr-blink/README.md b/examples/zephyr-blink/README.md new file mode 100644 index 0000000..c1cc31d --- /dev/null +++ b/examples/zephyr-blink/README.md @@ -0,0 +1,32 @@ +.. Copyright 2020-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html) +2. Download [development platform with examples](https://github.com/platformio/platform-teensy/archive/develop.zip) +3. Extract ZIP archive +4. Run these commands: + +```shell +# Change directory to example +$ cd platform-teensy/examples/zephyr-blink + +# Build project +$ pio run + +# Upload firmware +$ pio run --target upload + +# Clean build files +$ pio run --target clean +``` diff --git a/examples/zephyr-blink/include/README b/examples/zephyr-blink/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/examples/zephyr-blink/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/zephyr-blink/lib/README b/examples/zephyr-blink/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/examples/zephyr-blink/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/zephyr-blink/platformio.ini b/examples/zephyr-blink/platformio.ini new file mode 100644 index 0000000..0eea112 --- /dev/null +++ b/examples/zephyr-blink/platformio.ini @@ -0,0 +1,18 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:teensy40] +platform = teensy +framework = zephyr +board = teensy40 + +[env:teensy41] +platform = teensy +framework = zephyr +board = teensy41 diff --git a/examples/zephyr-blink/src/main.c b/examples/zephyr-blink/src/main.c new file mode 100644 index 0000000..e2fbfd3 --- /dev/null +++ b/examples/zephyr-blink/src/main.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +/* 1000 msec = 1 sec */ +#define SLEEP_TIME_MS 1000 + +/* The devicetree node identifier for the "led0" alias. */ +#define LED0_NODE DT_ALIAS(led0) + +#if DT_NODE_HAS_STATUS(LED0_NODE, okay) +#define LED0 DT_GPIO_LABEL(LED0_NODE, gpios) +#define PIN DT_GPIO_PIN(LED0_NODE, gpios) +#define FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios) +#else +/* A build error here means your board isn't set up to blink an LED. */ +#error "Unsupported board: led0 devicetree alias is not defined" +#define LED0 "" +#define PIN 0 +#define FLAGS 0 +#endif + +void main(void) +{ + const struct device *dev; + bool led_is_on = true; + int ret; + + dev = device_get_binding(LED0); + if (dev == NULL) { + return; + } + + ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS); + if (ret < 0) { + return; + } + + while (1) { + gpio_pin_set(dev, PIN, (int)led_is_on); + led_is_on = !led_is_on; + k_msleep(SLEEP_TIME_MS); + } +} diff --git a/examples/zephyr-blink/test/README b/examples/zephyr-blink/test/README new file mode 100644 index 0000000..df5066e --- /dev/null +++ b/examples/zephyr-blink/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/zephyr-blink/zephyr/CMakeLists.txt b/examples/zephyr-blink/zephyr/CMakeLists.txt new file mode 100644 index 0000000..dce8623 --- /dev/null +++ b/examples/zephyr-blink/zephyr/CMakeLists.txt @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.13.1) +include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) +project(blinky) + +target_sources(app PRIVATE ../src/main.c) diff --git a/examples/zephyr-blink/zephyr/prj.conf b/examples/zephyr-blink/zephyr/prj.conf new file mode 100644 index 0000000..7bbd5af --- /dev/null +++ b/examples/zephyr-blink/zephyr/prj.conf @@ -0,0 +1,2 @@ +CONFIG_GPIO=y +CONFIG_SERIAL=n diff --git a/examples/zephyr-synchronization/.gitignore b/examples/zephyr-synchronization/.gitignore new file mode 100644 index 0000000..aeaebb2 --- /dev/null +++ b/examples/zephyr-synchronization/.gitignore @@ -0,0 +1 @@ +.pio \ No newline at end of file diff --git a/examples/zephyr-synchronization/.travis.yml b/examples/zephyr-synchronization/.travis.yml new file mode 100644 index 0000000..7c486f1 --- /dev/null +++ b/examples/zephyr-synchronization/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/zephyr-synchronization/README.md b/examples/zephyr-synchronization/README.md new file mode 100644 index 0000000..e2a8e63 --- /dev/null +++ b/examples/zephyr-synchronization/README.md @@ -0,0 +1,32 @@ +.. Copyright 2020-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html) +2. Download [development platform with examples](https://github.com/platformio/platform-teensy/archive/develop.zip) +3. Extract ZIP archive +4. Run these commands: + +```shell +# Change directory to example +$ cd platform-teensy/examples/zephyr-synchronization + +# Build project +$ pio run + +# Upload firmware +$ pio run --target upload + +# Clean build files +$ pio run --target clean +``` diff --git a/examples/zephyr-synchronization/include/README b/examples/zephyr-synchronization/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/examples/zephyr-synchronization/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/zephyr-synchronization/lib/README b/examples/zephyr-synchronization/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/examples/zephyr-synchronization/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/zephyr-synchronization/platformio.ini b/examples/zephyr-synchronization/platformio.ini new file mode 100644 index 0000000..0eea112 --- /dev/null +++ b/examples/zephyr-synchronization/platformio.ini @@ -0,0 +1,18 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:teensy40] +platform = teensy +framework = zephyr +board = teensy40 + +[env:teensy41] +platform = teensy +framework = zephyr +board = teensy41 diff --git a/examples/zephyr-synchronization/src/main.c b/examples/zephyr-synchronization/src/main.c new file mode 100644 index 0000000..fb60a2e --- /dev/null +++ b/examples/zephyr-synchronization/src/main.c @@ -0,0 +1,115 @@ +/* main.c - Hello World demo */ + +/* + * Copyright (c) 2012-2014 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +/* + * The hello world demo has two threads that utilize semaphores and sleeping + * to take turns printing a greeting message at a controlled rate. The demo + * shows both the static and dynamic approaches for spawning a thread; a real + * world application would likely use the static approach for both threads. + */ + + +/* size of stack area used by each thread */ +#define STACKSIZE 1024 + +/* scheduling priority used by each thread */ +#define PRIORITY 7 + +/* delay between greetings (in ms) */ +#define SLEEPTIME 500 + + +/* + * @param my_name thread identification string + * @param my_sem thread's own semaphore + * @param other_sem other thread's semaphore + */ +void helloLoop(const char *my_name, + struct k_sem *my_sem, struct k_sem *other_sem) +{ + const char *tname; + uint8_t cpu; + struct k_thread *current_thread; + + while (1) { + /* take my semaphore */ + k_sem_take(my_sem, K_FOREVER); + + current_thread = k_current_get(); + tname = k_thread_name_get(current_thread); +#if CONFIG_SMP + cpu = arch_curr_cpu()->id; +#else + cpu = 0; +#endif + /* say "hello" */ + if (tname == NULL) { + printk("%s: Hello World from cpu %d on %s!\n", + my_name, cpu, CONFIG_BOARD); + } else { + printk("%s: Hello World from cpu %d on %s!\n", + tname, cpu, CONFIG_BOARD); + } + + /* wait a while, then let other thread have a turn */ + k_busy_wait(100000); + k_msleep(SLEEPTIME); + k_sem_give(other_sem); + } +} + +/* define semaphores */ + +K_SEM_DEFINE(threadA_sem, 1, 1); /* starts off "available" */ +K_SEM_DEFINE(threadB_sem, 0, 1); /* starts off "not available" */ + + +/* threadB is a dynamic thread that is spawned by threadA */ + +void threadB(void *dummy1, void *dummy2, void *dummy3) +{ + ARG_UNUSED(dummy1); + ARG_UNUSED(dummy2); + ARG_UNUSED(dummy3); + + /* invoke routine to ping-pong hello messages with threadA */ + helloLoop(__func__, &threadB_sem, &threadA_sem); +} + +K_THREAD_STACK_DEFINE(threadB_stack_area, STACKSIZE); +static struct k_thread threadB_data; + +/* threadA is a static thread that is spawned automatically */ + +void threadA(void *dummy1, void *dummy2, void *dummy3) +{ + ARG_UNUSED(dummy1); + ARG_UNUSED(dummy2); + ARG_UNUSED(dummy3); + + /* spawn threadB */ + k_tid_t tid = k_thread_create(&threadB_data, threadB_stack_area, + STACKSIZE, threadB, NULL, NULL, NULL, + PRIORITY, 0, K_FOREVER); + + k_thread_name_set(tid, "thread_b"); +#if CONFIG_SCHED_CPU_MASK + k_thread_cpu_mask_disable(&threadB_data, 1); + k_thread_cpu_mask_enable(&threadB_data, 0); +#endif + k_thread_start(&threadB_data); + + /* invoke routine to ping-pong hello messages with threadB */ + helloLoop(__func__, &threadA_sem, &threadB_sem); +} + +K_THREAD_DEFINE(thread_a, STACKSIZE, threadA, NULL, NULL, NULL, + PRIORITY, 0, 0); diff --git a/examples/zephyr-synchronization/test/README b/examples/zephyr-synchronization/test/README new file mode 100644 index 0000000..df5066e --- /dev/null +++ b/examples/zephyr-synchronization/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/zephyr-synchronization/zephyr/CMakeLists.txt b/examples/zephyr-synchronization/zephyr/CMakeLists.txt new file mode 100644 index 0000000..cac493b --- /dev/null +++ b/examples/zephyr-synchronization/zephyr/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.13.1) + +include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) +project(synchronization) + +target_sources(app PRIVATE ../src/main.c) diff --git a/examples/zephyr-synchronization/zephyr/prj.conf b/examples/zephyr-synchronization/zephyr/prj.conf new file mode 100644 index 0000000..f31f3e0 --- /dev/null +++ b/examples/zephyr-synchronization/zephyr/prj.conf @@ -0,0 +1,3 @@ +CONFIG_STDOUT_CONSOLE=y +# enable to use thread names +CONFIG_THREAD_NAME=y diff --git a/platform.json b/platform.json index 3953efd..bf09c84 100644 --- a/platform.json +++ b/platform.json @@ -28,6 +28,10 @@ "mbed": { "package": "framework-mbed", "script": "builder/frameworks/mbed.py" + }, + "zephyr": { + "package": "framework-zephyr", + "script": "builder/frameworks/zephyr.py" } }, "packages": { @@ -56,6 +60,12 @@ "owner": "platformio", "version": "~6.51506.0" }, + "framework-zephyr": { + "type": "framework", + "optional": true, + "owner": "platformio", + "version": "~2.20701.0" + }, "tool-teensy": { "type": "uploader", "optional": true, @@ -67,6 +77,26 @@ "optional": true, "owner": "platformio", "version": "^1.63208.0" + }, + "tool-cmake": { + "optional": true, + "owner": "platformio", + "version": "~3.21.0" + }, + "tool-dtc": { + "optional": true, + "owner": "platformio", + "version": "~1.4.7" + }, + "tool-ninja": { + "optional": true, + "owner": "platformio", + "version": "^1.7.0" + }, + "tool-gperf": { + "optional": true, + "owner": "platformio", + "version": "^3.0.0" } } } diff --git a/platform.py b/platform.py index 26b897a..1f1f0f1 100644 --- a/platform.py +++ b/platform.py @@ -16,6 +16,7 @@ import platform from platformio.managers.platform import PlatformBase +from platformio.util import get_systype class TeensyPlatform(PlatformBase): @@ -33,6 +34,13 @@ def configure_default_packages(self, variables, targets): if "mbed" in frameworks: self.packages["toolchain-gccarmnoneeabi"][ "version"] = ">=1.60301.0,<1.80000.0" + elif "zephyr" in frameworks: + for p in self.packages: + if p in ("tool-cmake", "tool-dtc", "tool-ninja"): + self.packages[p]["optional"] = False + if "windows" not in get_systype(): + self.packages["tool-gperf"]["optional"] = False + self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.80201.0" elif "arduino" in frameworks and board_config.get("build.core", "") == "teensy4": self.packages["tool-teensy"]["optional"] = False From 17c281303e78d651ea93de71df4ca76056c06e3a Mon Sep 17 00:00:00 2001 From: Valerii Koval Date: Fri, 28 Jan 2022 13:01:36 +0200 Subject: [PATCH 5/5] Bump version to 4.15.0 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index bf09c84..a987f78 100644 --- a/platform.json +++ b/platform.json @@ -19,7 +19,7 @@ "type": "git", "url": "https://github.com/platformio/platform-teensy.git" }, - "version": "4.14.0", + "version": "4.15.0", "frameworks": { "arduino": { "package": "framework-arduinoteensy",