diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..2330307 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,152 @@ +name: Continuous Integration for Machine Learning Applications +on: + push: + branches: + - main + - feature/* + tags: + - v* + pull_request: + branches: + - main + - feature/* + workflow_dispatch: + +permissions: + id-token: write + contents: read + +jobs: + generate-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v5 + + - name: Generate dynamic matrix from templates.xml + id: set-matrix + run: | + matrix=$(python3 .github/workflows/scripts/generate_matrix.py | jq -c .) + echo "matrix=$matrix" >> $GITHUB_OUTPUT + + get-sdk: + runs-on: ubuntu-latest + steps: + - name: Clone GSDK and ai-ml app + shell: bash + run: | + set -e + mkdir src + echo "==> Creating developer directories..." + cd src + echo "==> Cloning public GSDK" + git clone https://github.com/SiliconLabs/simplicity_sdk.git gsdk + cd gsdk + git checkout v2025.6.2 + mkdir extension + cd extension + git clone --recurse-submodules https://github.com/SiliconLabsSoftware/aiml-extension.git aiml-extension + cd aiml-extension + git checkout v2.1.2 + git submodule update --init --recursive + git lfs pull || true + + - name: Checkout machine_learning_applications (this repo) + uses: actions/checkout@v5 + with: + path: src/gsdk/extension/machine_learning_applications + + - name: Upload SDK + uses: actions/upload-artifact@v5 + with: + name: SDK + path: . + include-hidden-files: true + + get-tools: + runs-on: ubuntu-latest + steps: + - name: Download ARM-GNU and SLC toolchain + run: | + mkdir -p tools && cd tools + wget -q https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz + tar -xf arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz + mv arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi armgnu + rm arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz + wget -q https://www.silabs.com/documents/public/software/slc_cli_linux.zip + unzip -q slc_cli_linux.zip -d slc_cli + rm slc_cli_linux.zip + + - name: Upload Tools + uses: actions/upload-artifact@v5 + with: + name: ARM_GNU-and-slc-toolchain + path: . + include-hidden-files: true + + build-ml: + runs-on: ubuntu-latest + needs: [generate-matrix, get-sdk, get-tools] + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} + steps: + - name: Download GSDK + uses: actions/download-artifact@v5 + with: + name: SDK + path: . + + - name: Download ARM-GNU and SLC toolchain + uses: actions/download-artifact@v5 + with: + name: ARM_GNU-and-slc-toolchain + path: . + + - name: Install Java 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + check-latest: true + + - name: Configure SLC,ARM-GNU, JAVA paths + run: | + set -e + tree -L 3 + chmod -R +x ${{ github.workspace }}/tools/armgnu + echo "ARM_GCC_DIR=${{ github.workspace }}/tools/armgnu" >> "$GITHUB_ENV" + echo "${{ github.workspace }}/tools/armgnu/bin/" >> "$GITHUB_PATH" + + SLC_DIR="${{ github.workspace }}/tools/slc_cli/slc_cli/bin/slc-cli" + chmod +x "$SLC_DIR/slc-cli" + ln -sf "$SLC_DIR/slc-cli" "$SLC_DIR/slc" + echo "UC_CLI_DIR=$SLC_DIR" >> "$GITHUB_ENV" + echo "$SLC_DIR" >> "$GITHUB_PATH" + + echo "SLC_JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" + + - name: Trust sdk's + run: | + set -e + slc configuration --sdk "${{ github.workspace }}/src/gsdk" + slc signature trust --sdk "${{ github.workspace }}/src/gsdk" + slc signature trust --extension-path "${{ github.workspace }}/src/gsdk/extension/aiml-extension" + slc signature trust --extension-path "${{ github.workspace }}/src/gsdk/extension/machine_learning_applications" + + - name: Generate + Build + working-directory: ${{ github.workspace }}/src/gsdk/extension/machine_learning_applications + env: + APP: ${{ matrix.app }} + BOARD: ${{ matrix.board }} + run: | + set -e + echo "App: $APP" + echo "BOARD: $BOARD" + slc generate -d target/$APP/$BOARD -p $APP.slcp --with $BOARD -s "${{ github.workspace }}/src/gsdk" + cmake --preset project -S target/$APP/$BOARD/${APP##*/}_cmake + cmake --build target/$APP/$BOARD/${APP##*/}_cmake/build --parallel + echo "==> Listing generated .s37 files" + find ./target -name "*.s37" + diff --git a/.github/workflows/scripts/generate_matrix.py b/.github/workflows/scripts/generate_matrix.py new file mode 100644 index 0000000..0c8ea24 --- /dev/null +++ b/.github/workflows/scripts/generate_matrix.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +import os, json +from pathlib import Path +import xml.etree.ElementTree as ET + +ROOT = Path(__file__).resolve().parents[3] +TEMPLATES_XML = ROOT / "templates.xml" + +def get_prop(desc, key): + # + p = desc.find(f'properties[@key="{key}"]') + return (p.get("value") if p is not None else "").strip() + +def split_ws(s): + # boardCompatibility is space-separated: "brd2601a brd2601b" + return [x for x in s.replace(",", " ").split() if x] + +def main(): + tree = ET.parse(TEMPLATES_XML) + root = tree.getroot() + + rows = [] + for desc in root.findall("descriptors"): + app = get_prop(desc, "projectFilePaths").split(".")[0] # e.g. application/voice/.../series_2.slcp -> application/voice/.../series_2 + boards = split_ws(get_prop(desc, "boardCompatibility")) # e.g. ["brd2601a", "brd2601b"] + + for board in boards: + rows.append({ + "app": app, + "board": board + }) + + if not rows: + # Avoid empty matrix which makes Actions error out + rows = [{"app":"noop","board":"noop"}] + + matrix = {"include": rows} + print(json.dumps(matrix, indent=2)) + +if __name__ == "__main__": + main() diff --git a/application/imu/ble_magic_wand/ble_magic_wand.slcp b/application/imu/ble_magic_wand/ble_magic_wand.slcp index 04e186a..bb5a585 100644 --- a/application/imu/ble_magic_wand/ble_magic_wand.slcp +++ b/application/imu/ble_magic_wand/ble_magic_wand.slcp @@ -29,10 +29,14 @@ source: - path: magic_wand.cc - path: accelerometer.cc - path: bluetooth.c +sdk_extension: + - id: aiml + version: 2.1.2 component: - id: sl_system - id: device_init - id: tensorflow_lite_micro + from: aiml - id: imu_driver - id: iostream_recommended_stream - id: power_manager @@ -43,6 +47,7 @@ component: - id: gatt_configuration - id: bluetooth_feature_legacy_advertiser - id: bluetooth_feature_connection + - id: bluetooth_feature_connection_role_peripheral - id: bluetooth_feature_gatt_server - id: bluetooth_feature_legacy_scanner - id: bluetooth_feature_sm @@ -55,6 +60,17 @@ component: - id: printf - id: simple_button instance: [btn0] + - id: tensorflow_debug_log_iostream + from: aiml + - id: tensorflow_lite_micro_accelerated_kernels + from: aiml + condition: [device_has_mvp] + - id: tensorflow_lite_micro_optimized_kernels + from: aiml + condition: [device_has_mvp] + - id: tensorflow_lite_micro_optimized_kernels + from: aiml + condition: [device_compute_basic] define: - name: DEBUG_EFM - name: TF_LITE_STATIC_MEMORY diff --git a/application/vision/people_flow_counter_mlx90640/people_flow_counter_mlx90640.slcp b/application/vision/people_flow_counter_mlx90640/people_flow_counter_mlx90640.slcp index f79a81e..18c82ba 100644 --- a/application/vision/people_flow_counter_mlx90640/people_flow_counter_mlx90640.slcp +++ b/application/vision/people_flow_counter_mlx90640/people_flow_counter_mlx90640.slcp @@ -23,6 +23,8 @@ include: sdk_extension: - id: machine_learning_applications version: "1.0.0" + - id: aiml + version: 2.1.2 component: - id: sl_system - id: device_init @@ -32,6 +34,7 @@ component: - id: simple_led instance: [led0, led1] - id: iostream_recommended_stream + - id: cmsis_dsp - id: iostream_eusart instance: [vcom] - id: iostream_retarget_stdio @@ -40,8 +43,28 @@ component: - id: app_assert - id: app_log - id: device_init_dpll + - id: bluetooth_stack + - id: gatt_configuration + - id: bluetooth_feature_legacy_advertiser + - id: bluetooth_feature_connection + - id: bluetooth_feature_connection_role_peripheral + - id: bluetooth_feature_gatt_server + - id: bluetooth_feature_legacy_scanner + - id: bluetooth_feature_sm + - id: bluetooth_feature_system - id: tensorflow_lite_micro - - id: bt_fp_soc_default + from: aiml + - id: tensorflow_debug_log_iostream + from: aiml + - id: tensorflow_lite_micro_accelerated_kernels + from: aiml + condition: [device_has_mvp] + - id: tensorflow_lite_micro_optimized_kernels + from: aiml + condition: [device_has_mvp] + - id: tensorflow_lite_micro_optimized_kernels + from: aiml + condition: [device_compute_basic] - id: vision from: machine_learning_applications define: diff --git a/templates.xml b/templates.xml index a0334d0..6dc745f 100644 --- a/templates.xml +++ b/templates.xml @@ -13,20 +13,6 @@ - - - - - - - - - - - - - -