]> git.donarmstrong.com Git - kiibohd-controller.git/blob - Bootloader/Scripts/swdLoad.bash
12b1e9badebe39f92b1a20336482b6972a064f25
[kiibohd-controller.git] / Bootloader / Scripts / swdLoad.bash
1 #!/bin/bash
2 # Loads firmware image using an SWD Flasher
3 # Uses MCHCK ruby flasher toolchain
4 # NOTE: Only tested with a buspirate on Linux
5
6 # Arg 1: Path to firmware image
7 # Arg 2: Address to flash to (byte address)
8
9 # Must have two args
10 if [ "$#" -ne 2 ]; then
11         echo "Usage:   `basename $0` <firmware binary> <starting address>"
12         echo "Example: `basename $0` kiibohd_bootloader.bin 0"
13         exit 1
14 fi
15
16 # First check to see if the flasher toolchain is available
17 if [ ! -d "programmer" ]; then
18         # Use git to download the toolchain
19         git clone https://github.com/mchck/programmer.git
20 fi
21
22 # Make sure the toolchain is up to date
23 cd programmer
24 #git pull --rebase
25 cd ..
26
27 # Attempt to flash
28 # Udev rules have been applied to name the buspirate as /dev/buspirate (instead of something like /dev/ttyUSB0)
29 # By default only root can access serial devices on Linux
30 #ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate --mass-erase
31 ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate "$1" "$2"
32 #ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate --mass-erase "$1" "$2"
33