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:11 UTC

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

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