scripts: create helper script for DFU generation
Signed-off-by: Onur Özkan <work@onurozkan.dev>
This commit is contained in:
1 parent
0ded1a4e85
commit
63ebe8cac2
1 file changed
+20
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/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"
|
||||
Reference in new issue
Block a user