Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / ao-bringup / turnon_telegps
1 #!/bin/sh
2
3 if [ -x /usr/bin/ao-flash-lpc ]; then
4         FLASH_LPC=/usr/bin/ao-flash-lpc
5 else
6         echo "Can't find ao-flash-lpc!  Aborting."
7         exit 1
8 fi
9
10 if [ -x /usr/bin/ao-usbload ]; then
11         USBLOAD=/usr/bin/ao-usbload
12 else
13         echo "Can't find ao-usbload!  Aborting."
14         exit 1
15 fi
16
17 VERSION=1.0
18 PRODUCT=TeleGPS
19 BASE=`echo $PRODUCT | tr 'A-Z' 'a-z'`
20 echo $FILE
21
22 echo "$PRODUCT v$VERSION Turn-On and Calibration Program"
23 echo "Copyright 2014 by Bdale Garbee.  Released under GPL v2"
24 echo
25 echo "Expectations:"
26 echo "\t$PRODUCT v$VERSION powered from USB"
27 echo "\t\twith ST-Link-V2 cabled to debug header"
28 echo
29
30 case $# in
31     1)
32         SERIAL="$1"
33         echo "$PRODUCT-$VERSION serial number: $SERIAL" 
34         ;;
35     0)
36         echo -n "$PRODUCT-$VERSION serial number: "
37         read SERIAL
38         ;;
39     *)
40         echo "Usage: $0 <serial-number>" 1>&2
41         exit 1;
42         ;;
43 esac
44
45 #
46 # Use released versions of everything
47 #
48 FLASH_FILE=~/altusmetrumllc/Binaries/loaders/telegps-v1.0-altos-flash-*.elf
49 ALTOS_FILE=~/altusmetrumllc/Binaries/telegps-v1.0-*.elf
50
51 echo $FLASH_LPC $FLASH_FILE
52
53 $FLASH_LPC $FLASH_FILE || exit 1
54
55 sleep 2
56
57 echo $USBLOAD $ALTOS_FILE
58
59 $USBLOAD --serial=$SERIAL $ALTOS_FILE || exit 1
60
61 sleep 2
62
63 dev=`ao-list | awk '/TeleGPS-v'"$VERSION"'/ { print $3; exit(0); }'`
64
65 case "$dev" in
66 /dev/tty*)
67         echo "TeleGPS found on $dev"
68         ;;
69 *)
70         echo 'No TeleGPS-v'"$VERSION"' found'
71         exit 1
72         ;;
73 esac
74
75 SERIAL=$SERIAL ./cal-freq $dev
76
77 ./test-telegps
78
79 exit $?