add ability to build and upload sketches from the bash command line (via beta ino2cpp...
[zumo-cc3200/zumo-cc3200.git] / etc / rbload.sh
1 #!/bin/sh
2 #
3 # Flash the specified binary on the RedBear CC3200
4 #
5 # Usage: rbload binary [[com_port_id] [energia_install_dir]]"
6 #
8 if [ $# -lt 1 ]; then
9     echo "usage: `basename $0` binary [[com_port_id] [energia_install_dir]]"
10     exit 1
11 fi
13 # locate the binary file to load
14 binpath=`dirname $0`/../build
15 bin="$1"
16 if [ ! -r "$1" ]; then
17     if [ -r "$binpath/$bin" ]; then
18         bin="$binpath/$bin"
19     else
20         echo "error: can't find the binary file $bin"
21         exit 1
22     fi
23 fi
25 # set serial port id
26 comid="$2"
27 if [ "$comid" = "" ]; then
28     comid=9
29 fi
31 # set Energia install dir
32 eidir="$3"
33 if [ "$eidir" = "" ]; then
34     eidir="C:/ti"
35 fi
37 # convert bin to absolute path
38 bindir="`dirname $bin`"
39 bindir="`cd $bindir; pwd`"
40 bin="$bindir/`basename $bin`"
42 # use the latest version of energia to load $bin
43 for f in `ls -dt "$eidir"/energia-* 2> /dev/null` "$eidir"; do
44     # cc3200prog must be run from it's home directory (!)
45     cd "$f/hardware/tools/lm4f/bin"
46     ./cc3200prog "$comid" "$bin" || exit 1
47     echo Upload succeeded.  
48     echo Push the reset button on the ZumoCC3200 to start the sketch.
49     exit 0
50 done
51     
52 echo "error: energia is not installed in $eidir"
53 exit 1