You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/11/04 04:37:59 UTC

[01/13] incubator-mynewt-core git commit: debug script openocd; return error code from openocd when starting it without gdb.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 2820439e0 -> 14883ec82


debug script openocd; return error code from openocd when starting it
without gdb.


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/9b8642c4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9b8642c4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9b8642c4

Branch: refs/heads/develop
Commit: 9b8642c42858bc9c53835b81fb5db17ba30de642
Parents: 4a88d96
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 21:30:33 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/scripts/openocd.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9b8642c4/hw/scripts/openocd.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/openocd.sh b/hw/scripts/openocd.sh
index 4d6fc2e..f2335c6 100644
--- a/hw/scripts/openocd.sh
+++ b/hw/scripts/openocd.sh
@@ -83,9 +83,9 @@ openocd_debug () {
     else
 	# No GDB, wait for openocd to exit
 	openocd $CFG -f $OCD_CMD_FILE -c init -c halt
+	return $?
     fi
 
-
     rm $OCD_CMD_FILE
     return 0
 }


[11/13] incubator-mynewt-core git commit: MYNEWT-418; nrf51/nrf52 bsps to use common download/debug functions.

Posted by ma...@apache.org.
MYNEWT-418; nrf51/nrf52 bsps to use common download/debug functions.


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/3662f262
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3662f262
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3662f262

Branch: refs/heads/develop
Commit: 3662f2628d7216e7c0f0ee051bd24e78151f621b
Parents: d7bbbf9
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 16:09:59 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/bsp/bmd300eval/bmd300eval_debug.sh           | 32 +++----
 hw/bsp/bmd300eval/bmd300eval_download.sh        | 80 ++---------------
 .../nrf51-arduino_101/nrf51dk-16kbram_debug.sh  | 27 ++----
 .../nrf51dk-16kbram_download.sh                 | 84 ++----------------
 hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh | 27 ++----
 .../nrf51dk-16kbram/nrf51dk-16kbram_download.sh | 90 ++------------------
 hw/bsp/nrf51dk/nrf51dk_debug.sh                 |  4 +-
 hw/bsp/nrf51dk/nrf51dk_download.sh              |  4 +-
 8 files changed, 52 insertions(+), 296 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3662f262/hw/bsp/bmd300eval/bmd300eval_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/bmd300eval/bmd300eval_debug.sh b/hw/bsp/bmd300eval/bmd300eval_debug.sh
index 24a3f20..dbb3918 100755
--- a/hw/bsp/bmd300eval/bmd300eval_debug.sh
+++ b/hw/bsp/bmd300eval/bmd300eval_debug.sh
@@ -18,36 +18,28 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - RESET set if target should be reset when attaching
+#  - NO_GDB set if we should not start gdb to debug
+#
 
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to debug"
-    exit 1
-fi
+. $CORE_PATH/hw/scripts/jlink.sh
 
 FILE_NAME=$BIN_BASENAME.elf
-GDB_CMD_FILE=.gdb_cmds
-
-echo "Debugging" $FILE_NAME
 
