mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [06/13] incubator-mynewt-core git commit: MYNEWT-418 - nrf52dk use common functions for debug/download.
Date Fri, 04 Nov 2016 04:38:04 GMT
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 <marko@runtime.io>
Authored: Thu Nov 3 15:31:24 2016 -0700
Committer: Marko Kiiskila <marko@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


Mime
View raw message