#!/usr/bin/env bash # Builds (or flashes/monitors, if a serial port is actually attached) # the espresso_frame firmware for one board variant, via the project's # own firmware/build_for_board.sh -- this script just sources the # ESP-IDF environment first and auto-runs `set-target` (esp32c6 for # devkit/xiao, esp32s3 for ee02) on a board's very first build (a fresh # clone has no generated sdkconfig yet, same reasoning as CI's own build # steps -- see firmware/README.md's "Building for the Seeed XIAO # ESP32-C6" section). # # NOTE: ee02 builds will fail to compile -- deliberately -- until # firmware/components/epd13in3e's panel driver is ported from vendor # demo code (see that component's own top-of-file comment). The build # plumbing itself (target selection, partition table, sdkconfig # layering) is exercised regardless; only the final compile step fails. # # Usage: # build.sh # build devkit (default) # build.sh devkit # build.sh xiao # build.sh ee02 # build.sh both # build devkit + xiao (unchanged meaning) # build.sh all # build devkit + xiao + ee02 # build.sh xiao flash -p /dev/ttyUSB0 # only meaningful with real hardware attached set -euo pipefail script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" firmware_dir="$(git -C "$script_dir" rev-parse --show-toplevel)/firmware" IDF_DIR="$HOME/.espressif-idf/esp-idf" if [ ! -f "$IDF_DIR/export.sh" ]; then echo "ESP-IDF not found at $IDF_DIR -- run setup.sh first" >&2 exit 1 fi # export.sh is chatty and assumes an interactive shell prompt in spots; # redirect its own stdout, not ours, so build.sh's actual output (and a # real failure's stderr) stays visible. source "$IDF_DIR/export.sh" > /dev/null cd "$firmware_dir" build_one() { local board="$1" shift local sdkconfig target case "$board" in devkit) sdkconfig="sdkconfig"; target="esp32c6" ;; xiao) sdkconfig="sdkconfig.xiao_local"; target="esp32c6" ;; ee02) sdkconfig="sdkconfig.ee02_local"; target="esp32s3" ;; *) echo "Unknown board '$board' -- expected 'devkit', 'xiao', or 'ee02'" >&2; exit 1 ;; esac if [ ! -f "$sdkconfig" ]; then echo "==> $board: no generated sdkconfig yet, setting target $target" ./build_for_board.sh "$board" set-target "$target" fi local args=("$@") if [ ${#args[@]} -eq 0 ]; then args=(build) fi ./build_for_board.sh "$board" "${args[@]}" } board="${1:-devkit}" shift || true case "$board" in both) build_one devkit "$@" build_one xiao "$@" ;; all) build_one devkit "$@" build_one xiao "$@" build_one ee02 "$@" ;; *) build_one "$board" "$@" ;; esac