2015-08-10 20:49:46 +00:00
|
|
|
#!/usr/bin/env bash
|
2014-11-16 21:03:31 +00:00
|
|
|
# Loads firmware image using an SWD Flasher
|
|
|
|
# Uses MCHCK ruby flasher toolchain
|
|
|
|
# NOTE: Only tested with a buspirate on Linux
|
|
|
|
|
|
|
|
# Arg 1: Path to firmware image
|
|
|
|
# Arg 2: Address to flash to (byte address)
|
|
|
|
|
|
|
|
# Must have two args
|
|
|
|
if [ "$#" -ne 2 ]; then
|
|
|
|
echo "Usage: `basename $0` <firmware binary> <starting address>"
|
|
|
|
echo "Example: `basename $0` kiibohd_bootloader.bin 0"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# First check to see if the flasher toolchain is available
|
|
|
|
if [ ! -d "programmer" ]; then
|
|
|
|
# Use git to download the toolchain
|
|
|
|
git clone https://github.com/mchck/programmer.git
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure the toolchain is up to date
|
|
|
|
cd programmer
|
2015-04-05 06:21:11 +00:00
|
|
|
#git pull --rebase
|
2014-11-16 21:03:31 +00:00
|
|
|
cd ..
|
|
|
|
|
|
|
|
# Attempt to flash
|
|
|
|
# Udev rules have been applied to name the buspirate as /dev/buspirate (instead of something like /dev/ttyUSB0)
|
|
|
|
# By default only root can access serial devices on Linux
|
2015-04-05 06:21:11 +00:00
|
|
|
#ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate --mass-erase
|
2014-11-16 21:03:31 +00:00
|
|
|
ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate "$1" "$2"
|
2015-04-05 06:21:11 +00:00
|
|
|
#ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate --mass-erase "$1" "$2"
|
2014-11-16 21:03:31 +00:00
|
|
|
|