view program @ 0:6dfcd8e5b8df

first release
author Frank Kingswood <frank@kingswood-consulting.co.uk>
date Tue, 25 Mar 2014 20:31:00 +0000
parents
children 1a405bda2ffe
line wrap: on
line source
1 #!/bin/sh
2 set -e
4 if [ $# -ne 3 ] || [ "$1" = "--help" ] ; then
5 echo "Called from Makefile to program USB-GPIB"
6 exit 1
7 fi
9 for DEV in /dev/ttyUSB0* ; do
10 true
11 done
13 MODE=
14 if lsusb -d 16c0:047a ; then
15 echo "Autodetecting USB-GPIB"
17 exec 3<>$DEV
19 (
20 sleep 1
21 kill -ALRM $$
22 ) &
23 trap "true" ALRM
24 while read X ; do echo $X ; done
25 sleep 1
27 echo "++ver" >&3
28 read V <&3
29 case "$V" in
30 *USB-GPIB-32U4*)
31 echo "Found USB-GPIB"
32 ;;
33 *)
34 exit 2
35 ;;
36 esac
38 # call the boot loader
39 case "$V" in
40 *Teensy*)
41 echo "++DEBUG 0x7e00" >&3
42 MODE=Teensy
43 ;;
44 *)
45 echo "++DEBUG 0x7800" >&3
46 MODE=AVR109
47 ;;
48 esac
50 exec 3>&-
51 sleep 0.5
53 elif lsusb -d 2341:8036 ; then
54 MODE=AVR109
56 elif lsusb -d 16c0:0478 ; then
57 MODE=Teensy
59 else
60 echo "No device found"
61 exit 1
62 fi
64 echo "$MODE boot loader"
66 if [ "$1" != "--program" ] ; then
67 exit 1
68 fi
70 set -x
72 case "$MODE" in
73 Teensy)
74 teensy_loader_cli -mmcu="$2" -w -v "$3"
75 ;;
76 AVR109)
77 avrdude -c avr109 -P $DEV -p "$2" -q -U flash:w:"$3"
78 ;;
79 esac