knob_os/tools/build_slave.sh

36 lines
1.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
# build_slave.sh —— 编译副控固件 slave_audio(ESP32-U4WDH, 4MB flash)
#
# 用法:./tools/build_slave.sh 编译,产物在 build_slave/
# ./tools/build_slave.sh clean 清缓存重编
#
# 为什么分开编:主控是 esp32s3 target,副控是经典 esp32 target,
# 两者 core 缓存不能共用,所以各用各的 build 目录。
#
# ⚠ 烧录前必须先备份原厂 4MB:
# ./tools/backup_slave.sh 或手跑 esptool read_flash 0x0 0x400000
set -e
HERE="$(cd "$(dirname "$0")/.." && pwd)"
AC="${ARDUINO_CLI:-$HERE/../../工具/arduino-cli}"
OUT="$HERE/build_slave"
CACHE="$OUT/.cache"
FQBN="esp32:esp32:esp32:FlashSize=4M,PartitionScheme=no_fs"
if [ "${1:-}" = "clean" ]; then
CLEAN="--clean"
# 不能 rm -rf:safe-delete 策略会拦整条命令,挪走等效且留现场
if [ -d "$CACHE" ]; then
mv "$CACHE" "$CACHE.broken-$(date +%H%M%S)"
echo ">> 旧缓存已挪到 $(basename "$CACHE").broken-*"
fi
fi
mkdir -p "$OUT" "$CACHE"
echo ">> compiling slave ($FQBN)"
"$AC" compile $CLEAN --build-path "$CACHE" --output-dir "$OUT" \
--fqbn "$FQBN" "$HERE/slave_audio"
echo ">> done. artifacts:"
ls -la "$OUT"/*.bin 2>/dev/null || true