Selaa lähdekoodia

ci: Add freeRTOS CI build

Stefan Profanter 4 vuotta sitten
vanhempi
commit
c7ee50f797

+ 28 - 0
.azure-pipelines/azure-pipelines-linux.yml

@@ -0,0 +1,28 @@
+# Docs see here:
+# https://aka.ms/yaml
+
+jobs:
+- job: 'cross_freeRTOS'
+  displayName: 'Arch (freeRTOS)'
+  pool:
+    vmImage: 'ubuntu-18.04'
+  variables:
+    IDF_PATH: $(Build.BinariesDirectory)/esp-idf
+  steps:
+  - checkout: self
+    submodules: recursive
+
+  - task: Bash@3
+    inputs:
+      targetType: FilePath
+      filePath: ./tools/azure-devops/freeRTOS/install.sh
+      failOnStderr: false
+    displayName: Installing required packages
+
+  - task: Bash@3
+    inputs:
+      targetType: FilePath
+      filePath: ./tools/azure-devops/freeRTOS/build.sh
+      failOnStderr: false
+    displayName: Building & Testing
+

+ 25 - 0
tools/azure-devops/freeRTOS/CMakeLists.txt

@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 3.5)
+
+add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../../ ${CMAKE_BINARY_DIR}/lib)
+
+include($ENV{IDF_PATH}/tools/cmake/project.cmake)
+
+get_target_property(OPEN62541_SOURCES open62541-object SOURCES)
+get_target_property(OPEN62541_INCLUDES open62541-object INCLUDE_DIRECTORIES)
+
+# Create an open62541 component for ESP IDF
+set(open62541_component_dir ${CMAKE_CURRENT_LIST_DIR}/components/open62541-lib)
+file(MAKE_DIRECTORY ${open62541_component_dir})
+file(WRITE ${open62541_component_dir}/CMakeLists.txt "
+set(COMPONENT_SRCS ${OPEN62541_SOURCES})
+set(COMPONENT_ADD_INCLUDEDIRS ${OPEN62541_INCLUDES})
+set(COMPONENT_REQUIRES lwip mbedtls freertos)
+register_component()
+")
+
+add_definitions(-DUA_ARCHITECTURE_FREERTOSLWIP)
+
+project(hello-world)
+
+add_dependencies(open62541-lib open62541-code-generation)
+

+ 44 - 0
tools/azure-devops/freeRTOS/build.sh

@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+set -e
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+BASE_DIR="$( realpath "$DIR/../../../" )"
+
+echo "== freeRTOS Build =="
+
+# Add xtensa compiler to path
+export PATH=$PATH:$IDF_PATH/xtensa-esp32-elf/bin
+
+mkdir -p build_freertos && cd build_freertos
+
+CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Debug \
+    -DUA_ENABLE_AMALGAMATION=OFF \
+    -DCMAKE_TOOLCHAIN_FILE=${IDF_PATH}/tools/cmake/toolchain-esp32.cmake \
+    -DUA_ARCHITECTURE=freertosLWIP \
+    -DUA_BUILD_EXAMPLES=OFF"
+
+
+# We first need to call cmake separately to generate the required source code. Then we can call the freeRTOS CMake
+mkdir lib && cd lib
+cmake \
+    ${CMAKE_ARGS} \
+    ${BASE_DIR}
+if [ $? -ne 0 ] ; then exit 1 ; fi
+
+make -j open62541-code-generation
+if [ $? -ne 0 ] ; then exit 1 ; fi
+
+# Now call the freeRTOS CMake with same arguments
+cd ..
+
+cmake \
+    ${CMAKE_ARGS} \
+    ${BASE_DIR}/tools/azure-devops/freeRTOS/
+if [ $? -ne 0 ] ; then exit 1 ; fi
+
+# NOTE!!!
+# If you came here to see how to build your own version for the ESP32,
+# make sure to call `make menuconfig` first and configure the options.
+
+make hello-world.elf
+if [ $? -ne 0 ] ; then exit 1 ; fi

+ 6 - 0
tools/azure-devops/freeRTOS/components/main/CMakeLists.txt

@@ -0,0 +1,6 @@
+set(COMPONENT_REQUIRES open62541-lib )
+set(COMPONENT_PRIV_REQUIRES spi_flash )
+set(COMPONENT_SRCS hello_world_main.c)
+set(COMPONENT_ADD_INCLUDEDIRS "")
+
+register_component()

+ 40 - 0
tools/azure-devops/freeRTOS/components/main/hello_world_main.c

@@ -0,0 +1,40 @@
+/* Hello World Example
+
+   This example code is in the Public Domain (or CC0 licensed, at your option.)
+
+   Unless required by applicable law or agreed to in writing, this
+   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+   CONDITIONS OF ANY KIND, either express or implied.
+*/
+#include <stdio.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "esp_system.h"
+#include "esp_spi_flash.h"
+
+
+void app_main()
+{
+    printf("Hello world!\n");
+
+    /* Print chip information */
+    esp_chip_info_t chip_info;
+    esp_chip_info(&chip_info);
+    printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ",
+           chip_info.cores,
+           (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
+           (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
+
+    printf("silicon revision %d, ", chip_info.revision);
+
+    printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
+           (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
+
+    for (int i = 10; i >= 0; i--) {
+        printf("Restarting in %d seconds...\n", i);
+        vTaskDelay(1000 / portTICK_PERIOD_MS);
+    }
+    printf("Restarting now.\n");
+    fflush(stdout);
+    esp_restart();
+}

+ 16 - 0
tools/azure-devops/freeRTOS/install.sh

@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+set -e
+
+sudo apt-get update
+sudo apt install -y cmake python3-pip check libsubunit-dev wget tar git
+
+git clone -b v3.2.3 --recursive https://github.com/espressif/esp-idf.git $IDF_PATH
+cd $IDF_PATH
+python -m pip install wheel
+python -m pip install --user -r $IDF_PATH/requirements.txt
+
+# See https://docs.espressif.com/projects/esp-idf/en/stable/get-started/linux-setup.html#toolchain-setup
+wget -q https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
+tar -xf xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz -C $IDF_PATH
+rm xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz