From 4f8edb312be8064c16d4c5baebb5d9f129515010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Fekete?= Date: Tue, 3 Jan 2023 12:50:38 -0500 Subject: [PATCH] Add compilation to espressif (#5947) * Refactor GitHub actions and add ESP tests. * Add script for building all examples for ESP. * Fixes for ESP-IDF v5.0 * Consolidating Espressif files into a single include.am Co-authored-by: Andras Fekete --- .github/workflows/docker-Espressif.yml | 38 ++++++++++ .github/workflows/macos-check.yml | 28 ------- .github/workflows/os-check.yml | 73 +++++++++++++++++++ .github/workflows/ubuntu-check.yml | 26 ------- .github/workflows/windows-check.yml | 38 ---------- IDE/Espressif/ESP-IDF/compileAllExamples.sh | 14 ++++ .../wolfssl_client/main/wifi_connect.c | 4 +- .../wolfssl_server/main/wifi_connect.c | 4 +- IDE/Espressif/include.am | 7 ++ IDE/include.am | 3 +- 10 files changed, 137 insertions(+), 98 deletions(-) create mode 100644 .github/workflows/docker-Espressif.yml delete mode 100644 .github/workflows/macos-check.yml create mode 100644 .github/workflows/os-check.yml delete mode 100644 .github/workflows/ubuntu-check.yml delete mode 100644 .github/workflows/windows-check.yml create mode 100755 IDE/Espressif/ESP-IDF/compileAllExamples.sh create mode 100644 IDE/Espressif/include.am diff --git a/.github/workflows/docker-Espressif.yml b/.github/workflows/docker-Espressif.yml new file mode 100644 index 000000000..98d0e0ffd --- /dev/null +++ b/.github/workflows/docker-Espressif.yml @@ -0,0 +1,38 @@ +name: Test Espressif examples on various official Docker containers +concurrency: + group: ${{ github.ref }} + +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +jobs: + espressif_latest: + name: Test Espressif on latest Docker container + runs-on: ubuntu-latest + container: + image: espressif/idf:latest + steps: + - uses: actions/checkout@v3 + - name: Initialize Espressif IDE and build examples + run: . /opt/esp/idf/export.sh; IDE/Espressif/ESP-IDF/compileAllExamples.sh + espressif_v4_4: + name: Test Espressif on v4.4 Docker container + runs-on: ubuntu-latest + container: + image: espressif/idf:release-v4.4 + steps: + - uses: actions/checkout@v3 + - name: Initialize Espressif IDE and build examples + run: . /opt/esp/idf/export.sh; IDE/Espressif/ESP-IDF/compileAllExamples.sh + espressif_v5_0: + name: Test Espressif on v5.0 Docker container + runs-on: ubuntu-latest + container: + image: espressif/idf:release-v5.0 + steps: + - uses: actions/checkout@v3 + - name: Initialize Espressif IDE and build examples + run: . /opt/esp/idf/export.sh; IDE/Espressif/ESP-IDF/compileAllExamples.sh diff --git a/.github/workflows/macos-check.yml b/.github/workflows/macos-check.yml deleted file mode 100644 index 465add45b..000000000 --- a/.github/workflows/macos-check.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: macOS Build Test - -on: - push: - branches: [ '*' ] - pull_request: - branches: [ '*' ] - -jobs: - build: - - runs-on: macos-latest - - steps: - - uses: actions/checkout@v2 - - name: brew - run: brew install automake libtool - - name: autogen - run: ./autogen.sh - - name: configure - run: ./configure - - name: make - run: make - - name: make check - run: make check - - name: make distcheck - run: make distcheck - diff --git a/.github/workflows/os-check.yml b/.github/workflows/os-check.yml new file mode 100644 index 000000000..d9cbec127 --- /dev/null +++ b/.github/workflows/os-check.yml @@ -0,0 +1,73 @@ +name: Test MacOS/Ubuntu/Windows compilation +concurrency: + group: ${{ github.ref }} + +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +jobs: + macos_build: + name: macOS Build Test + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: brew + run: brew install automake libtool + - name: autogen + run: ./autogen.sh + - name: configure + run: ./configure + - name: make + run: make + - name: make check + run: make check + - name: make distcheck + run: make distcheck + + ubuntu_build: + name: Ubuntu Build Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: autogen + run: ./autogen.sh + - name: configure + run: ./configure + - name: make + run: make + - name: make check + run: make check + - name: make distcheck + run: make distcheck + + windows_build: + name: Windows Build Test + runs-on: windows-latest + env: + # Path to the solution file relative to the root of the project. + SOLUTION_FILE_PATH: wolfssl64.sln + + # Configuration type to build. + # You can convert this to a build matrix if you need coverage of multiple configuration types. + # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + BUILD_CONFIGURATION: Release + BUILD_PLATFORM: x64 + steps: + - uses: actions/checkout@v2 + + - name: Add MSBuild to PATH + uses: microsoft/setup-msbuild@v1 + + - name: Restore NuGet packages + working-directory: ${{env.GITHUB_WORKSPACE}} + run: nuget restore ${{env.SOLUTION_FILE_PATH}} + + - name: Build + working-directory: ${{env.GITHUB_WORKSPACE}} + # Add additional options to the MSBuild command line here (like platform or verbosity level). + # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference + run: msbuild /m /p:PlatformToolset=v142 /p:Platform=${{env.BUILD_PLATFORM}} /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} + diff --git a/.github/workflows/ubuntu-check.yml b/.github/workflows/ubuntu-check.yml deleted file mode 100644 index c851a5849..000000000 --- a/.github/workflows/ubuntu-check.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Ubuntu Build Test - -on: - push: - branches: [ '*' ] - pull_request: - branches: [ '*' ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: autogen - run: ./autogen.sh - - name: configure - run: ./configure - - name: make - run: make - - name: make check - run: make check - - name: make distcheck - run: make distcheck - diff --git a/.github/workflows/windows-check.yml b/.github/workflows/windows-check.yml deleted file mode 100644 index 58d17fdeb..000000000 --- a/.github/workflows/windows-check.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Windows Build Test - -on: - push: - branches: [ '*' ] - pull_request: - branches: [ '*' ] - -env: - # Path to the solution file relative to the root of the project. - SOLUTION_FILE_PATH: wolfssl64.sln - - # Configuration type to build. - # You can convert this to a build matrix if you need coverage of multiple configuration types. - # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - BUILD_CONFIGURATION: Release - BUILD_PLATFORM: x64 - -jobs: - build: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v1 - - - name: Restore NuGet packages - working-directory: ${{env.GITHUB_WORKSPACE}} - run: nuget restore ${{env.SOLUTION_FILE_PATH}} - - - name: Build - working-directory: ${{env.GITHUB_WORKSPACE}} - # Add additional options to the MSBuild command line here (like platform or verbosity level). - # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference - run: msbuild /m /p:PlatformToolset=v142 /p:Platform=${{env.BUILD_PLATFORM}} /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} - diff --git a/IDE/Espressif/ESP-IDF/compileAllExamples.sh b/IDE/Espressif/ESP-IDF/compileAllExamples.sh new file mode 100755 index 000000000..4835f80f3 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/compileAllExamples.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Example usage: +# cd wolfssl && docker run --rm -v $PWD:/project -w /project espressif/idf:latest IDE/Espressif/ESP-IDF/compileAllExamples.sh + +SCRIPT_DIR=$(builtin cd ${BASH_SOURCE%/*}; pwd) +pushd ${SCRIPT_DIR} && ./setup.sh; popd +for file in "benchmark" "client" "server" "test"; do + cd ${IDF_PATH}/examples/protocols/wolfssl_${file}/ && idf.py build + if [ $? -ne 0 ]; then + echo "Failed in ${file}" + exit 1 + fi +done diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c index 27ae96333..dadaacca6 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c @@ -132,8 +132,8 @@ void app_main(void) ESP_ERROR_CHECK(nvs_flash_init()); ESP_LOGI(TAG, "Initialize wifi"); -#if (ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1) || \ - (ESP_IDF_VERSION_MAJOR > 5) +#if (ESP_IDF_VERSION_MAJOR == 4 && ESP_IDF_VERSION_MINOR >= 1) || \ + (ESP_IDF_VERSION_MAJOR >= 5) esp_netif_init(); #else tcpip_adapter_init(); diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c index f7cb1b4de..450677698 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c @@ -133,8 +133,8 @@ void app_main(void) ESP_LOGI(TAG, "Initialize wifi"); /* TCP/IP adapter initialization */ -#if (ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1) || \ - (ESP_IDF_VERSION_MAJOR > 5) +#if (ESP_IDF_VERSION_MAJOR == 4 && ESP_IDF_VERSION_MINOR >= 1) || \ + (ESP_IDF_VERSION_MAJOR >= 5) esp_netif_init(); #else tcpip_adapter_init(); diff --git a/IDE/Espressif/include.am b/IDE/Espressif/include.am new file mode 100644 index 000000000..fa101a884 --- /dev/null +++ b/IDE/Espressif/include.am @@ -0,0 +1,7 @@ +# vim:ft=automake +# included from Top Level Makefile.am +# All paths should be given relative to the root + +EXTRA_DIST+= IDE/Espressif/ESP-IDF/setup_win.bat +EXTRA_DIST+= IDE/Espressif/ESP-IDF/dummy_test_paths.h +EXTRA_DIST+= IDE/Espressif/ESP-IDF/compileAllExamples.sh diff --git a/IDE/include.am b/IDE/include.am index 6fbafa980..7c7166ade 100644 --- a/IDE/include.am +++ b/IDE/include.am @@ -50,8 +50,7 @@ include IDE/IAR-MSP430/include.am include IDE/zephyr/include.am include IDE/AURIX/include.am include IDE/MCUEXPRESSO/include.am +include IDE/Espressif/include.am EXTRA_DIST+= IDE/IAR-EWARM IDE/MDK-ARM IDE/MDK5-ARM IDE/MYSQL IDE/LPCXPRESSO IDE/HEXIWEAR IDE/Espressif EXTRA_DIST+= IDE/OPENSTM32/README.md -EXTRA_DIST+= IDE/Espressif/ESP-IDF/setup_win.bat -EXTRA_DIST+= IDE/Espressif/ESP-IDF/dummy_test_paths.h