rust-embassy-stm32/elf-to-hex.sh

15 lines
466 B
Bash
Raw Permalink Normal View History

2024-11-12 07:46:50 +00:00
#!/bin/bash
objcopy -O ihex target/thumbv6m-none-eabi/release/main target/main.hex -S
# read version number
version=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }' Cargo.toml)
# check if version was found
if [[ -z "$version" ]]; then
echo "Error: Version not found in Cargo.toml"
exit 1
fi
echo "Firmware Version $version"
# write version into filename
mv target/main.hex target/FW-$version-main.hex
echo "target/FW-$version-main.hex"