Files
kaptan/scripts/create-dfu-image.sh
T
2026-07-18 16:52:04 +03:00

21 lines
578 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
if [[ $# -ne 2 ]]; then
printf 'Usage: %s <input.elf> <output.bin>\n' "$0" >&2
exit 2
fi
readonly input_elf="$1"
readonly output_image="$2"
readonly host="$(rustc -vV | sed -n 's/^host: //p')"
readonly llvm_objcopy="$(rustc --print sysroot)/lib/rustlib/$host/bin/llvm-objcopy"
if [[ ! -x "$llvm_objcopy" ]]; then
printf 'llvm-objcopy is unavailable; install it with: rustup component add llvm-tools-preview\n' >&2
exit 1
fi
"$llvm_objcopy" -O binary "$input_elf" "$output_image"
printf 'DFU image: %s\n' "$output_image"