You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/10/16 20:45:47 UTC

[GitHub] mkiiskila closed pull request #1453: allow user to override TCP port gdb and jtag emulator use to communicate

mkiiskila closed pull request #1453: allow user to override TCP port gdb and jtag emulator use to communicate
URL: https://github.com/apache/mynewt-core/pull/1453
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/scripts/common.sh b/hw/scripts/common.sh
index 5fde01805d..42a222bbb3 100755
--- a/hw/scripts/common.sh
+++ b/hw/scripts/common.sh
@@ -42,3 +42,29 @@ windows_detect() {
         COMSPEC=cmd.exe
     fi
 }
+
+#
+# Check if known parameters are set in EXTRA_JTAG_CMD. Filter these
+# parameters out of the arguments passed to jtag emulator software.
+# Only special parameter is -port <portnumber>
+#
+parse_extra_jtag_cmd() {
+    PORT=3333
+
+    NEW_EXTRA_JTAG_CMD=""
+    while [ "$1" != "" ]; do
+	case $1 in
+	    -port)
+		shift
+		PORT=$1
+		shift
+		;;
+	    *)
+		NEW_EXTRA_JTAG_CMD+=" $1"
+		shift
+		;;
+	esac
+    done
+    echo $NEW_EXTRA_JTAG_CMD
+    EXTRA_JTAG_CMD=$NEW_EXTRA_JTAG_CMD
+}
diff --git a/hw/scripts/jlink.sh b/hw/scripts/jlink.sh
index 8a75502a5a..db5e257b5d 100755
--- a/hw/scripts/jlink.sh
+++ b/hw/scripts/jlink.sh
@@ -27,8 +27,11 @@ JLINK_GDB_SERVER=JLinkGDBServer
 jlink_load () {
     GDB_CMD_FILE=.gdb_cmds
     GDB_OUT_FILE=.gdb_out
+    PORT=3333
 
     windows_detect
+    parse_extra_jtag_cmd $EXTRA_JTAG_CMD
+
     if [ $WINDOWS -eq 1 ]; then
 	JLINK_GDB_SERVER=JLinkGDBServerCL
     fi
@@ -53,8 +56,8 @@ jlink_load () {
     # downloading somewhere in the flash. So need to figure out how to tell it
     # not to do that, or report failure if gdb fails to write this file
     #
-    echo "shell sh -c \"trap '' 2; $JLINK_GDB_SERVER -device $JLINK_DEV -speed 1000 -if SWD -port 3333 -singlerun $EXTRA_JTAG_CMD  &\" " > $GDB_CMD_FILE
-    echo "target remote localhost:3333" >> $GDB_CMD_FILE
+    echo "shell sh -c \"trap '' 2; $JLINK_GDB_SERVER -device $JLINK_DEV -speed 1000 -if SWD -port $PORT -singlerun $EXTRA_JTAG_CMD  &\" " > $GDB_CMD_FILE
+    echo "target remote localhost:$PORT" >> $GDB_CMD_FILE
     echo "mon reset" >> $GDB_CMD_FILE
     echo "restore $FILE_NAME binary $FLASH_OFFSET" >> $GDB_CMD_FILE
 
@@ -109,6 +112,7 @@ jlink_debug() {
     if [ $WINDOWS -eq 1 ]; then
 	JLINK_GDB_SERVER=JLinkGDBServerCL
     fi
+    parse_extra_jtag_cmd $EXTRA_JTAG_CMD
 
     if [ -z "$NO_GDB" ]; then
         GDB_CMD_FILE=.gdb_cmds
@@ -129,17 +133,17 @@ jlink_debug() {
             # Launch jlink server in a separate command interpreter, to make
             # sure it doesn't get killed by Ctrl-C signal from bash.
             #
-            $COMSPEC /C "start $COMSPEC /C $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun $EXTRA_JTAG_CMD"
+            $COMSPEC /C "start $COMSPEC /C $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port $PORT -singlerun $EXTRA_JTAG_CMD"
         else
             #
             # Block Ctrl-C from getting passed to jlink server.
             #
             set -m
-            $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun $EXTRA_JTAG_CMD  > /dev/null &
+            $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port $PORT -singlerun $EXTRA_JTAG_CMD  > /dev/null &
             set +m
         fi
 
-        echo "target remote localhost:3333" > $GDB_CMD_FILE
+        echo "target remote localhost:$PORT" > $GDB_CMD_FILE
         # Whether target should be reset or not
         if [ ! -z "$RESET" ]; then
             echo "mon reset" >> $GDB_CMD_FILE
@@ -155,7 +159,7 @@ jlink_debug() {
             rm $GDB_CMD_FILE
 	fi
     else
-        $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun $EXTRA_JTAG_CMD
+        $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port $PORT -singlerun $EXTRA_JTAG_CMD
     fi
     return 0
 }
diff --git a/hw/scripts/openocd.sh b/hw/scripts/openocd.sh
index 0913bd00c4..1a9e68ab2b 100755
--- a/hw/scripts/openocd.sh
+++ b/hw/scripts/openocd.sh
@@ -27,6 +27,8 @@ GDB=arm-none-eabi-gdb
 openocd_load () {
     OCD_CMD_FILE=.openocd_cmds
 
+    parse_extra_jtag_cmd $EXTRA_JTAG_CMD
+
     echo "$EXTRA_JTAG_CMD" > $OCD_CMD_FILE
     echo "init" >> $OCD_CMD_FILE
     echo "$CFG_RESET" >> $OCD_CMD_FILE
@@ -66,9 +68,10 @@ openocd_debug () {
     OCD_CMD_FILE=.openocd_cmds
 
     windows_detect
+    parse_extra_jtag_cmd $EXTRA_JTAG_CMD
 
-    echo "gdb_port 3333" > $OCD_CMD_FILE
-    echo "telnet_port 4444" >> $OCD_CMD_FILE
+    echo "gdb_port $PORT" > $OCD_CMD_FILE
+    echo "telnet_port $(($PORT+1))" >> $OCD_CMD_FILE
     echo "$EXTRA_JTAG_CMD" >> $OCD_CMD_FILE
 
     if [ -z "$NO_GDB" ]; then
@@ -101,7 +104,7 @@ openocd_debug () {
 
         GDB_CMD_FILE=.gdb_cmds
 
-        echo "target remote localhost:3333" > $GDB_CMD_FILE
+        echo "target remote localhost:$PORT" > $GDB_CMD_FILE
         if [ ! -z "$RESET" ]; then
             echo "mon reset halt" >> $GDB_CMD_FILE
         fi


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services