xiao_pet_tracker_rust/build_and_flash.sh

28 lines
747 B
Bash
Raw Normal View History

2025-02-24 23:16:48 +01:00
#!/bin/bash
set -e
COM_PORT=/dev/cu.usbmodem2101
echo -e "bootloader" > $COM_PORT
sleep 1s
while getopts 'abc:h' opt; do
case "$opt" in
?|h)
echo "Usage: $(basename $0) crate_name"
exit 1
;;
esac
done
shift "$(($OPTIND -1))"
CRATE=$1
cargo build -p $CRATE --release
arm-none-eabi-objcopy -O ihex target/thumbv7em-none-eabihf/release/$CRATE target/$CRATE.hex
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0x0123 --application target/$CRATE.hex target/$CRATE.zip
# Use our custom reboot system to boot the controller into serial-only DFU mode.
# echo -e "bootloader" > $COM_PORT
# Wait for the reboot.
# sleep 1s
adafruit-nrfutil --verbose dfu serial -pkg target/$CRATE.zip -p $COM_PORT -b 115200 --singlebank