You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2017/03/24 23:15:26 UTC

[04/50] [abbrv] incubator-mynewt-core git commit: scripts; pathnames need to be converted when calling cmd.exe. CMDSPEC not set when using win-bash.

scripts; pathnames need to be converted when calling cmd.exe.
CMDSPEC not set when using win-bash.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/567a360f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/567a360f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/567a360f

Branch: refs/heads/nrf_cputime
Commit: 567a360fe0c4eb8f0d5d1c15585b6805e3559c27
Parents: 56444ed
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Sat Mar 4 19:07:48 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Mar 10 13:10:53 2017 -0800

----------------------------------------------------------------------
 hw/scripts/common.sh  | 15 +++++++++++++++
 hw/scripts/jlink.sh   | 30 +++++++++++++-----------------
 hw/scripts/openocd.sh | 16 ++++++++--------
 3 files changed, 36 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/567a360f/hw/scripts/common.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/common.sh b/hw/scripts/common.sh
index 06b6f2b..ee85a90 100644
--- a/hw/scripts/common.sh
+++ b/hw/scripts/common.sh
@@ -28,3 +28,18 @@ common_file_to_load () {
         FILE_NAME=$BIN_BASENAME.img
     fi
 }
+
+#
+# Check if this is executing in Windows. If so, set variable WINDOWS to 1.
+# Also check if $COMSPEC is set or not.
+#
+windows_detect() {
+    BUILD_OS=`uname`
+    WINDOWS=0
+    if [ $BUILD_OS = "Windows_NT" ]; then
+	WINDOWS=1
+    fi
+    if [ $WINDOWS -eq 1 -a -z "$COMSPEC" ]; then
+	COMSPEC=cmd.exe
+    fi
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/567a360f/hw/scripts/jlink.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/jlink.sh b/hw/scripts/jlink.sh
index 2f3fbe8..7b35017 100644
--- a/hw/scripts/jlink.sh
+++ b/hw/scripts/jlink.sh
@@ -17,15 +17,6 @@
 
 . $CORE_PATH/hw/scripts/common.sh
 
-if which JLinkGDBServerCL >/dev/null 2>&1; then
-  JLINK_GDB_SERVER=JLinkGDBServerCL
-elif which JLinkGDBServer >/dev/null 2>&1; then
-  JLINK_GDB_SERVER=JLinkGDBServer
-else
-  echo "Cannot find JLinkGDBServer, make sure J-Link tools are in your PATH"
-  exit 1
-fi
-
 #
 # FILE_NAME is the file to load
 # FLASH_OFFSET is location in the flash
@@ -35,6 +26,10 @@ jlink_load () {
     GDB_CMD_FILE=.gdb_cmds
     GDB_OUT_FILE=.gdb_out
 
+    windows_detect
+    if [ $WINDOWS -eq 1 ]; then
+	JLINK_GDB_SERVER=JLinkGDBServerCL
+    fi
     if [ -z $FILE_NAME ]; then
         echo "Missing filename"
         exit 1
@@ -104,6 +99,11 @@ jlink_load () {
 # RESET is set if we should reset the target at attach time
 #
 jlink_debug() {
+    windows_detect
+    if [ $WINDOWS -eq 1 ]; then
+	JLINK_GDB_SERVER=JLinkGDBServerCL
+    fi
+
     if [ -z "$NO_GDB" ]; then
         GDB_CMD_FILE=.gdb_cmds
 
@@ -118,12 +118,12 @@ jlink_debug() {
 
         echo "Debugging" $FILE_NAME
 
-        if [ -x "$COMSPEC" ]; then
+        if [ $WINDOWS -eq 1 ]; then
             #
             # 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"
+            $COMSPEC "/C start $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun"
         else
             #
             # Block Ctrl-C from getting passed to jlink server.
@@ -141,12 +141,8 @@ jlink_debug() {
         fi
         echo "$EXTRA_GDB_CMDS" >> $GDB_CMD_FILE
 
-        if [ -x "$COMSPEC" ]; then
-            $COMSPEC /C "start $COMSPEC /C arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME"
-        else
-            arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-            rm $GDB_CMD_FILE
-        fi
+        arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+        rm $GDB_CMD_FILE
     else
         $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun
     fi

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/567a360f/hw/scripts/openocd.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/openocd.sh b/hw/scripts/openocd.sh
index e838bcd..a20e451 100644
--- a/hw/scripts/openocd.sh
+++ b/hw/scripts/openocd.sh
@@ -62,6 +62,8 @@ openocd_load () {
 openocd_debug () {
     OCD_CMD_FILE=.openocd_cmds
 
+    windows_detect
+
     echo "gdb_port 3333" > $OCD_CMD_FILE
     echo "telnet_port 4444" >> $OCD_CMD_FILE
     echo "$EXTRA_JTAG_CMD" >> $OCD_CMD_FILE
@@ -76,12 +78,14 @@ openocd_debug () {
             exit 1
         fi
 
-        if [ -x "$COMSPEC" ]; then
+        if [ $WINDOWS -eq 1 ]; then
             #
             # Launch openocd in a separate command interpreter, to make sure
             # it doesn't get killed by Ctrl-C signal from bash.
             #
-            $COMSPEC /C "start $COMSPEC /C openocd $CFG -f $OCD_CMD_FILE -c init -c halt"
+            CFG=`echo $CFG | sed 's/\//\\\\/g'`
+            echo $CFG
+            $COMSPEC "/C start openocd openocd $CFG -f $OCD_CMD_FILE -c init -c halt"
         else
             #
             # Block Ctrl-C from getting passed to openocd.
@@ -97,12 +101,8 @@ openocd_debug () {
         if [ ! -z "$RESET" ]; then
             echo "mon reset halt" >> $GDB_CMD_FILE
         fi
-        if [ -x "$COMSPEC" ]; then
-            $COMSPEC /C "start $COMSPEC /C arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME"
-        else
-            arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-            rm $GDB_CMD_FILE
-        fi
+        arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+        rm $GDB_CMD_FILE
     else
         # No GDB, wait for openocd to exit
         openocd $CFG -f $OCD_CMD_FILE -c init -c halt