ao-bringup: Use local versions of tools instead of /usr/bin for turnon_easymega
[fw/altos] / ao-tools / ao-flash / ao-flash-stm
1 #!/bin/sh
2 case "$#" in
3 0)
4         echo "usage: $0 <filename> ..."
5         exit 1
6         ;;
7 esac
8
9 ST_FLASH=st-flash
10
11 if which $ST_FLASH > /dev/null; then
12     :
13 else
14     echo "$0: $ST_FLASH not found. Check to see if the stlink package is installed"
15     exit 1
16 fi
17
18 file=$1
19
20 bin=/tmp/flash$$.bin
21 trap "rm $bin" 0 1 15
22
23 base=`arm-none-eabi-nm $file | awk '/interrupt_vector/ { print $1 }'`
24 case x"$base" in
25 x)
26     echo "$file: No interrupt vector address found"
27     exit 1
28     ;;
29 esac
30
31 arm-none-eabi-objcopy -O binary $file $bin
32
33 $ST_FLASH --reset write $bin $base