Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame^] | 1 | #! /bin/sh |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | # Expect the script to run in argument |
| 6 | if [ $# != 1 ]; then |
| 7 | echo "ERROR: No script provided" |
| 8 | echo "usage: $(basename $0) <ds5_script_to_run>" |
| 9 | exit 1 |
| 10 | fi |
| 11 | |
| 12 | # Is DS-5 command-line debugger found? |
| 13 | if [ ! $(which debugger) ]; then |
| 14 | echo 'ERROR: Failed to find DS-5 command-line debugger.' |
| 15 | echo 'Please add the path to the command-line debugger in your PATH.' |
| 16 | echo 'E.g.: export PATH=<DS-5 install dir>/bin:$PATH' |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | # DS-5 configuration database entry for Juno r0 |
| 21 | juno_cdb_entry='ARM Development Boards::Juno ARM Development Platform (r0)::Bare Metal Debug::Bare Metal Debug::Debug Cortex-A53_0::DSTREAM' |
| 22 | |
| 23 | # Browse for available DSTREAM connections and lists targets that match the |
| 24 | # connection type specified in the configuration database entry |
| 25 | echo "Trying to detect your DSTREAM unit..." |
| 26 | connections_list=available_connections |
| 27 | debugger --cdb-entry "$juno_cdb_entry" --browse \ |
| 28 | | tee $connections_list |
| 29 | |
| 30 | # Remove first line in the file (i.e. "Available connections:") |
| 31 | tail -n +2 $connections_list > ${connections_list}_stripped |
| 32 | mv ${connections_list}_stripped ${connections_list} |
| 33 | |
| 34 | # Use first available connection |
| 35 | read connection < $connections_list || true |
| 36 | rm $connections_list |
| 37 | |
| 38 | if [ -z "$connection" ] ; then |
| 39 | echo "ERROR: Found no connection" |
| 40 | exit 1 |
| 41 | fi |
| 42 | |
| 43 | # Run DS-5 script |
| 44 | echo "Connecting to $connection..." |
| 45 | debugger \ |
| 46 | --cdb-entry "$juno_cdb_entry" \ |
| 47 | --cdb-entry-param "Connection=$connection" \ |
| 48 | --stop_on_connect=false \ |
| 49 | --script=$1 |