From b06239f84fd27bfa08bcb826ad071e80fa8e3cc2 Mon Sep 17 00:00:00 2001 From: liquidraver <504870+liquidraver@users.noreply.github.com> Date: Tue, 2 Jun 2026 21:30:24 +0200 Subject: [PATCH] build linux executables too --- .github/workflows/build.yml | 49 +++++++++++++++++++++++++++++++++- build.sh | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac6ef55..2e341d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -133,6 +133,48 @@ jobs: path: firmware key: cache-firmware-esp32-repeaters-${{ github.sha }} + build-linux: + needs: setup-zephyr + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-python@v6 + with: + python-version: '${{ env.python_version }}' + cache: 'pip' + - run: pip install -r requirements.txt + + - uses: actions/cache/restore@v5 + with: + path: modules + key: cache-zephyr-modules-${{ github.sha }} + + - name: Setup Zephyr project + uses: zephyrproject-rtos/action-zephyr-setup@v1 + with: + app-path: zephcore + toolchains: ${{ env.toolchains }} + sdk-version: ${{ env.zephyr_sdk }} + + # native_sim presets are cross-compiled for the target SBC architecture: + # femtofox = ARMv7-A (32-bit), rak6421 / rak6421_pi5 = aarch64 (64-bit). + - name: Install cross-compile toolchains + run: | + sudo apt-get update + sudo apt-get install -y \ + gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \ + gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + + - name: build firmwares + run: bash build.sh linux + + - uses: actions/cache@v5 + with: + path: firmware + key: cache-firmware-linux-${{ github.sha }} + build-esp32-companions: needs: setup-zephyr runs-on: ubuntu-latest @@ -178,7 +220,7 @@ jobs: key: cache-firmware-esp32-companions-${{ github.sha }} create-release: - needs: [build-nrf, build-esp32-companions, build-esp32-repeaters] + needs: [build-nrf, build-esp32-companions, build-esp32-repeaters, build-linux] runs-on: ubuntu-latest steps: @@ -203,6 +245,11 @@ jobs: path: firmware key: cache-firmware-esp32-repeaters-${{ github.sha }} + - uses: actions/cache/restore@v5 + with: + path: firmware + key: cache-firmware-linux-${{ github.sha }} + - name: upload firmware artifacts uses: actions/upload-artifact@v7 with: diff --git a/build.sh b/build.sh index 279ee32..f10edd6 100644 --- a/build.sh +++ b/build.sh @@ -23,6 +23,14 @@ nRF_boards=( gat562_30s ) +# Native-Linux presets (not Zephyr boards — built with -b native_sim plus an +# EXTRA_CONF_FILE). Each targets a real SBC arch, so it is cross-compiled. +Linux_boards=( + femtofox + rak6421 + rak6421_pi5 +) + ESP32_boards=( xiao_esp32c3 xiao_esp32c6/esp32c6/hpcore @@ -71,6 +79,50 @@ if [[ $1 == "nrf" ]]; then done fi +if [[ $1 == "linux" ]]; then + for board in "${Linux_boards[@]}"; do + # Pick the native_sim variant + cross toolchain for the target SBC arch. + case "$board" in + femtofox) + # Luckfox Pico Mini — ARMv7-A (32-bit) → native_sim (32-bit) + zboard="native_sim" + host="arm" + cross="/usr/bin/arm-linux-gnueabihf-" + ;; + rak6421|rak6421_pi5) + # Raspberry Pi — aarch64 (64-bit) → native_sim/native/64 + zboard="native_sim/native/64" + host="aarch64" + cross="/usr/bin/aarch64-linux-gnu-" + ;; + *) + echo "Unknown linux board: $board" + exit 1 + ;; + esac + + # build native-Linux companion (TCP transport — the default role) + echo "Now building $board companion (native linux)" + west build -b "$zboard" zephcore --pristine -- \ + -DZEPHYR_TOOLCHAIN_VARIANT=cross-compile \ + -DNATIVE_TARGET_HOST="$host" \ + -DCROSS_COMPILE="$cross" \ + -DEXTRA_CONF_FILE="boards/linux_native/$board.conf" + # native_sim emits zephcore_native_linux.exe; ship it as an extension-less + # per-board name (zephcore_linux_--). + mv build/zephyr/zephcore_native_linux.exe firmware/zephcore_linux_"$board"-companion-"$COMMIT_HASH" + + # build native-Linux repeater + echo "Now building $board repeater (native linux)" + west build -b "$zboard" zephcore --pristine -- \ + -DZEPHYR_TOOLCHAIN_VARIANT=cross-compile \ + -DNATIVE_TARGET_HOST="$host" \ + -DCROSS_COMPILE="$cross" \ + -DEXTRA_CONF_FILE="boards/linux_native/$board.conf;boards/common/repeater.conf" + mv build/zephyr/zephcore_native_linux.exe firmware/zephcore_linux_"$board"-repeater-"$COMMIT_HASH" + done +fi + if [[ $1 == "esp32" ]]; then for board in "${ESP32_boards[@]}"; do board_clean_for_path=$(echo "$board" | sed -e 's/\//-/g')