ao-bringup: Use local versions of tools instead of /usr/bin for turnon_easymega
[fw/altos] / ao-bringup / turnon_easymega
1 #!/bin/sh
2
3 if [ -x ../ao-tools/ao-flash/ao-flash-stm ]; then
4         STMLOAD=../ao-tools/ao-flash/ao-flash-stm
5 else
6         echo "Can't find ao-flash-stm!  Aborting."
7         exit 1
8 fi
9
10 if [ -x ../ao-tools/ao-usbload/ao-usbload ]; then
11         USBLOAD=../ao-tools/ao-usbload/ao-usbload
12 else
13         echo "Can't find ao-usbload!  Aborting."
14         exit 1
15 fi
16
17 VERSION=1.0
18 REPO=~/altusmetrumllc/Binaries
19
20 echo "EasyMega v$VERSION Turn-On and Calibration Program"
21 echo "Copyright 2014 by Bdale Garbee.  Released under GPL v2"
22 echo
23 echo "Expectations:"
24 echo "\tEasyMega v$VERSION"
25 echo "\t\twith USB cable attached"
26 echo "\t\twith ST-Link-V2 cabled to debug header"
27 echo
28 echo -n "EasyMega-$VERSION serial number: "
29 read SERIAL
30
31 echo $STMLOAD
32
33 $STMLOAD $REPO/loaders/easymega-v$VERSION*.elf || exit 1
34
35 sleep 2
36
37 $USBLOAD --serial=$SERIAL $REPO/easymega-v$VERSION*.elf || exit 1
38
39 sleep 2
40
41 dev=`ao-list | awk '/EasyMega-v'"$VERSION"'/ { print $3; exit(0); }'`
42
43 case "$dev" in
44 /dev/tty*)
45         echo "EasyMega found on $dev"
46         ;;
47 *)
48         echo 'No EasyMega-v'"$VERSION"' found'
49         exit 1
50         ;;
51 esac
52
53 echo 'E 0' > $dev
54
55 ../ao-tools/ao-cal-accel/ao-cal-accel $dev || exit 1
56
57 echo 'E 1' > $dev
58
59 ./test-easymega
60
61 exit $?