annotate Bootloader/Scripts/swdLoad.bash @ 401:99f93dec8fea

Start removing select Linux-isms bash might not be in /bin. Don't expect it there.
author Dan McGregor <dan.mcgregor@usask.ca>
date Mon, 10 Aug 2015 14:49:46 -0600
parents f4d4cad283c6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
401
99f93dec8fea Start removing select Linux-isms
Dan McGregor <dan.mcgregor@usask.ca>
parents: 330
diff changeset
1 #!/usr/bin/env bash
254
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
2 # Loads firmware image using an SWD Flasher
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
3 # Uses MCHCK ruby flasher toolchain
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
4 # NOTE: Only tested with a buspirate on Linux
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
5
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
6 # Arg 1: Path to firmware image
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
7 # Arg 2: Address to flash to (byte address)
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
8
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
9 # Must have two args
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
10 if [ "$#" -ne 2 ]; then
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
11 echo "Usage: `basename $0` <firmware binary> <starting address>"
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
12 echo "Example: `basename $0` kiibohd_bootloader.bin 0"
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
13 exit 1
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
14 fi
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
15
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
16 # First check to see if the flasher toolchain is available
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
17 if [ ! -d "programmer" ]; then
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
18 # Use git to download the toolchain
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
19 git clone https://github.com/mchck/programmer.git
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
20 fi
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
21
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
22 # Make sure the toolchain is up to date
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
23 cd programmer
330
f4d4cad283c6 Some initial bringup of the dfu bootloader on the mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents: 254
diff changeset
24 #git pull --rebase
254
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
25 cd ..
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
26
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
27 # Attempt to flash
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
28 # Udev rules have been applied to name the buspirate as /dev/buspirate (instead of something like /dev/ttyUSB0)
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
29 # By default only root can access serial devices on Linux
330
f4d4cad283c6 Some initial bringup of the dfu bootloader on the mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents: 254
diff changeset
30 #ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate --mass-erase
254
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
31 ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate "$1" "$2"
330
f4d4cad283c6 Some initial bringup of the dfu bootloader on the mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents: 254
diff changeset
32 #ruby programmer/flash.rb name=buspirate:dev=/dev/buspirate --mass-erase "$1" "$2"
254
45cb81040110 Adding convenience scripts to build and load manufacturing image via SWD.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
33