-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_all.sh
More file actions
executable file
·114 lines (101 loc) · 4.5 KB
/
Copy pathbuild_all.sh
File metadata and controls
executable file
·114 lines (101 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
# build_all.sh — Build CSI Radar firmware for all device targets
#
# Prerequisites:
# . ~/esp/esp-idf/export.sh (sets IDF_PATH, adds idf.py to PATH)
#
# Usage:
# chmod +x build_all.sh
# ./build_all.sh (build everything)
# ./build_all.sh tx-esp32 (build one variant)
#
# Each variant gets its own build directory so sdkconfigs don't collide.
# First-time build generates sdkconfig from defaults.
# Customize device-specific settings (SSID, DEVICE_ID, role) with:
# idf.py -B build/<variant> menuconfig
#
# Flash a variant:
# idf.py -B build/<variant> -p /dev/ttyUSB0 flash monitor
set -euo pipefail
if [[ -z "${IDF_PATH:-}" ]]; then
echo "ERROR: IDF_PATH not set. Run: . ~/esp/esp-idf/export.sh"
exit 1
fi
PROJECT_ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$PROJECT_ROOT"
# ── Variant table: name target role device_id_hint ────────────────────
declare -A VARIANTS=(
["tx-esp32"]="esp32"
["tx-esp32s3"]="esp32s3"
["tx-esp32c5"]="esp32c5"
["rx-esp32s3"]="esp32s3"
)
declare -A ROLE_HINT=(
["tx-esp32"]="TX → WROOM x2"
["tx-esp32s3"]="TX → Atom S3, AtomFly"
["tx-esp32c5"]="TX → Waveshare C5, T-Dongle C5 (5GHz capable)"
["rx-esp32s3"]="RX → XIAO ESP32-S3 Sense, Cardputer ADV"
)
build_variant() {
local name="$1"
local target="${VARIANTS[$name]}"
local build_dir="build/${name}"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Building: ${name}"
echo " Target: ${target}"
echo " Role: ${ROLE_HINT[$name]}"
echo " Dir: ${build_dir}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
mkdir -p "$build_dir"
# RX variants get the camera/PSRAM overlay on top of the shared defaults.
# IDF auto-appends ".<target>" to each file in the list, so the esp32s3
# base still applies. TX variants keep the plain default behaviour.
local sdkconfig_defaults_arg=()
if [[ "$name" == rx-* ]]; then
sdkconfig_defaults_arg=(-D SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.rx-camera")
fi
# Each variant keeps its own sdkconfig INSIDE its build dir. IDF otherwise
# defaults SDKCONFIG to the project root, so building different targets in
# sequence collides ("Target 'esp32s3' ... does not match 'esp32'"). Keeping
# it per-variant also keeps each board's Wi-Fi creds in its own gitignored
# build/<variant>/sdkconfig.
idf.py \
-D IDF_TARGET="${target}" \
-D SDKCONFIG="${build_dir}/sdkconfig" \
"${sdkconfig_defaults_arg[@]}" \
-B "${build_dir}" \
build
local bin="${build_dir}/csi_radar.bin"
if [[ -f "$bin" ]]; then
echo " ✓ ${bin} ($(du -sh "$bin" | cut -f1))"
echo " Flash: idf.py -B ${build_dir} -p /dev/ttyUSB0 flash"
else
echo " ✗ Build succeeded but binary not found?"
fi
}
# ── Main ─────────────────────────────────────────────────────────────────────
if [[ $# -gt 0 ]]; then
# Build specific variant(s) passed as arguments
for variant in "$@"; do
if [[ -z "${VARIANTS[$variant]+x}" ]]; then
echo "Unknown variant: $variant"
echo "Available: ${!VARIANTS[*]}"
exit 1
fi
build_variant "$variant"
done
else
# Build everything
echo "Building all variants..."
for variant in "tx-esp32" "tx-esp32s3" "tx-esp32c5" "rx-esp32s3"; do
build_variant "$variant"
done
fi
echo ""
echo "═══ Done. Before first flash, customize each build: ════════════════════"
echo " idf.py -B build/tx-esp32 menuconfig # set DEVICE_ID, channel"
echo " idf.py -B build/tx-esp32s3 menuconfig # set DEVICE_ID, channel"
echo " idf.py -B build/tx-esp32c5 menuconfig # set DEVICE_ID, channel (36+ for 5GHz)"
echo " idf.py -B build/rx-esp32s3 menuconfig # set DEVICE_ID, SSID, password, MQTT broker URI"
echo "════════════════════════════════════════════════════════════════════════"