Sandrine Bailleux | 7c5df58 | 2018-08-30 17:37:43 +0200 | [diff] [blame] | 1 | #! /bin/bash |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 2 | |
| 3 | set -e |
| 4 | |
| 5 | # Expect the script to run in argument |
| 6 | if [ $# != 1 ]; then |
| 7 | echo "ERROR: No script provided" |
Sandrine Bailleux | 47ab4f4 | 2019-05-10 13:23:41 +0200 | [diff] [blame] | 8 | echo "usage: $(basename $0) <armds_script_to_run>" |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 9 | exit 1 |
| 10 | fi |
| 11 | |
| 12 | # Is DS-5 command-line debugger found? |
Sandrine Bailleux | 47ab4f4 | 2019-05-10 13:23:41 +0200 | [diff] [blame] | 13 | if [ ! $(which armdbg) ]; then |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 14 | echo 'ERROR: Failed to find DS-5 command-line debugger.' |
Sandrine Bailleux | 47ab4f4 | 2019-05-10 13:23:41 +0200 | [diff] [blame] | 15 | echo 'Please add the path to the armdbg program in your PATH.' |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 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 |
Sandrine Bailleux | 47ab4f4 | 2019-05-10 13:23:41 +0200 | [diff] [blame] | 21 | juno_cdb_entry='Arm::Juno Arm Development Platform (r0)::Bare Metal Debug::Bare Metal Debug::Debug Cortex-A53_0::DSTREAM' |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 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 |
Sandrine Bailleux | 47ab4f4 | 2019-05-10 13:23:41 +0200 | [diff] [blame] | 27 | armdbg --cdb-entry "$juno_cdb_entry" --browse \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 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 | |
Sandrine Bailleux | 7c5df58 | 2018-08-30 17:37:43 +0200 | [diff] [blame] | 34 | if [ ! -s $connections_list ] ; then |
| 35 | echo "ERROR: Found no connection" |
| 36 | exit 1 |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 37 | fi |
| 38 | |
Sandrine Bailleux | 7c5df58 | 2018-08-30 17:37:43 +0200 | [diff] [blame] | 39 | # Ask the user which connection to use. |
| 40 | echo |
| 41 | cat -n $connections_list |
| 42 | echo -n "Which one do you want to connect to? " |
| 43 | read connection_id |
| 44 | |
| 45 | # Extract the corresponding connection name from the file. |
| 46 | connection=$(((sed -n "${connection_id}p") | sed 's/^ *//') < $connections_list) |
| 47 | if [ -z "$connection" ] ; then |
| 48 | echo "ERROR: Invalid connection" |
| 49 | exit 1 |
| 50 | fi |
| 51 | |
| 52 | rm $connections_list |
| 53 | |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 54 | # Run DS-5 script |
Sandrine Bailleux | 7c5df58 | 2018-08-30 17:37:43 +0200 | [diff] [blame] | 55 | echo |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 56 | echo "Connecting to $connection..." |
Sandrine Bailleux | 47ab4f4 | 2019-05-10 13:23:41 +0200 | [diff] [blame] | 57 | armdbg \ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 58 | --cdb-entry "$juno_cdb_entry" \ |
| 59 | --cdb-entry-param "Connection=$connection" \ |
| 60 | --stop_on_connect=false \ |
| 61 | --script=$1 |