ao-bringup: Get turnon_telemini working
[fw/altos] / ao-bringup / turnon_easymini
1 #!/bin/sh
2
3 if [ -x ../ao-tools/ao-flash/ao-flash-lpc ]; then
4         FLASH_LPC=../ao-tools/ao-flash/ao-flash-lpc
5 elif [ -x /usr/bin/ao-flash-lpc ]; then
6         FLASH_LPC=/usr/bin/ao-flash-lpc
7 else
8         echo "Can't find ao-flash-lpc!  Aborting."
9         exit 1
10 fi
11
12 if [ -x ../ao-tools/ao-usbload/ao-usbload ]; then
13         USBLOAD=../ao-tools/ao-usbload/ao-usbload
14 elif [ -x /usr/bin/ao-usbload ]; then
15         USBLOAD=/usr/bin/ao-usbload
16 else
17         echo "Can't find ao-usbload!  Aborting."
18         exit 1
19 fi
20
21 VERSION=1.0
22 PRODUCT=EasyMini
23 BASE=`echo $PRODUCT | tr 'A-Z' 'a-z'`
24 echo $FILE
25
26 echo "$PRODUCT v$VERSION Turn-On and Calibration Program"
27 echo "Copyright 2010 by Bdale Garbee.  Released under GPL v2"
28 echo
29 echo "Expectations:"
30 echo "\t$PRODUCT v$VERSION powered from USB"
31 echo "\t\twith ST-Link-V2 cabled to debug header"
32 echo
33 echo -n "$PRODUCT-$VERSION serial number: "
34 read SERIAL
35
36 echo $FLASH_LPC
37
38 $FLASH_LPC ../src/$BASE-v$VERSION/flash-loader/$BASE-v$VERSION-altos-flash-*.elf || exit 1
39
40 sleep 1
41
42 echo $USBLOAD
43
44 $USBLOAD --serial=$SERIAL ../src/$BASE-v$VERSION/*.ihx || exit 1
45
46 sleep 2
47
48 dev=`ao-list | awk '/'"$PRODUCT"'-v'"$VERSION"'/ { print $3; exit(0); }'`
49
50 case "$dev" in
51 /dev/tty*)
52         echo "$PRODUCT found on $dev"
53         ;;
54 *)
55         echo 'No '"$PRODUCT"'-v'"$VERSION"' found'
56         exit 1
57         ;;
58 esac
59
60 echo "Testing igniters. Both should flash"
61 ./test-igniter "$dev" drogue main
62
63 case $? in
64 0)
65         ;;
66 *)
67         echo "failed"
68         exit 1
69 esac
70
71 echo "Testing baro sensor"
72 ./test-baro "$dev"
73
74 case $? in
75 0)
76         ;;
77 *)
78         echo "failed"
79         exit 1
80 esac
81
82 FLASHSIZE=1048576
83
84 echo "Testing flash"
85 ./test-flash "$dev" "$FLASHSIZE"
86
87 case $? in
88 0)
89         ;;
90 *)
91         echo "failed"
92         exit 1
93 esac
94
95 echo "$PRODUCT-v$VERSION" serial "$SERIAL" is ready to ship
96 exit 0