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:38:06 UTC

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

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