Mercurial > louis > kiibohd-controller
annotate LoadFile/winload.teensy @ 412:e7a3be42ae1e
Debug code for interconnect cable debugging
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Sat, 20 Feb 2016 13:27:49 -0800 |
parents | 99f93dec8fea |
children |
rev | line source |
---|---|
401
99f93dec8fea
Start removing select Linux-isms
Dan McGregor <dan.mcgregor@usask.ca>
parents:
281
diff
changeset
|
1 #!/usr/bin/env bash |
276
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
2 # Convenience script for loading firmware onto a teensy type device |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
3 # By default, initiates teensy-load-cli |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
4 |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
5 SERIAL_PORT="" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
6 AUTO_SCREEN_SESSION="" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
7 PROG_NAME=$(basename $0) |
207
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
8 |
276
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
9 # Parse all the command line arguments |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
10 while (( "$#" >= "1" )); do |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
11 # Scan each argument |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
12 key="$1" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
13 case $key in |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
14 -a|--autoscreen) |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
15 AUTO_SCREEN_SESSION="$2" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
16 shift |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
17 ;; |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
18 -f|--fastload) |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
19 SERIAL_PORT="$2" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
20 shift |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
21 ;; |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
22 -h|--help) |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
23 echo "Usage: $PROG_NAME [options...]" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
24 echo "" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
25 echo "Loads the most recent built firmware (@TARGET_BIN@) to the device." |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
26 echo "Requires Cygwin." |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
27 echo " (winload.teensy)" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
28 echo "" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
29 echo "Arguments:" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
30 echo " -f, --fastload SERIAL_PORT Send the reload command to the debug terminal." |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
31 echo " e.g. /dev/ttyACM0" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
32 echo " NOTE: May not work due to non-functional terminal, or disable remote flashing" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
33 echo " -h, --help This message." |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
34 exit 1 |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
35 ;; |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
36 *) |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
37 echo "INVALID ARG: '$1'" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
38 exit 2 |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
39 ;; |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
40 esac |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
41 |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
42 # Shift to the next argument |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
43 shift |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
44 done |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
45 |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
46 # First check to see teensy-loader-cli has been compiled |
207
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
47 if [ ! -e teensy-loader-cli/teensy-loader-cli ]; then |
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
48 # Compile teensy-loader-cli |
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
49 mkdir -p teensy-loader-cli |
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
50 cd teensy-loader-cli |
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
51 cmake -G "Unix Makefiles" $(cygpath -u @CMAKE_SOURCE_DIR@/LoadFile) |
281
71882cd1c362
Check for needed programs
Rowan Decker <Smasher816@gmail.com>
parents:
276
diff
changeset
|
52 make || exit 3 |
207
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
53 cd - |
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
54 fi |
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
55 |
276
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
56 # If a SERIAL_PORT was specified set the uC into reflash mode |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
57 # XXX May not be successful if uC is not in a good state (or does not allow remote flashing) |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
58 if [[ "$SERIAL_PORT" != "" ]] && [[ -e "$SERIAL_PORT" ]]; then |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
59 echo "NOTE: This may fail if the uC is in a bad state or does not support remote flashing" |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
60 printf "reload\r" > $SERIAL_PORT |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
61 sleep 1 |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
62 fi |
207
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
63 |
276
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
64 # Loads the hex file onto the teensy |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
65 teensy-loader-cli/teensy-loader-cli -mmcu=@MCU@ -w @TARGET_HEX@ |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
66 EXIT_STATUS=$? |
207
8b11031e38a7
Adding convenience loader scripts for DFU based microcontrollers
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
67 |
276
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
68 exit $EXIT_STATUS |
2a3468f5d8be
Updating load scripts with command line arguments
Jacob Alexander <haata@kiibohd.com>
parents:
207
diff
changeset
|
69 |