ao-bringup: Allow dfu_util to "fail" while flashing chaoskey
[fw/altos] / ao-bringup / turnon_easymini
1 #!/bin/sh
2
3 if [ -x /usr/bin/dfu-util ]; then
4     DFU_UTIL=/usr/bin/dfu-util
5 else
6     echo "Can't find dfu-util! 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 elif [ -x /usr/bin/ao-usbload ]; then
13         USBLOAD=/usr/bin/ao-usbload
14 else
15         echo "Can't find ao-usbload!  Aborting."
16         exit 1
17 fi
18
19 VERSION=2.0
20 PRODUCT=EasyMini
21 BASE=`echo $PRODUCT | tr 'A-Z' 'a-z'`
22 echo $FILE
23
24 echo "$PRODUCT v$VERSION Turn-On and Calibration Program"
25 echo "Copyright 2010 by Bdale Garbee.  Released under GPL v2+"
26 echo
27 echo "Expectations:"
28 echo "\t$PRODUCT v$VERSION powered and connected to USB"
29 echo
30
31 case $# in
32     1)
33         SERIAL="$1"
34         echo "$PRODUCT-$VERSION serial number: $SERIAL" 
35         ;;
36     0)
37         echo -n "$PRODUCT-$VERSION serial number: "
38         read SERIAL
39         ;;
40     *)
41         echo "Usage: $0 <serial-number>" 1>&2
42         exit 1;
43         ;;
44 esac
45
46 #
47 # Use released versions of everything
48 #
49 FLASH_FILE=~/altusmetrumllc/Binaries/loaders/easymini-v2.0-altos-flash-*.bin
50 ALTOS_FILE=~/altusmetrumllc/Binaries/easymini-v2.0-*.elf
51
52 #FLASH_FILE=../src/$BASE-v$VERSION/flash-loader/$BASE-v$VERSION-altos-flash-*.elf
53 #ALTOS_FILE=../src/$BASE-v$VERSION/*.ihx
54
55 echo $DFU_UTIL -a 0 -s 0x08000000:leave -D $FLASH_FILE
56
57 #$DFU_UTIL -a 0 -s 0x08000000:leave -D $FLASH_FILE || exit 1
58
59 sleep 2
60
61 echo $USBLOAD $ALTOS_FILE
62
63 $USBLOAD --serial=$SERIAL $ALTOS_FILE || exit 1
64
65 sleep 1
66
67 ./test-easymini
68
69 exit $?