-# Monitor mode. Background process gets it's own process group.
-set -m
-JLinkGDBServer -device nRF52 -speed 4000 -if SWD -port 3333 -singlerun > /dev/null &
-set +m
-
-echo "target remote localhost:3333" > $GDB_CMD_FILE
-
-# Whether target should be reset or not
-if [ ! -z "$RESET" ]; then
-    echo "mon reset" >> $GDB_CMD_FILE
+if [ $# -gt 2 ]; then
+    SPLIT_ELF_NAME=$3.elf
+    # TODO -- this magic number 0x42000 is the location of the second image
+    # slot. we should either get this from a flash map file or somehow learn
+    # this from the image itself
+    EXTRA_GDB_CMDS="add-symbol-file $SPLIT_ELF_NAME 0x8000 -readnow"
 fi
 
-arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-
-rm $GDB_CMD_FILE
+JLINK_DEV="nRF52"
 
+jlink_debug

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3662f262/hw/bsp/bmd300eval/bmd300eval_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/bmd300eval/bmd300eval_download.sh b/hw/bsp/bmd300eval/bmd300eval_download.sh
index b5e6537..08d45b4 100755
--- a/hw/bsp/bmd300eval/bmd300eval_download.sh
+++ b/hw/bsp/bmd300eval/bmd300eval_download.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,6 +17,7 @@
 # under the License.
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
@@ -24,81 +25,16 @@
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
+#  - FLASH_OFFSET contains the flash offset to download to
+#  - BOOT_LOADER is set if downloading a bootloader
 
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to download"
-    exit 1
-fi
-
-IS_BOOTLOADER=0
-GDB_CMD_FILE=.gdb_cmds
-
-# Look for 'bootloader' in FEATURES
-for feature in $FEATURES; do
-    if [ $feature == "BOOT_LOADER" ]; then
-        IS_BOOTLOADER=1
-    fi
-done
+. $CORE_PATH/hw/scripts/jlink.sh
 
 if [ "$MFG_IMAGE" ]; then
     FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.bin
-elif [ $IS_BOOTLOADER -eq 1 ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.elf.bin
-elif [ $IMAGE_SLOT -eq 0 ]; then
-    FLASH_OFFSET=0x8000
-    FILE_NAME=$BIN_BASENAME.img
-elif [ $IMAGE_SLOT -eq 1 ]; then
-    FLASH_OFFSET=0x42000
-    FILE_NAME=$BIN_BASENAME.img
-else 
-    echo "Invalid Image Slot Number: $IMAGE_SLOT"
-    exit 1
-fi
-
-echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
-
-if [ ! -f $FILE_NAME ]; then
-    echo "File " $FILE_NAME "not found"
-    exit 1
 fi
 
-# XXX for some reason JLinkExe overwrites flash at offset 0 when
-# 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 /bin/sh -c 'trap \"\" 2;JLinkGDBServer -device nRF52 -speed 4000 -if SWD -port 3333 -singlerun' & " > $GDB_CMD_FILE
-echo "target remote localhost:3333" >> $GDB_CMD_FILE
-echo "restore $FILE_NAME binary $FLASH_OFFSET" >> $GDB_CMD_FILE
-echo "quit" >> $GDB_CMD_FILE
-
-msgs=`arm-none-eabi-gdb -x $GDB_CMD_FILE 2>&1`
-echo $msgs > .gdb_out
-
-rm $GDB_CMD_FILE
-
-# Echo output from script run, so newt can show it if things go wrong.
-echo $msgs
-
-error=`echo $msgs | grep error`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i failed`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "unknown / supported"`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "not found"`
-if [ -n "$error" ]; then
-    exit 1
-fi
+JLINK_DEV="nRF52"
 
-exit 0
+common_file_to_load
+jlink_load

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3662f262/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_debug.sh b/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_debug.sh
index db73ad3..7b919c7 100755
--- a/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_debug.sh
+++ b/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_debug.sh
@@ -18,34 +18,19 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - RESET set if target should be reset when attaching
+#  - NO_GDB set if we should not start gdb to debug
 #
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to debug"
-    exit 1
-fi
 
-FILE_NAME=$BIN_BASENAME.elf
-GDB_CMD_FILE=.gdb_cmds
-
-echo "Debugging" $FILE_NAME
-
-set -m
-JLinkGDBServer -device nRF51422_xxAC -speed 4000 -if SWD -port 3333 -singlerun > /dev/null &
-set +m
+. $CORE_PATH/hw/scripts/jlink.sh
 
-echo "target remote localhost:3333" > $GDB_CMD_FILE
-
-# Whether target should be reset or not
-if [ ! -z "$RESET" ]; then
-    echo "mon reset" >> $GDB_CMD_FILE
-fi
-
-arm-none-eabi-gdb --tui -x $GDB_CMD_FILE $FILE_NAME
+FILE_NAME=$BIN_BASENAME.elf
+JLINK_DEV="nRF51422_xxAC"
 
-rm $GDB_CMD_FILE
+jlink_debug

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3662f262/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_download.sh b/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_download.sh
index 35fd647..3e552e2 100755
--- a/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_download.sh
+++ b/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_download.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -18,6 +18,7 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
@@ -25,85 +26,16 @@
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
+#  - FLASH_OFFSET contains the flash offset to download to
+#  - BOOT_LOADER is set if downloading a bootloader
 
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to download"
-    exit 1
-fi
-
-IS_BOOTLOADER=0
-#JLINK_SCRIPT=.download.jlink
-GDB_CMD_FILE=.gdb_cmds
-
-# Look for 'bootloader' in FEATURES
-for feature in $FEATURES; do
-    if [ $feature == "BOOT_LOADER" ]; then
-        IS_BOOTLOADER=1
-    fi
-done
+. $CORE_PATH/hw/scripts/jlink.sh
 
 if [ "$MFG_IMAGE" ]; then
     FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.bin
-elif [ $IS_BOOTLOADER -eq 1 ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.elf.bin
-else
-    FLASH_OFFSET=0x8000
-    FILE_NAME=$BIN_BASENAME.img
 fi
 
-echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
-
-if [ ! -f $FILE_NAME ]; then
-    echo "File " $FILE_NAME "not found"
-    exit 1
-fi
-
-# XXX for some reason JLinkExe overwrites flash at offset 0 when
-# 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 /bin/sh -c 'trap \"\" 2;JLinkGDBServer -device nRF51422_xxAC -speed 4000 -if SWD -port 3333 -singlerun' & " > $GDB_CMD_FILE
-echo "target remote localhost:3333" >> $GDB_CMD_FILE
-echo "restore $FILE_NAME binary $FLASH_OFFSET" >> $GDB_CMD_FILE
-echo "quit" >> $GDB_CMD_FILE
-
-msgs=`arm-none-eabi-gdb -x $GDB_CMD_FILE 2>&1`
-echo $msgs > .gdb_out
-
-rm $GDB_CMD_FILE
-
-#cat > $JLINK_SCRIPT <<EOF
-#w 4001e504 1
-#loadbin $FILE_NAME,$FLASH_OFFSET
-#q
-#EOF
-
-#msgs=`JLinkExe -device nRF51422_xxAC -speed 4000 -if SWD $JLINK_SCRIPT`
-
-# Echo output from script run, so newt can show it if things go wrong.
-echo $msgs
-#rm $JLINK_SCRIPT
-
-error=`echo $msgs | grep error`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i failed`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "unknown / supported"`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "not found"`
-if [ -n "$error" ]; then
-    exit 1
-fi
+JLINK_DEV="nRF51422_xxAC"
 
-exit 0
+common_file_to_load
+jlink_load

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3662f262/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh
index dadc91f..9830fed 100755
--- a/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh
+++ b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh
@@ -18,34 +18,19 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - RESET set if target should be reset when attaching
+#  - NO_GDB set if we should not start gdb to debug
 #
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to debug"
-    exit 1
-fi
 
-FILE_NAME=$BIN_BASENAME.elf
-GDB_CMD_FILE=.gdb_cmds
-
-echo "Debugging" $FILE_NAME
-
-set -m
-JLinkGDBServer -device nRF51422_xxAC -speed 4000 -if SWD -port 3333 -singlerun > /dev/null &
-set +m
+. $CORE_PATH/hw/scripts/jlink.sh
 
-echo "target remote localhost:3333" > $GDB_CMD_FILE
-# Whether target should be reset or not
-if [ ! -z "$RESET" ]; then
-    echo "mon reset" >> $GDB_CMD_FILE
-fi
-
-arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-
-rm $GDB_CMD_FILE
+FILE_NAME=$BIN_BASENAME.elf
+JLINK_DEV="nRF51422_xxAC"
 
+jlink_debug

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3662f262/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh
index 8fc8055..fc83a27 100755
--- a/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh
+++ b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -18,6 +18,7 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
@@ -25,91 +26,16 @@
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
+#  - FLASH_OFFSET contains the flash offset to download to
+#  - BOOT_LOADER is set if downloading a bootloader
 
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to download"
-    exit 1
-fi
-
-IS_BOOTLOADER=0
-#JLINK_SCRIPT=.download.jlink
-GDB_CMD_FILE=.gdb_cmds
-
-# Look for 'bootloader' in FEATURES
-for feature in $FEATURES; do
-    if [ $feature == "BOOT_LOADER" ]; then
-        IS_BOOTLOADER=1
-    fi
-done
+. $CORE_PATH/hw/scripts/jlink.sh
 
 if [ "$MFG_IMAGE" ]; then
     FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.bin
-elif [ $IS_BOOTLOADER -eq 1 ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.elf.bin
-elif [ $IMAGE_SLOT -eq 0 ]; then
-    FLASH_OFFSET=0x8000
-    FILE_NAME=$BIN_BASENAME.img
-elif [ $IMAGE_SLOT -eq 1 ]; then
-    FLASH_OFFSET=0x23800
-    FILE_NAME=$BIN_BASENAME.img
-else
-    echo "Invalid Image Slot Number: $IMAGE_SLOT"
-    exit 1
 fi
 
-echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
-
-if [ ! -f $FILE_NAME ]; then
-    echo "File " $FILE_NAME "not found"
-    exit 1
-fi
-
-# XXX for some reason JLinkExe overwrites flash at offset 0 when
-# 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 /bin/sh -c 'trap \"\" 2;JLinkGDBServer -device nRF51422_xxAC -speed 4000 -if SWD -port 3333 -singlerun' & " > $GDB_CMD_FILE
-echo "target remote localhost:3333" >> $GDB_CMD_FILE
-echo "restore $FILE_NAME binary $FLASH_OFFSET" >> $GDB_CMD_FILE
-echo "quit" >> $GDB_CMD_FILE
-
-msgs=`arm-none-eabi-gdb -x $GDB_CMD_FILE 2>&1`
-echo $msgs > .gdb_out
-
-rm $GDB_CMD_FILE
-
-#cat > $JLINK_SCRIPT <<EOF
-#w 4001e504 1
-#loadbin $FILE_NAME,$FLASH_OFFSET
-#q
-#EOF
-
-#msgs=`JLinkExe -device nRF51422_xxAC -speed 4000 -if SWD $JLINK_SCRIPT`
-
-# Echo output from script run, so newt can show it if things go wrong.
-echo $msgs
-#rm $JLINK_SCRIPT
-
-error=`echo $msgs | grep error`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i failed`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "unknown / supported"`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "not found"`
-if [ -n "$error" ]; then
-    exit 1
-fi
+JLINK_DEV="nRF51422_xxAC"
 
-exit 0
+common_file_to_load
+jlink_load

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3662f262/hw/bsp/nrf51dk/nrf51dk_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/nrf51dk_debug.sh b/hw/bsp/nrf51dk/nrf51dk_debug.sh
index 9830fed..7b919c7 100755
--- a/hw/bsp/nrf51dk/nrf51dk_debug.sh
+++ b/hw/bsp/nrf51dk/nrf51dk_debug.sh
@@ -6,9 +6,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3662f262/hw/bsp/nrf51dk/nrf51dk_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/nrf51dk_download.sh b/hw/bsp/nrf51dk/nrf51dk_download.sh
index fc83a27..3e552e2 100755
--- a/hw/bsp/nrf51dk/nrf51dk_download.sh
+++ b/hw/bsp/nrf51dk/nrf51dk_download.sh
@@ -6,9 +6,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY


[13/13] incubator-mynewt-core git commit: MYNEWT-418; rb-nano2; use common functions for debug/download.

Posted by ma...@apache.org.
MYNEWT-418; rb-nano2; use common functions for debug/download.


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/14883ec8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/14883ec8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/14883ec8

Branch: refs/heads/develop
Commit: 14883ec82ff4e0dd9c8aa7e907c9f16ea2509b2b
Parents: 9b8642c
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 21:37:22 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:37:22 2016 -0700

----------------------------------------------------------------------
 hw/bsp/rb-nano2/rb-nano2_debug.sh    |  35 +++--------
 hw/bsp/rb-nano2/rb-nano2_download.sh | 100 ++++--------------------------
 2 files changed, 20 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/14883ec8/hw/bsp/rb-nano2/rb-nano2_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/rb-nano2/rb-nano2_debug.sh b/hw/bsp/rb-nano2/rb-nano2_debug.sh
index ccaf5fd..4ac2d94 100755
--- a/hw/bsp/rb-nano2/rb-nano2_debug.sh
+++ b/hw/bsp/rb-nano2/rb-nano2_debug.sh
@@ -6,9 +6,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,39 +18,20 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - RESET set if target should be reset when attaching
+#  - NO_GDB set if we should not start gdb to debug
 #
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to debug"
-    exit 1
-fi
-
-if [ -z "$BSP_PATH" ]; then
-    echo "Need BSP path for openocd script location"
-    exit 1
-fi
+. $CORE_PATH/hw/scripts/openocd.sh
 
 FILE_NAME=$BIN_BASENAME.elf
-GDB_CMD_FILE=.gdb_cmds
-
-echo "Debugging" $FILE_NAME
-
-set -m
-openocd -s $BSP_PATH -f cmsis-dap.cfg -f nrf52.cfg -c "nrf52.cpu configure -event gdb-detach {resume;shutdown}" -c "$EXTRA_JTAG_CMD" -c init -c halt &
-set +m
-
-echo "target remote localhost:3333" > $GDB_CMD_FILE
-# Whether target should be reset or not
-if [ ! -z "$RESET" ]; then
-    echo "mon reset" >> $GDB_CMD_FILE
-fi
-
-arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+CFG="-s $BSP_PATH -f cmsis-dap.cfg -f nrf52.cfg"
+EXTRA_JTAG_CMD="$EXTRA_JTAG_CMD; nrf52.cpu configure -event gdb-detach {resume;shutdown}"
 
-rm $GDB_CMD_FILE
+openocd_debug
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/14883ec8/hw/bsp/rb-nano2/rb-nano2_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/rb-nano2/rb-nano2_download.sh b/hw/bsp/rb-nano2/rb-nano2_download.sh
index 31dcdee..f027618 100755
--- a/hw/bsp/rb-nano2/rb-nano2_download.sh
+++ b/hw/bsp/rb-nano2/rb-nano2_download.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -6,9 +6,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,6 +18,7 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
@@ -25,94 +26,17 @@
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
+#  - FLASH_OFFSET contains the flash offset to download to
+#  - BOOT_LOADER is set if downloading a bootloader
 
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to download"
-    exit 1
-fi
-
-IS_BOOTLOADER=0
-#JLINK_SCRIPT=.download.jlink
-GDB_CMD_FILE=.gdb_cmds
+. $CORE_PATH/hw/scripts/openocd.sh
 
-# Look for 'bootloader' in FEATURES
-for feature in $FEATURES; do
-    if [ $feature == "BOOT_LOADER" ]; then
-        IS_BOOTLOADER=1
-    fi
-done
+CFG="-s $BSP_PATH -f cmsis-dap.cfg -f nrf52.cfg"
 
 if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.bin
-elif [ $IS_BOOTLOADER -eq 1 ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.elf.bin
-elif [ $IMAGE_SLOT -eq 0 ]; then
-    FLASH_OFFSET=0x8000
-    FILE_NAME=$BIN_BASENAME.img
-elif [ $IMAGE_SLOT -eq 1 ]; then
-    FLASH_OFFSET=0x23800
-    FILE_NAME=$BIN_BASENAME.img
-else
-    echo "Invalid Image Slot Number: $IMAGE_SLOT"
-    exit 1
-fi
-
-echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
-
-if [ ! -f $FILE_NAME ]; then
-    echo "File " $FILE_NAME "not found"
-    exit 1
-fi
-
-# XXX for some reason JLinkExe overwrites flash at offset 0 when
-# 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 /bin/sh -c 'trap \"\" 2;openocd -s $BSP_PATH -f cmsis-dap.cfg -c \"$EXTRA_JTAG_CMD\" -f nrf52.cfg' &" > $GDB_CMD_FILE
-echo "target remote localhost:3333" >> $GDB_CMD_FILE
-echo "monitor reset halt" >> $GDB_CMD_FILE
-echo "monitor flash write_image erase $FILE_NAME $FLASH_OFFSET" >> $GDB_CMD_FILE
-echo "monitor reset run" >> $GDB_CMD_FILE
-echo "monitor shutdown" >> $GDB_CMD_FILE
-echo "quit" >> $GDB_CMD_FILE
-
-msgs=`arm-none-eabi-gdb -x $GDB_CMD_FILE 2>&1`
-echo $msgs > .gdb_out
-
-rm $GDB_CMD_FILE
-
-#cat > $JLINK_SCRIPT <<EOF
-#w 4001e504 1
-#loadbin $FILE_NAME,$FLASH_OFFSET
-#q
-#EOF
-
-#msgs=`JLinkExe -device nRF52 -speed 4000 -if SWD $JLINK_SCRIPT`
-
-# Echo output from script run, so newt can show it if things go wrong.
-echo $msgs
-#rm $JLINK_SCRIPT
-
-error=`echo $msgs | grep error | grep -v Ignoring`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i failed`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "unknown / supported"`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "not found"`
-if [ -n "$error" ]; then
-    exit 1
+    FLASH_OFFSET=0
 fi
 
-exit 0
+common_file_to_load
+openocd_load
+openocd_reset_run


[12/13] incubator-mynewt-core git commit: MYNEWT-418; frdm-k64f - update debug/download to use environment variables. Use common function to figure out what file to load.

Posted by ma...@apache.org.
MYNEWT-418; frdm-k64f - update debug/download to use environment
variables. Use common function to figure out what file to load.


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/f453bd29
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f453bd29
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f453bd29

Branch: refs/heads/develop
Commit: f453bd2916b407d76709cdf09e039012408b0bfe
Parents: f971e8a
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 21:27:34 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/bsp/frdm-k64f/frdm-k64_debug.sh    | 21 ++++++++++---------
 hw/bsp/frdm-k64f/frdm-k64_download.sh | 33 +++++++-----------------------
 2 files changed, 18 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f453bd29/hw/bsp/frdm-k64f/frdm-k64_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/frdm-k64f/frdm-k64_debug.sh b/hw/bsp/frdm-k64f/frdm-k64_debug.sh
index b387d9c..5d8159b 100755
--- a/hw/bsp/frdm-k64f/frdm-k64_debug.sh
+++ b/hw/bsp/frdm-k64f/frdm-k64_debug.sh
@@ -16,18 +16,19 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Called: $0 <bsp_directory_path> <binary> [features...]
-#  - bsp_directory_path is absolute path to hw/bsp/bsp_name
-#  - binary is the path to prefix to target binary, .elf appended to name is
-#    the ELF file
-#  - identities is the project identities string.
+
+# Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
+#  - BSP_PATH is absolute path to hw/bsp/bsp_name
+#  - BIN_BASENAME is the path to prefix to target binary,
+#    .elf appended to name is the ELF file
+#  - FEATURES holds the target features string
+#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
+#  - RESET set if target should be reset when attaching
+#  - NO_GDB set if we should not start gdb to debug
 #
-if [ $# -lt 1 ]; then
-    echo "Need binary to debug"
-    exit 1
-fi
 
-FILE_NAME=$2.elf
+FILE_NAME=$BIN_BASENAME.elf
 GDB_CMD_FILE=.gdb_cmds
 
 echo "Debugging" $FILE_NAME

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f453bd29/hw/bsp/frdm-k64f/frdm-k64_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/frdm-k64f/frdm-k64_download.sh b/hw/bsp/frdm-k64f/frdm-k64_download.sh
index fccd7e0..84d1dbc 100755
--- a/hw/bsp/frdm-k64f/frdm-k64_download.sh
+++ b/hw/bsp/frdm-k64f/frdm-k64_download.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,6 +17,7 @@
 # under the License.
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
@@ -24,35 +25,15 @@
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
+#  - FLASH_OFFSET contains the flash offset to download to
+#  - BOOT_LOADER is set if downloading a bootloader
 
-if [ -z "${BIN_BASENAME}" ]; then
-    echo "Need binary to download"
-    exit 1
-fi
-
-IS_BOOTLOADER=0
-USE_OPENOCD=0
-GDB_CMD_FILE=.gdb_cmds
+. $CORE_PATH/hw/scripts/openocd.sh
 
-# Look for 'bootloader' in FEATURES
-for feature in ${FEATURES}; do
-    if [ ${feature} == "BOOT_LOADER" ]; then
-        IS_BOOTLOADER=1
-    fi
-    if [ ${feature} = "openocd_debug" ]; then
-        USE_OPENOCD=1
-    fi
-done
+common_file_to_load
 
 if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.bin
-elif [ $IS_BOOTLOADER -eq 1 ]; then
-    FLASH_OFFSET=0x00000000
-    FILE_NAME=${BIN_BASENAME}.elf.bin
-else
-    FLASH_OFFSET=0x00008000
-    FILE_NAME=${BIN_BASENAME}.elf.bin
+    FLASH_OFFSET=0
 fi
 
 echo "Downloading" ${FILE_NAME} "to" ${FLASH_OFFSET}


[06/13] incubator-mynewt-core git commit: MYNEWT-418 - nrf52dk use common functions for debug/download.

Posted by ma...@apache.org.
MYNEWT-418 - nrf52dk use common functions for debug/download.


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/82fdbc2c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/82fdbc2c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/82fdbc2c

Branch: refs/heads/develop
Commit: 82fdbc2c3117572148c59c025daa1482fbb6f1c8
Parents: 6ba3b4b
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 15:31:24 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/bsp/nrf52dk/nrf52dk_debug.sh    | 39 +++++-----------
 hw/bsp/nrf52dk/nrf52dk_download.sh | 80 ++++-----------------------------
 2 files changed, 19 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/82fdbc2c/hw/bsp/nrf52dk/nrf52dk_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/nrf52dk_debug.sh b/hw/bsp/nrf52dk/nrf52dk_debug.sh
index 31a1b2c..cce04c6 100755
--- a/hw/bsp/nrf52dk/nrf52dk_debug.sh
+++ b/hw/bsp/nrf52dk/nrf52dk_debug.sh
@@ -18,48 +18,31 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - RESET set if target should be reset when attaching
+#  - NO_GDB set if we should not start gdb to debug
 #
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to debug"
-    exit 1
-fi
+
+. $CORE_PATH/hw/scripts/jlink.sh
 
 FILE_NAME=$BIN_BASENAME.elf
 
-SPLIT_ELF_PRESENT=0
 if [ $# -gt 2 ]; then
-    SPLIT_ELF_PRESENT=1
     SPLIT_ELF_NAME=$3.elf
+    # TODO -- this magic number 0x42000 is the location of the second image
+    # slot. we should either get this from a flash map file or somehow learn
+    # this from the image itself
+    EXTRA_GDB_CMDS="add-symbol-file $SPLIT_ELF_NAME 0x8000 -readnow"
 fi
 
-GDB_CMD_FILE=.gdb_cmds
-
-echo "Debugging" $FILE_NAME
-
-# Monitor mode. Background process gets it's own process group.
-set -m
-JLinkGDBServer -device nRF52 -speed 4000 -if SWD -port 3333 -singlerun > /dev/null &
-set +m
+JLINK_DEV="nRF52"
 
-echo "target remote localhost:3333" > $GDB_CMD_FILE
-# Whether target should be reset or not
-if [ ! -z "$RESET" ]; then
-    echo "mon reset" >> $GDB_CMD_FILE
-    echo "si" >> $GDB_CMD_FILE
-fi
-if [ $SPLIT_ELF_PRESENT -eq 1 ]; then
-    # TODO -- this magic number 0x42000 is the location of the second image slot.
-    # we should either get this from a flash map file or somehow learn this from the image itself
-    echo "add-symbol-file $SPLIT_ELF_NAME 0x8000 -readnow" >> $GDB_CMD_FILE
-fi
-
-arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+GDB_CMD_FILE=.gdb_cmds
 
-rm $GDB_CMD_FILE
+jlink_debug
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/82fdbc2c/hw/bsp/nrf52dk/nrf52dk_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/nrf52dk_download.sh b/hw/bsp/nrf52dk/nrf52dk_download.sh
index b5e6537..08d45b4 100755
--- a/hw/bsp/nrf52dk/nrf52dk_download.sh
+++ b/hw/bsp/nrf52dk/nrf52dk_download.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,6 +17,7 @@
 # under the License.
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
@@ -24,81 +25,16 @@
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
+#  - FLASH_OFFSET contains the flash offset to download to
+#  - BOOT_LOADER is set if downloading a bootloader
 
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to download"
-    exit 1
-fi
-
-IS_BOOTLOADER=0
-GDB_CMD_FILE=.gdb_cmds
-
-# Look for 'bootloader' in FEATURES
-for feature in $FEATURES; do
-    if [ $feature == "BOOT_LOADER" ]; then
-        IS_BOOTLOADER=1
-    fi
-done
+. $CORE_PATH/hw/scripts/jlink.sh
 
 if [ "$MFG_IMAGE" ]; then
     FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.bin
-elif [ $IS_BOOTLOADER -eq 1 ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.elf.bin
-elif [ $IMAGE_SLOT -eq 0 ]; then
-    FLASH_OFFSET=0x8000
-    FILE_NAME=$BIN_BASENAME.img
-elif [ $IMAGE_SLOT -eq 1 ]; then
-    FLASH_OFFSET=0x42000
-    FILE_NAME=$BIN_BASENAME.img
-else 
-    echo "Invalid Image Slot Number: $IMAGE_SLOT"
-    exit 1
-fi
-
-echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
-
-if [ ! -f $FILE_NAME ]; then
-    echo "File " $FILE_NAME "not found"
-    exit 1
 fi
 
-# XXX for some reason JLinkExe overwrites flash at offset 0 when
-# 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 /bin/sh -c 'trap \"\" 2;JLinkGDBServer -device nRF52 -speed 4000 -if SWD -port 3333 -singlerun' & " > $GDB_CMD_FILE
-echo "target remote localhost:3333" >> $GDB_CMD_FILE
-echo "restore $FILE_NAME binary $FLASH_OFFSET" >> $GDB_CMD_FILE
-echo "quit" >> $GDB_CMD_FILE
-
-msgs=`arm-none-eabi-gdb -x $GDB_CMD_FILE 2>&1`
-echo $msgs > .gdb_out
-
-rm $GDB_CMD_FILE
-
-# Echo output from script run, so newt can show it if things go wrong.
-echo $msgs
-
-error=`echo $msgs | grep error`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i failed`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "unknown / supported"`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "not found"`
-if [ -n "$error" ]; then
-    exit 1
-fi
+JLINK_DEV="nRF52"
 
-exit 0
+common_file_to_load
+jlink_load


[04/13] incubator-mynewt-core git commit: Fix incorrect env variable name in comments

Posted by ma...@apache.org.
Fix incorrect env variable name in comments


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/9112760e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9112760e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9112760e

Branch: refs/heads/develop
Commit: 9112760e25d3d83ae41ea4299eb225b2e319698d
Parents: 2820439
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 15:26:37 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/bsp/nucleo-f401re/nucleo-f401re_download.sh                     | 2 +-
 .../olimex_stm32-e407_devboard_download.sh                         | 2 +-
 hw/bsp/stm32f4discovery/stm32f4discovery_download.sh               | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9112760e/hw/bsp/nucleo-f401re/nucleo-f401re_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nucleo-f401re/nucleo-f401re_download.sh b/hw/bsp/nucleo-f401re/nucleo-f401re_download.sh
index def6af4..0666699 100755
--- a/hw/bsp/nucleo-f401re/nucleo-f401re_download.sh
+++ b/hw/bsp/nucleo-f401re/nucleo-f401re_download.sh
@@ -27,7 +27,7 @@
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
 #  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOTLOADER is set if downloading a bootloader
+#  - BOOT_LOADER is set if downloading a bootloader
 
 . $CORE_PATH/hw/scripts/openocd.sh
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9112760e/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
index e46b4c3..9ee17c4 100755
--- a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
+++ b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
@@ -26,7 +26,7 @@
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
 #  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOTLOADER is set if downloading a bootloader
+#  - BOOT_LOADER is set if downloading a bootloader
 
 . $CORE_PATH/hw/scripts/openocd.sh
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9112760e/hw/bsp/stm32f4discovery/stm32f4discovery_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f4discovery/stm32f4discovery_download.sh b/hw/bsp/stm32f4discovery/stm32f4discovery_download.sh
index 4eacf2a..7a30cf5 100755
--- a/hw/bsp/stm32f4discovery/stm32f4discovery_download.sh
+++ b/hw/bsp/stm32f4discovery/stm32f4discovery_download.sh
@@ -27,7 +27,7 @@
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
 #  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOTLOADER is set if downloading a bootloader
+#  - BOOT_LOADER is set if downloading a bootloader
 . $CORE_PATH/hw/scripts/openocd.sh
 
 CFG="-s $BSP_PATH -f f4discovery.cfg"


[10/13] incubator-mynewt-core git commit: stm32f4discovery debug script; remove unnecessary command.

Posted by ma...@apache.org.
stm32f4discovery debug script; remove unnecessary command.


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/f3d4146e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f3d4146e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f3d4146e

Branch: refs/heads/develop
Commit: f3d4146eed70febe8a66566f684f0881c5b16a37
Parents: f453bd2
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 21:28:52 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/bsp/stm32f4discovery/stm32f4discovery_debug.sh | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3d4146e/hw/bsp/stm32f4discovery/stm32f4discovery_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f4discovery/stm32f4discovery_debug.sh b/hw/bsp/stm32f4discovery/stm32f4discovery_debug.sh
index 400157b..12a79f1 100755
--- a/hw/bsp/stm32f4discovery/stm32f4discovery_debug.sh
+++ b/hw/bsp/stm32f4discovery/stm32f4discovery_debug.sh
@@ -34,5 +34,3 @@ CFG="-s $BSP_PATH -f $BSP_PATH/f4discovery.cfg -f $OCD_CMD_FILE"
 EXTRA_JTAG_CMD="$EXTRA_JTAG_CMD; stm32f4x.cpu configure -event gdb-detach {resume;shutdown}"
 
 openocd_debug
-
-rm $OCD_CMD_FILE


[02/13] incubator-mynewt-core git commit: debug scripts jlink; add explanation about why we parse out of jlinkGDBServer as opposed to looking return code when figuring out if things worked or not.

Posted by ma...@apache.org.
debug scripts jlink; add explanation about why we parse out of jlinkGDBServer
as opposed to looking return code when figuring out if things worked or not.


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/4a88d960
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4a88d960
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4a88d960

Branch: refs/heads/develop
Commit: 4a88d9606f9f330167ae5839aac49a5e4542f031
Parents: f3d4146
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 21:29:34 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/scripts/jlink.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4a88d960/hw/scripts/jlink.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/jlink.sh b/hw/scripts/jlink.sh
index 542b63d..0f85810 100644
--- a/hw/scripts/jlink.sh
+++ b/hw/scripts/jlink.sh
@@ -54,9 +54,12 @@ jlink_load () {
     msgs=`arm-none-eabi-gdb -x $GDB_CMD_FILE 2>&1`
     echo $msgs > $GDB_OUT_FILE
 
-#    rm $GDB_CMD_FILE
+    rm $GDB_CMD_FILE
 
     # Echo output from script run, so newt can show it if things go wrong.
+    # JLinkGDBServer always exits with non-zero error code, regardless of
+    # whether there was an error during execution of it or not. So we cannot
+    # use it.
     echo $msgs
 
     error=`echo $msgs | grep error`


[08/13] incubator-mynewt-core git commit: MYNEWT-418; nrf51dk use common functions for debug/download.

Posted by ma...@apache.org.
MYNEWT-418; nrf51dk use common functions for debug/download.


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/d7bbbf92
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d7bbbf92
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d7bbbf92

Branch: refs/heads/develop
Commit: d7bbbf92946b03a9649423ac978da641b3d4b0b2
Parents: 46f9bb4
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 15:47:59 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/bsp/nrf51dk/nrf51dk_debug.sh    | 27 +++-------
 hw/bsp/nrf51dk/nrf51dk_download.sh | 91 +++------------------------------
 2 files changed, 14 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d7bbbf92/hw/bsp/nrf51dk/nrf51dk_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/nrf51dk_debug.sh b/hw/bsp/nrf51dk/nrf51dk_debug.sh
index dadc91f..9830fed 100755
--- a/hw/bsp/nrf51dk/nrf51dk_debug.sh
+++ b/hw/bsp/nrf51dk/nrf51dk_debug.sh
@@ -18,34 +18,19 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - RESET set if target should be reset when attaching
+#  - NO_GDB set if we should not start gdb to debug
 #
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to debug"
-    exit 1
-fi
 
-FILE_NAME=$BIN_BASENAME.elf
-GDB_CMD_FILE=.gdb_cmds
-
-echo "Debugging" $FILE_NAME
-
-set -m
-JLinkGDBServer -device nRF51422_xxAC -speed 4000 -if SWD -port 3333 -singlerun > /dev/null &
-set +m
+. $CORE_PATH/hw/scripts/jlink.sh
 
-echo "target remote localhost:3333" > $GDB_CMD_FILE
-# Whether target should be reset or not
-if [ ! -z "$RESET" ]; then
-    echo "mon reset" >> $GDB_CMD_FILE
-fi
-
-arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-
-rm $GDB_CMD_FILE
+FILE_NAME=$BIN_BASENAME.elf
+JLINK_DEV="nRF51422_xxAC"
 
+jlink_debug

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d7bbbf92/hw/bsp/nrf51dk/nrf51dk_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/nrf51dk_download.sh b/hw/bsp/nrf51dk/nrf51dk_download.sh
index 7148e78..fc83a27 100755
--- a/hw/bsp/nrf51dk/nrf51dk_download.sh
+++ b/hw/bsp/nrf51dk/nrf51dk_download.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -18,6 +18,7 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
@@ -25,92 +26,16 @@
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
+#  - FLASH_OFFSET contains the flash offset to download to
+#  - BOOT_LOADER is set if downloading a bootloader
 
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to download"
-    exit 1
-fi
-
-IS_BOOTLOADER=0
-#JLINK_SCRIPT=.download.jlink
-GDB_CMD_FILE=.gdb_cmds
-
-# Look for 'bootloader' in FEATURES
-for feature in $FEATURES; do
-    if [ $feature == "BOOT_LOADER" ]; then
-        IS_BOOTLOADER=1
-    fi
-done
+. $CORE_PATH/hw/scripts/jlink.sh
 
 if [ "$MFG_IMAGE" ]; then
     FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.bin
-elif [ $IS_BOOTLOADER -eq 1 ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.elf.bin
-elif [ $IMAGE_SLOT -eq 0 ]; then
-    FLASH_OFFSET=0x8000
-    FILE_NAME=$BIN_BASENAME.img
-elif [ $IMAGE_SLOT -eq 1 ]; then
-    FLASH_OFFSET=0x23800
-    FILE_NAME=$BIN_BASENAME.img
-else
-    echo "Invalid Image Slot Number: $IMAGE_SLOT"
-    exit 1
-fi
-
-
-echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
-
-if [ ! -f $FILE_NAME ]; then
-    echo "File " $FILE_NAME "not found"
-    exit 1
-fi
-
-# XXX for some reason JLinkExe overwrites flash at offset 0 when
-# 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 /bin/sh -c 'trap \"\" 2;JLinkGDBServer -device nRF51422_xxAC -speed 4000 -if SWD -port 3333 -singlerun' & " > $GDB_CMD_FILE
-echo "target remote localhost:3333" >> $GDB_CMD_FILE
-echo "restore $FILE_NAME binary $FLASH_OFFSET" >> $GDB_CMD_FILE
-echo "quit" >> $GDB_CMD_FILE
-
-msgs=`arm-none-eabi-gdb -x $GDB_CMD_FILE 2>&1`
-echo $msgs > .gdb_out
-
-rm $GDB_CMD_FILE
-
-#cat > $JLINK_SCRIPT <<EOF
-#w 4001e504 1
-#loadbin $FILE_NAME,$FLASH_OFFSET
-#q
-#EOF
-
-#msgs=`JLinkExe -device nRF51422_xxAC -speed 4000 -if SWD $JLINK_SCRIPT`
-
-# Echo output from script run, so newt can show it if things go wrong.
-echo $msgs
-#rm $JLINK_SCRIPT
-
-error=`echo $msgs | grep error`
-if [ -n "$error" ]; then
-    exit 1
 fi
 
-error=`echo $msgs | grep -i failed`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "unknown / supported"`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "not found"`
-if [ -n "$error" ]; then
-    exit 1
-fi
+JLINK_DEV="nRF51422_xxAC"
 
-exit 0
+common_file_to_load
+jlink_load


[03/13] incubator-mynewt-core git commit: primo bsp; needs timer0 to boot, and uart1 for console. Enable them by default. Needs OPENOCD_DEBUG declared to choose between jlink and openocd.

Posted by ma...@apache.org.
primo bsp; needs timer0 to boot, and uart1 for console. Enable them by
default.
Needs OPENOCD_DEBUG declared to choose between jlink and openocd.


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/9e39286f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9e39286f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9e39286f

Branch: refs/heads/develop
Commit: 9e39286f000fe18d95e89fef760eee2b8546391f
Parents: 3662f26
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 21:20:17 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/bsp/arduino_primo_nrf52/syscfg.yml | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9e39286f/hw/bsp/arduino_primo_nrf52/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/arduino_primo_nrf52/syscfg.yml b/hw/bsp/arduino_primo_nrf52/syscfg.yml
index 175cf14..5b89ff9 100644
--- a/hw/bsp/arduino_primo_nrf52/syscfg.yml
+++ b/hw/bsp/arduino_primo_nrf52/syscfg.yml
@@ -20,6 +20,10 @@
 # Package: hw/bsp/arduino_primo_nrf52
 
 syscfg.defs:
+    OPENOCD_DEBUG:
+        description: 'TBD'
+        value: 0
+
     BSP_NRF52:
         description: 'TBD'
         value: 1
@@ -63,7 +67,7 @@ syscfg.defs:
 
     UART_1:
         description: 'Bitbanger UART'
-        value:  0
+        value:  1
     UART_1_PIN_TX:
         description: 'TBD'
         value:  11
@@ -98,7 +102,7 @@ syscfg.defs:
 
     TIMER_0:
         description: 'NRF52 Timer 0'
-        value:  0
+        value:  1
     TIMER_1:
         description: 'NRF52 Timer 1'
         value:  0


[05/13] incubator-mynewt-core git commit: MYNEWT-418; common functions for download/debug with JLink.

Posted by ma...@apache.org.
MYNEWT-418; common functions for download/debug with JLink.


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/6ba3b4bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6ba3b4bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6ba3b4bd

Branch: refs/heads/develop
Commit: 6ba3b4bd9df352798820ab60d596f4174a408ab9
Parents: 9112760
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 15:30:54 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/scripts/jlink.sh | 127 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 127 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6ba3b4bd/hw/scripts/jlink.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/jlink.sh b/hw/scripts/jlink.sh
new file mode 100644
index 0000000..542b63d
--- /dev/null
+++ b/hw/scripts/jlink.sh
@@ -0,0 +1,127 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+. $CORE_PATH/hw/scripts/common.sh
+
+#
+# FILE_NAME is the file to load
+# FLASH_OFFSET is location in the flash
+# JLINK_DEV is what we tell JLinkGDBServer this device to be
+#
+jlink_load () {
+    GDB_CMD_FILE=.gdb_cmds
+    GDB_OUT_FILE=.gdb_out
+
+    if [ -z $FILE_NAME ]; then
+        echo "Missing filename"
+        return 1
+    fi
+    if [ ! -f "$FILE_NAME" ]; then
+        echo "Cannot find file" $FILE
+        return 1
+    fi
+    if [ -z $FLASH_OFFSET ]; then
+        echo "Missing flash offset"
+        return 1
+    fi
+
+    echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
+
+    # XXX for some reason JLinkExe overwrites flash at offset 0 when
+    # 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 /bin/sh -c 'trap \"\" 2;JLinkGDBServer -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun' & " > $GDB_CMD_FILE
+    echo "target remote localhost:3333" >> $GDB_CMD_FILE
+    echo "mon reset" >> $GDB_CMD_FILE
+    echo "restore $FILE_NAME binary $FLASH_OFFSET" >> $GDB_CMD_FILE
+    echo "quit" >> $GDB_CMD_FILE
+
+    msgs=`arm-none-eabi-gdb -x $GDB_CMD_FILE 2>&1`
+    echo $msgs > $GDB_OUT_FILE
+
+#    rm $GDB_CMD_FILE
+
+    # Echo output from script run, so newt can show it if things go wrong.
+    echo $msgs
+
+    error=`echo $msgs | grep error`
+    if [ -n "$error" ]; then
+	return 1
+    fi
+
+    error=`echo $msgs | grep -i failed`
+    if [ -n "$error" ]; then
+	return 1
+    fi
+
+    error=`echo $msgs | grep -i "unknown / supported"`
+    if [ -n "$error" ]; then
+	return 1
+    fi
+
+    error=`echo $msgs | grep -i "not found"`
+    if [ -n "$error" ]; then
+	return 1
+    fi
+
+    return 0
+}
+
+#
+# FILE_NAME is the file to debug
+# NO_GDB is set if we should not start gdb
+# JLINK_DEV is what we tell JLinkGDBServer this device to be
+# EXTRA_GDB_CMDS is for extra commands to pass to gdb
+# RESET is set if we should reset the target at attach time
+#
+jlink_debug() {
+    if [ -z "$NO_GDB" ]; then
+	GDB_CMD_FILE=.gdb_cmds
+
+	if [ -z $FILE_NAME ]; then
+            echo "Missing filename"
+            return 1
+	fi
+	if [ ! -f "$FILE_NAME" ]; then
+            echo "Cannot find file" $FILE
+            return 1
+	fi
+
+	echo "Debugging" $FILE_NAME
+
+	# Monitor mode. Background process gets it's own process group.
+	set -m
+	JLinkGDBServer -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun > /dev/null &
+	set +m
+
+	echo "target remote localhost:3333" > $GDB_CMD_FILE
+	# Whether target should be reset or not
+	if [ ! -z "$RESET" ]; then
+	    echo "mon reset" >> $GDB_CMD_FILE
+	    echo "si" >> $GDB_CMD_FILE
+	fi
+	echo "$EXTRA_GDB_CMDS" >> $GDB_CMD_FILE
+
+	arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+
+	rm $GDB_CMD_FILE
+    else
+	JLinkGDBServer -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun
+    fi
+    return 0
+}


[09/13] incubator-mynewt-core git commit: MYNEWT-418; arduino_primo, nrf51-blenano - use common functions for debug/download.

Posted by ma...@apache.org.
MYNEWT-418; arduino_primo, nrf51-blenano - use common functions for
debug/download.


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/f971e8a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f971e8a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f971e8a5

Branch: refs/heads/develop
Commit: f971e8a529d88183ce8a65c12ea2af4e1804d3d1
Parents: 9e39286
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 21:26:34 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/bsp/arduino_primo_nrf52/primo_debug.sh    |  58 ++++---------
 hw/bsp/arduino_primo_nrf52/primo_download.sh |  84 ++++--------------
 hw/bsp/nrf51-blenano/nrf51dk_debug.sh        |  32 ++-----
 hw/bsp/nrf51-blenano/nrf51dk_download.sh     | 100 +++-------------------
 4 files changed, 51 insertions(+), 223 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f971e8a5/hw/bsp/arduino_primo_nrf52/primo_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/arduino_primo_nrf52/primo_debug.sh b/hw/bsp/arduino_primo_nrf52/primo_debug.sh
index f2b11d7..2ed8972 100755
--- a/hw/bsp/arduino_primo_nrf52/primo_debug.sh
+++ b/hw/bsp/arduino_primo_nrf52/primo_debug.sh
@@ -6,9 +6,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,62 +18,38 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - RESET set if target should be reset when attaching
-
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to debug"
-    exit 1
-fi
+#  - NO_GDB set if we should not start gdb to debug
+#
 
 USE_OPENOCD=0
 FILE_NAME=$BIN_BASENAME.elf
-GDB_CMD_FILE=.gdb_cmds
-
-echo "Debugging" $FILE_NAME
 
-# Look for 'openocd_debug' in FEATURES
+# Look for 'OPENOCD_DEBUG' in FEATURES
 for feature in $FEATURES; do
-    if [ $feature = "openocd_debug" ]; then
+    if [ $feature = "OPENOCD_DEBUG" ]; then
         USE_OPENOCD=1
     fi
 done
 
-echo "target remote localhost:3333" > $GDB_CMD_FILE
-
 if [ $USE_OPENOCD -eq 1 ]; then
-    if [ -z "$BSP_PATH" ]; then
-        echo "Need BSP path for openocd script location"
-        exit 1
-    fi
+    . $CORE_PATH/hw/scripts/openocd.sh
 
-    #
-    # Block Ctrl-C from getting passed to openocd.
-    # Exit openocd when gdb detaches.
-    #
-    set -m
-    openocd -s $BSP_PATH -f arduino_primo.cfg -c "$EXTRA_JTAG_CMD" -c "gdb_port 3333; telnet_port 4444; nrf52.cpu configure -event gdb-detach {resume;shutdown}" -c init -c halt &
-    set +m
-    # Whether target should be reset or not
-    if [ ! -z "$RESET" ]; then
-	echo "mon reset halt" >> $GDB_CMD_FILE
-    fi
+    CFG="-s $BSP_PATH -f arduino_primo.cfg"
+    EXTRA_JTAG_CMD="$EXTRA_JTAG_CMD; nrf52.cpu configure -event gdb-detach {resume;shutdown}"
+
+    openocd_debug
 else
-    #
-    # Block Ctrl-C from getting passed to JLinkGDBServer
-    set -m
-    JLinkGDBServer -device nRF52 -speed 4000 -if SWD -port 3333 -singlerun > /dev/null &
-    set +m
-    # Whether target should be reset or not
-    if [ ! -z "$RESET" ]; then
-	echo "mon reset" >> $GDB_CMD_FILE
-    fi
-fi
+    . $CORE_PATH/hw/scripts/jlink.sh
+
+    JLINK_DEV="nRF52"
 
-arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-rm $GDB_CMD_FILE
+    jlink_debug
+fi
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f971e8a5/hw/bsp/arduino_primo_nrf52/primo_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/arduino_primo_nrf52/primo_download.sh b/hw/bsp/arduino_primo_nrf52/primo_download.sh
index 3bdcf9a..0d416fa 100755
--- a/hw/bsp/arduino_primo_nrf52/primo_download.sh
+++ b/hw/bsp/arduino_primo_nrf52/primo_download.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,6 +17,7 @@
 # under the License.
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
@@ -24,92 +25,39 @@
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
+#  - FLASH_OFFSET contains the flash offset to download to
+#  - BOOT_LOADER is set if downloading a bootloader
 
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to download"
-    exit 1
-fi
-
-IS_BOOTLOADER=0
 USE_OPENOCD=0
-GDB_CMD_FILE=.gdb_cmds
 
-# Look for 'bootloader' in FEATURES
+# Look for 'openocd_debug' in FEATURES
 for feature in $FEATURES; do
-    if [ $feature == "BOOT_LOADER" ]; then
-        IS_BOOTLOADER=1
-    fi
-    if [ $feature = "openocd_debug" ]; then
+    if [ $feature = "OPENOCD_DEBUG" ]; then
         USE_OPENOCD=1
     fi
 done
 
 if [ "$MFG_IMAGE" ]; then
     FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.bin
-elif [ $IS_BOOTLOADER -eq 1 ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.elf.bin
-elif [ $IMAGE_SLOT -eq 0 ]; then
-    FLASH_OFFSET=0x8000
-    FILE_NAME=$BIN_BASENAME.img
-elif [ $IMAGE_SLOT -eq 1 ]; then
-    FLASH_OFFSET=0x42000
-    FILE_NAME=$BIN_BASENAME.img
-else 
-    echo "Invalid Image Slot Number: $IMAGE_SLOT"
-    exit 1
-fi
-
-echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
-
-if [ ! -f $FILE_NAME ]; then
-    echo "File " $FILE_NAME "not found"
-    exit 1
 fi
 
 if [ $USE_OPENOCD -eq 1 ]; then
-    if [ -z "$BSP_PATH" ]; then
-        echo "Need BSP path for openocd script location"
-        exit 1
-    fi
+    . $CORE_PATH/hw/scripts/openocd.sh
 
     #
     # XXXX note that this is using openocd through STM32, with openocd
     # which has been patched to support nrf52 flash.
     #
-    openocd -s $BSP_PATH -f arduino_primo.cfg -c "$EXTRA_JTAG_CMD" -c init -c "reset halt" -c "flash write_image erase $FILE_NAME $FLASH_OFFSET" -c "reset run" -c shutdown
-else
-    echo "shell /bin/sh -c 'trap \"\" 2;JLinkGDBServer -device nRF52 -speed 4000 -if SWD -port 3333 -singlerun' & " > $GDB_CMD_FILE
-    echo "target remote localhost:3333" >> $GDB_CMD_FILE
-    echo "restore $FILE_NAME binary $FLASH_OFFSET" >> $GDB_CMD_FILE
-    echo "quit" >> $GDB_CMD_FILE
+    CFG="-s $BSP_PATH -f arduino_primo.cfg"
 
-    msgs=`arm-none-eabi-gdb -x $GDB_CMD_FILE 2>&1`
-    echo $msgs > .gdb_out
-
-    rm $GDB_CMD_FILE
-
-    # Echo output from script run, so newt can show it if things go wrong.
-    echo $msgs
-
-    error=`echo $msgs | grep error`
-    if [ -n "$error" ]; then
-        exit 1
-    fi
-
-    error=`echo $msgs | grep -i failed`
-    if [ -n "$error" ]; then
-        exit 1
-    fi
+    common_file_to_load
+    openocd_load
+    openocd_reset_run
+else
+    . $CORE_PATH/hw/scripts/jlink.sh
 
-    error=`echo $msgs | grep -i "unknown / supported"`
-    if [ -n "$error" ]; then
-        exit 1
-    fi
+    JLINK_DEV="nRF52"
 
-    error=`echo $msgs | grep -i "not found"`
-    if [ -n "$error" ]; then
-        exit 1
-    fi
+    common_file_to_load
+    jlink_load
 fi

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f971e8a5/hw/bsp/nrf51-blenano/nrf51dk_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51-blenano/nrf51dk_debug.sh b/hw/bsp/nrf51-blenano/nrf51dk_debug.sh
index 4645336..4ca9760 100755
--- a/hw/bsp/nrf51-blenano/nrf51dk_debug.sh
+++ b/hw/bsp/nrf51-blenano/nrf51dk_debug.sh
@@ -18,39 +18,19 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - RESET set if target should be reset when attaching
+#  - NO_GDB set if we should not start gdb to debug
 #
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to debug"
-    exit 1
-fi
-
-if [ -z "$BSP_PATH" ]; then
-    echo "Need BSP path for openocd script location"
-    exit 1
-fi
+. $CORE_PATH/hw/scripts/openocd.sh
 
 FILE_NAME=$BIN_BASENAME.elf
-GDB_CMD_FILE=.gdb_cmds
-
-echo "Debugging" $FILE_NAME
-
-set -m
-openocd -s $BSP_PATH -f cmsis-dap.cfg -f nrf51.cfg -c "nrf51.cpu configure -event gdb-detach {resume;shutdown}" -c "$EXTRA_JTAG_CMD" -c init -c halt &
-set +m
-
-echo "target remote localhost:3333" > $GDB_CMD_FILE
-# Whether target should be reset or not
-if [ ! -z "$RESET" ]; then
-    echo "mon reset" >> $GDB_CMD_FILE
-fi
-
-arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-
-rm $GDB_CMD_FILE
+CFG="-s $BSP_PATH -f cmsis-dap.cfg -f nrf51.cfg"
+EXTRA_JTAG_CMD="$EXTRA_JTAG_CMD; nrf51.cpu configure -event gdb-detach {resume;shutdown}"
 
+openocd_debug

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f971e8a5/hw/bsp/nrf51-blenano/nrf51dk_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51-blenano/nrf51dk_download.sh b/hw/bsp/nrf51-blenano/nrf51dk_download.sh
index d6e9eac..af3f7bd 100755
--- a/hw/bsp/nrf51-blenano/nrf51dk_download.sh
+++ b/hw/bsp/nrf51-blenano/nrf51dk_download.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -6,9 +6,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,6 +18,7 @@
 #
 
 # Called with following variables set:
+#  - CORE_PATH is absolute path to @apache-mynewt-core
 #  - BSP_PATH is absolute path to hw/bsp/bsp_name
 #  - BIN_BASENAME is the path to prefix to target binary,
 #    .elf appended to name is the ELF file
@@ -25,94 +26,17 @@
 #  - FEATURES holds the target features string
 #  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
 #  - MFG_IMAGE is "1" if this is a manufacturing image
+#  - FLASH_OFFSET contains the flash offset to download to
+#  - BOOT_LOADER is set if downloading a bootloader
 
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to download"
-    exit 1
-fi
-
-IS_BOOTLOADER=0
-#JLINK_SCRIPT=.download.jlink
-GDB_CMD_FILE=.gdb_cmds
+. $CORE_PATH/hw/scripts/openocd.sh
 
-# Look for 'bootloader' in FEATURES
-for feature in $FEATURES; do
-    if [ $feature == "BOOT_LOADER" ]; then
-        IS_BOOTLOADER=1
-    fi
-done
+CFG="-s $BSP_PATH -f cmsis-dap.cfg -f nrf51.cfg"
 
 if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.bin
-elif [ $IS_BOOTLOADER -eq 1 ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.elf.bin
-elif [ $IMAGE_SLOT -eq 0 ]; then
-    FLASH_OFFSET=0x8000
-    FILE_NAME=$BIN_BASENAME.img
-elif [ $IMAGE_SLOT -eq 1 ]; then
-    FLASH_OFFSET=0x23800
-    FILE_NAME=$BIN_BASENAME.img
-else
-    echo "Invalid Image Slot Number: $IMAGE_SLOT"
-    exit 1
-fi
-
-echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
-
-if [ ! -f $FILE_NAME ]; then
-    echo "File " $FILE_NAME "not found"
-    exit 1
-fi
-
-# XXX for some reason JLinkExe overwrites flash at offset 0 when
-# 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 /bin/sh -c 'trap \"\" 2;openocd -s $BSP_PATH -f cmsis-dap.cfg -c \"$EXTRA_JTAG_CMD\" -f nrf51.cfg' &" > $GDB_CMD_FILE
-echo "target remote localhost:3333" >> $GDB_CMD_FILE
-echo "monitor reset halt" >> $GDB_CMD_FILE
-echo "monitor flash write_image erase $FILE_NAME $FLASH_OFFSET" >> $GDB_CMD_FILE
-echo "monitor reset run" >> $GDB_CMD_FILE
-echo "monitor shutdown" >> $GDB_CMD_FILE
-echo "quit" >> $GDB_CMD_FILE
-
-msgs=`arm-none-eabi-gdb -x $GDB_CMD_FILE 2>&1`
-echo $msgs > .gdb_out
-
-rm $GDB_CMD_FILE
-
-#cat > $JLINK_SCRIPT <<EOF
-#w 4001e504 1
-#loadbin $FILE_NAME,$FLASH_OFFSET
-#q
-#EOF
-
-#msgs=`JLinkExe -device nRF51422_xxAC -speed 4000 -if SWD $JLINK_SCRIPT`
-
-# Echo output from script run, so newt can show it if things go wrong.
-echo $msgs
-#rm $JLINK_SCRIPT
-
-error=`echo $msgs | grep error | grep -v Ignoring`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i failed`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "unknown / supported"`
-if [ -n "$error" ]; then
-    exit 1
-fi
-
-error=`echo $msgs | grep -i "not found"`
-if [ -n "$error" ]; then
-    exit 1
+    FLASH_OFFSET=0
 fi
 
-exit 0
+common_file_to_load
+openocd_load
+openocd_reset_run


[07/13] incubator-mynewt-core git commit: nrf52dk debug.sh; remove unnecessary var assignment

Posted by ma...@apache.org.
nrf52dk debug.sh; remove unnecessary var assignment


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/46f9bb46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/46f9bb46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/46f9bb46

Branch: refs/heads/develop
Commit: 46f9bb464c59e82f1324163efb30455683d02ad7
Parents: 82fdbc2
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 15:46:27 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 21:32:01 2016 -0700

----------------------------------------------------------------------
 hw/bsp/nrf52dk/nrf52dk_debug.sh | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/46f9bb46/hw/bsp/nrf52dk/nrf52dk_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/nrf52dk_debug.sh b/hw/bsp/nrf52dk/nrf52dk_debug.sh
index cce04c6..17b980d 100755
--- a/hw/bsp/nrf52dk/nrf52dk_debug.sh
+++ b/hw/bsp/nrf52dk/nrf52dk_debug.sh
@@ -42,7 +42,5 @@ fi
 
 JLINK_DEV="nRF52"
 
-GDB_CMD_FILE=.gdb_cmds
-
 jlink_debug