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/03 19:26:41 UTC

[2/2] incubator-mynewt-core git commit: nucleo; use common functions for debug/download.

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

Branch: refs/heads/develop
Commit: fc267d69998850bbcb5a7f5fdb3e5e953cd28585
Parents: 02e41ab
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 12:25:46 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 12:25:46 2016 -0700

----------------------------------------------------------------------
 hw/bsp/nucleo-f401re/nucleo-f401re_debug.sh    | 32 +++++++++------------
 hw/bsp/nucleo-f401re/nucleo-f401re_download.sh | 31 ++++++++------------
 2 files changed, 25 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc267d69/hw/bsp/nucleo-f401re/nucleo-f401re_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nucleo-f401re/nucleo-f401re_debug.sh b/hw/bsp/nucleo-f401re/nucleo-f401re_debug.sh
index 1f17120..6935830 100755
--- a/hw/bsp/nucleo-f401re/nucleo-f401re_debug.sh
+++ b/hw/bsp/nucleo-f401re/nucleo-f401re_debug.sh
@@ -18,36 +18,30 @@
 #
 
 # 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/openocd.sh
 
 FILE_NAME=$BIN_BASENAME.elf
-GDB_CMD_FILE=.gdb_cmds
+OCD_CMD_FILE=.openocd_cmds
 
-echo "Debugging" $FILE_NAME
+CFG="-f board/st_nucleo_f4.cfg"
 
-#
-# Block Ctrl-C from getting passed to openocd.
+echo "gdb_port 3333" > $OCD_CMD_FILE
+echo "telnet_port 4444" >> $OCD_CMD_FILE
 # Exit openocd when gdb detaches.
-#
-set -m
-openocd -f board/st_nucleo_f4.cfg -s $BSP_PATH -c "gdb_port 3333; telnet_port 4444; stm32f4x.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 halt" >> $GDB_CMD_FILE
+echo "stm32f4x.cpu configure -event gdb-detach {resume;shutdown}" >> $OCD_CMD_FILE
+if [ ! -z "$EXTRA_JTAG_CMD" ]; then
+    echo "$EXTRA_JTAG_CMD" >> $OCD_CMD_FILE
 fi
 
-arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-rm $GDB_CMD_FILE
+openocd_debug
+
+rm $OCD_CMD_FILE

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc267d69/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 ccf7bf3..d752ba9 100755
--- a/hw/bsp/nucleo-f401re/nucleo-f401re_download.sh
+++ b/hw/bsp/nucleo-f401re/nucleo-f401re_download.sh
@@ -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,32 +26,24 @@
 #  - 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
-set -x
-if [ -z "$BIN_BASENAME" ]; then
-    echo "Need binary to download"
-    exit 1
-fi
+#  - FLASH_OFFSET contains the flash offset to download to
+#  - BOOTLOADER is set if downloading a bootloader
 
-IS_BOOTLOADER=0
+. $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="-f board/st_nucleo_f4.cfg"
+if [ ! -z "$EXTRA_JTAG_CMD" ]; then
+    CFG="$CFG -c $EXTRA_JTAG_CMD"
+fi
 
 if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x0
-    FILE_NAME=$BIN_BASENAME.bin
-elif [ $IS_BOOTLOADER -eq 1 ]; then
     FLASH_OFFSET=0x08000000
+    FILE_NAME=$BIN_BASENAME.bin
+elif [ "$BOOT_LOADER" ]; then
     FILE_NAME=$BIN_BASENAME.elf.bin
 else
-    FLASH_OFFSET=0x08020000
     FILE_NAME=$BIN_BASENAME.img
 fi
-echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
-
-openocd -f board/st_nucleo_f4.cfg -c "$EXTRA_JTAG_CMD" -c init -c "reset halt" -c "flash write_image erase $FILE_NAME $FLASH_OFFSET" -c "reset run" -c shutdown
 
+openocd_load
+openocd_reset_run