From 63ebe8cac2f4a438aacc6d05695890b5822e687a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Sat, 18 Jul 2026 16:52:04 +0300 Subject: [PATCH] scripts: create helper script for DFU generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onur Özkan --- scripts/create-dfu-image.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/create-dfu-image.sh diff --git a/scripts/create-dfu-image.sh b/scripts/create-dfu-image.sh new file mode 100755 index 0000000..925708c --- /dev/null +++ b/scripts/create-dfu-image.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ $# -ne 2 ]]; then + printf 'Usage: %s \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"