#!/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"