42 lines
1.2 KiB
Bash
Executable File
42 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Build script for custom ESP-IDF bootloader with rollback enabled.
|
|
# Requirements:
|
|
# - ESP-IDF installed
|
|
# - IDF_PATH exported
|
|
# - Python env prepared (the usual ESP-IDF setup)
|
|
# Usage:
|
|
# ./build_bootloader.sh [esp32|esp32s3|esp32c3|esp32s2|esp32c2|esp32c6|esp32h2]
|
|
# If target is omitted, the last configured target will be used.
|
|
|
|
TARGET=${1:-}
|
|
|
|
if [[ -z "${IDF_PATH:-}" ]]; then
|
|
echo "ERROR: IDF_PATH is not set. Please install ESP-IDF and export the environment (source export.sh)." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# shellcheck source=/dev/null
|
|
source "$IDF_PATH/export.sh"
|
|
|
|
if [[ -n "$TARGET" ]]; then
|
|
idf.py set-target "$TARGET"
|
|
fi
|
|
|
|
# Ensure sdkconfig.defaults is considered (ESP-IDF does this automatically).
|
|
# Build only the bootloader.
|
|
idf.py bootloader
|
|
|
|
echo
|
|
BOOTLOADER_BIN="build/bootloader/bootloader.bin"
|
|
if [[ -f "$BOOTLOADER_BIN" ]]; then
|
|
echo "Bootloader built: $BOOTLOADER_BIN"
|
|
echo "You can use this with espflash via:"
|
|
echo " espflash flash --bootloader $BOOTLOADER_BIN [--partition-table partitions.csv] <your-app-binary>"
|
|
else
|
|
echo "ERROR: Bootloader binary not found. Check build logs above." >&2
|
|
exit 2
|
|
fi
|
|
cp build/bootloader/bootloader.bin ../rust/bootloader.bin
|