From 1c1045eada5b87cee028df7534c3f7e43783011a Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Mon, 27 Oct 2025 13:38:05 +0200 Subject: [PATCH] Add script to build ESP-Hosted slave firmwares --- build.sh | 16 +++++++++++-- tools/build-hosted.sh | 52 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100755 tools/build-hosted.sh diff --git a/build.sh b/build.sh index a1de00765..bc6622680 100755 --- a/build.sh +++ b/build.sh @@ -31,7 +31,7 @@ if [ -z $DEPLOY_OUT ]; then fi function print_help() { - echo "Usage: build.sh [-s] [-n] [-A ] [-I ] [-D ] [-i ] [-c ] [-t ] [-b ] [config ...]" + echo "Usage: build.sh [-s] [-n] [-A ] [-I ] [-D ] [-i ] [-c ] [-t ] [-b ] [config ...]" echo " -s Skip installing/updating of ESP-IDF and all components" echo " -n Disable ccache" echo " -A Set which branch of arduino-esp32 to be used for compilation" @@ -87,7 +87,8 @@ while getopts ":A:I:i:c:t:b:D:sde" opt; do [ "$b" != "reconfigure" ] && [ "$b" != "idf-libs" ] && [ "$b" != "copy-bootloader" ] && - [ "$b" != "mem-variant" ]; then + [ "$b" != "mem-variant" ] && + [ "$b" != "hosted" ]; then print_help fi BUILD_TYPE="$b" @@ -137,6 +138,11 @@ if [ "$BUILD_TYPE" != "all" ]; then print_help fi + if [ "$BUILD_TYPE" == "hosted" ]; then + ./tools/build-hosted.sh + exit $? + fi + # Target Features Configs for target_json in `jq -c '.targets[]' configs/builds.json`; do target=$(echo "$target_json" | jq -c '.target' | tr -d '"') @@ -226,6 +232,12 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf-libs if [ $? -ne 0 ]; then exit 1; fi + # Build ESP-Hosted slave firmwares + if [ "$target" == "esp32p4" ]; then + ./tools/build-hosted.sh + fi + + # Build ESP-SR Models if [ "$target" == "esp32s3" ] || [ "$target" == "esp32p4" ]; then idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" srmodels_bin if [ $? -ne 0 ]; then exit 1; fi diff --git a/tools/build-hosted.sh b/tools/build-hosted.sh new file mode 100755 index 000000000..fb168c5cf --- /dev/null +++ b/tools/build-hosted.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +CCACHE_ENABLE=1 + +export IDF_CCACHE_ENABLE=$CCACHE_ENABLE +source ./tools/config.sh + +SLAVE_DIR="$AR_MANAGED_COMPS/espressif__esp_hosted/slave" + +if [ ! -d "$SLAVE_DIR" ]; then + echo "ESP-Hosted component not found!" + exit 1 +fi + +VERSION_FILE="$SLAVE_DIR/main/esp_hosted_coprocessor_fw_ver.h" + +if [ ! -f "$VERSION_FILE" ]; then + echo "Error: File $VERSION_FILE not found!" + exit 1 +fi + +MAJOR=$(grep "PROJECT_VERSION_MAJOR_1" "$VERSION_FILE" | sed 's/.*PROJECT_VERSION_MAJOR_1 \([0-9]*\).*/\1/') +MINOR=$(grep "PROJECT_VERSION_MINOR_1" "$VERSION_FILE" | sed 's/.*PROJECT_VERSION_MINOR_1 \([0-9]*\).*/\1/') +PATCH=$(grep "PROJECT_VERSION_PATCH_1" "$VERSION_FILE" | sed 's/.*PROJECT_VERSION_PATCH_1 \([0-9]*\).*/\1/') + +if [ -z "$MAJOR" ] || [ -z "$MINOR" ] || [ -z "$PATCH" ]; then + echo "Error: Could not extract all version infos!" + echo "MAJOR: '$MAJOR', MINOR: '$MINOR', PATCH: '$PATCH'" + exit 1 +fi + +VERSION="$MAJOR.$MINOR.$PATCH" +echo "Building ESP-Hosted firmware $VERSION" + +cd "$SLAVE_DIR" + +OUTPUT_DIR="$AR_TOOLS/esp32-arduino-libs/hosted" +mkdir -p "$OUTPUT_DIR" + +TARGETS=( + "esp32c5" + "esp32c6" +) + +for target in "${TARGETS[@]}"; do + echo "Building for target: $target" + idf.py set-target "$target" + idf.py clean + idf.py build + cp "$SLAVE_DIR/build/network_adapter.bin" "$OUTPUT_DIR/$target-v$VERSION.bin" + echo "Build completed: $target-v$VERSION.bin" +done