Fix boot loaders after syscfg/sysinit changes.
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/1540d5b0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1540d5b0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1540d5b0 Branch: refs/heads/develop Commit: 1540d5b00b04a465339cf8ea8b547b778fed0c7d Parents: 0e029a5 Author: Christopher Collins <[email protected]> Authored: Wed Sep 14 13:34:26 2016 -0700 Committer: Christopher Collins <[email protected]> Committed: Wed Sep 14 13:58:36 2016 -0700 ---------------------------------------------------------------------- apps/boot/pkg.yml | 7 ++- hw/bsp/arduino_primo_nrf52/pkg.yml | 2 +- hw/bsp/arduino_primo_nrf52/primo_debug.sh | 52 ++++++++++------- hw/bsp/arduino_primo_nrf52/primo_download.sh | 60 +++++++++++++------- hw/bsp/bmd300eval/bmd300eval_debug.sh | 28 +++++---- hw/bsp/bmd300eval/bmd300eval_download.sh | 48 ++++++++++------ hw/bsp/bmd300eval/pkg.yml | 2 +- hw/bsp/native/native_debug.sh | 27 +++++---- .../nrf51-arduino_101/nrf51dk-16kbram_debug.sh | 26 +++++---- .../nrf51dk-16kbram_download.sh | 39 +++++++------ hw/bsp/nrf51-arduino_101/pkg.yml | 2 +- hw/bsp/nrf51-blenano/nrf51dk_debug.sh | 33 +++++++---- hw/bsp/nrf51-blenano/nrf51dk_download.sh | 55 +++++++++++------- hw/bsp/nrf51-blenano/pkg.yml | 2 +- hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh | 25 ++++---- .../nrf51dk-16kbram/nrf51dk-16kbram_download.sh | 52 ++++++++++------- hw/bsp/nrf51dk-16kbram/pkg.yml | 2 +- hw/bsp/nrf51dk/nrf51dk_debug.sh | 25 ++++---- hw/bsp/nrf51dk/nrf51dk_download.sh | 55 +++++++++++------- hw/bsp/nrf51dk/pkg.yml | 2 +- hw/bsp/nrf52dk/nrf52dk_debug.sh | 37 ++++++++---- hw/bsp/nrf52dk/nrf52dk_download.sh | 48 ++++++++++------ hw/bsp/nrf52dk/pkg.yml | 2 +- hw/bsp/nrf52pdk/nrf52pdk_debug.sh | 25 ++++---- hw/bsp/nrf52pdk/nrf52pdk_download.sh | 35 ++++++------ hw/bsp/nrf52pdk/pkg.yml | 2 +- .../olimex_stm32-e407_devboard_debug.sh | 31 ++++++---- .../olimex_stm32-e407_devboard_download.sh | 38 ++++++------- hw/bsp/olimex_stm32-e407_devboard/pkg.yml | 2 +- sys/config/pkg.yml | 2 +- 30 files changed, 465 insertions(+), 301 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/apps/boot/pkg.yml ---------------------------------------------------------------------- diff --git a/apps/boot/pkg.yml b/apps/boot/pkg.yml index 31e2018..8a375a5 100644 --- a/apps/boot/pkg.yml +++ b/apps/boot/pkg.yml @@ -43,9 +43,6 @@ pkg.deps.BOOT_SERIAL.OVERWRITE: - libs/console/full - libs/boot_serial -pkg.syscfg_vals: - LOG_LEVEL: 255 - pkg.syscfg_defs: BOOT_LOADER: description: 'TBD' @@ -59,3 +56,7 @@ pkg.syscfg_defs: BOOT_SERIAL: description: 'TBD' value: 0 + +pkg.syscfg_vals: + LOG_LEVEL: 255 + STATS_NAMES: 0 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/arduino_primo_nrf52/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/arduino_primo_nrf52/pkg.yml b/hw/bsp/arduino_primo_nrf52/pkg.yml index 048f663..a2210d4 100644 --- a/hw/bsp/arduino_primo_nrf52/pkg.yml +++ b/hw/bsp/arduino_primo_nrf52/pkg.yml @@ -30,7 +30,7 @@ pkg.keywords: pkg.arch: cortex_m4 pkg.compiler: compiler/arm-none-eabi-m4 pkg.linkerscript: "primo.ld" -pkg.linkerscript.bootloader.OVERWRITE: "boot-primo.ld" +pkg.linkerscript.BOOT_LOADER.OVERWRITE: "boot-primo.ld" pkg.downloadscript: primo_download.sh pkg.debugscript: primo_debug.sh pkg.cflags: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/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 aa98cf5..f2b11d7 100755 --- a/hw/bsp/arduino_primo_nrf52/primo_debug.sh +++ b/hw/bsp/arduino_primo_nrf52/primo_debug.sh @@ -16,56 +16,64 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# -# -if [ $# -lt 1 ]; then + +# Called with following variables set: +# - 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 USE_OPENOCD=0 -MY_PATH=$1 -FILE_NAME=$2.elf +FILE_NAME=$BIN_BASENAME.elf GDB_CMD_FILE=.gdb_cmds echo "Debugging" $FILE_NAME -# Look for 'openocd_debug' from 3rd arg onwards -shift -shift -while [ $# -gt 0 ]; do - if [ $1 = "openocd_debug" ]; then +# Look for 'openocd_debug' in FEATURES +for feature in $FEATURES; do + if [ $feature = "openocd_debug" ]; then USE_OPENOCD=1 fi - shift 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 + # # Block Ctrl-C from getting passed to openocd. # Exit openocd when gdb detaches. # - # Note that openocd behaves differently than Primo. We reset the target - # as we attach with openocd. If you don't want that, replace "reset halt" - # with just "halt" set -m - openocd -s $MY_PATH -f arduino_primo.cfg -c "gdb_port 3333; telnet_port 4444; nrf52.cpu configure -event gdb-detach {shutdown}" -c init -c "reset halt" & + 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 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 -echo "target remote localhost:3333" > $GDB_CMD_FILE arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME rm $GDB_CMD_FILE http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/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 9940e39..36f1ef9 100755 --- a/hw/bsp/arduino_primo_nrf52/primo_download.sh +++ b/hw/bsp/arduino_primo_nrf52/primo_download.sh @@ -16,55 +16,71 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# +# Called with following variables set: +# - 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 +# - IMAGE_SLOT is the image slot to download to +# - FEATURES holds the target features string +# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software # -if [ $# -lt 2 ]; then +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to download" exit 1 fi +if [ -z "$IMAGE_SLOT" ]; then + echo "Need image slot to download" + exit 1 +fi + IS_BOOTLOADER=0 USE_OPENOCD=0 -MYPATH=$1 -BASENAME=$2 GDB_CMD_FILE=.gdb_cmds -# Look for 'bootloader' from 3rd arg onwards -shift -shift -while [ $# -gt 0 ]; do - if [ $1 = "bootloader" ]; then - IS_BOOTLOADER=1 +# Look for 'bootloader' in FEATURES +for feature in $FEATURES; do + if [ $feature == "BOOT_LOADER" ]; then + IS_BOOTLOADER=1 fi - if [ $1 = "openocd_debug" ]; then + if [ $feature = "openocd_debug" ]; then USE_OPENOCD=1 fi - shift done if [ $IS_BOOTLOADER -eq 1 ]; then FLASH_OFFSET=0x0 - FILE_NAME=$BASENAME.elf.bin -else + FILE_NAME=$BIN_BASENAME.elf.bin +elif [ $IMAGE_SLOT -eq 0 ]; then FLASH_OFFSET=0x8000 - FILE_NAME=$BASENAME.img + 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 + # # XXXX note that this is using openocd through STM32, with openocd # which has been patched to support nrf52 flash. # - openocd -s $MYPATH -f arduino_primo.cfg -c init -c "reset halt" -c "flash write_image erase $FILE_NAME $FLASH_OFFSET" -c "reset run" -c shutdown + 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/bmd300eval/bmd300eval_debug.sh ---------------------------------------------------------------------- diff --git a/hw/bsp/bmd300eval/bmd300eval_debug.sh b/hw/bsp/bmd300eval/bmd300eval_debug.sh index 469bbaa..24a3f20 100755 --- a/hw/bsp/bmd300eval/bmd300eval_debug.sh +++ b/hw/bsp/bmd300eval/bmd300eval_debug.sh @@ -16,20 +16,21 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# -# -if [ $# -lt 1 ]; then - echo "Need binary to download" + +# Called with following variables set: +# - 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 -FILE_NAME=$2.elf +FILE_NAME=$BIN_BASENAME.elf GDB_CMD_FILE=.gdb_cmds echo "Debugging" $FILE_NAME @@ -41,6 +42,11 @@ 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/bmd300eval/bmd300eval_download.sh ---------------------------------------------------------------------- diff --git a/hw/bsp/bmd300eval/bmd300eval_download.sh b/hw/bsp/bmd300eval/bmd300eval_download.sh index 028a5aa..6c25243 100755 --- a/hw/bsp/bmd300eval/bmd300eval_download.sh +++ b/hw/bsp/bmd300eval/bmd300eval_download.sh @@ -16,44 +16,56 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# +# Called with following variables set: +# - 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 +# - IMAGE_SLOT is the image slot to download to +# - FEATURES holds the target features string +# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software # -if [ $# -lt 2 ]; then +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to download" exit 1 fi +if [ -z "$IMAGE_SLOT" ]; then + echo "Need image slot to download" + exit 1 +fi + IS_BOOTLOADER=0 -BASENAME=$2 GDB_CMD_FILE=.gdb_cmds -# Look for 'bootloader' from 3rd arg onwards -shift -shift -while [ $# -gt 0 ]; do - if [ $1 = "bootloader" ]; then +# Look for 'bootloader' in FEATURES +for feature in $FEATURES; do + if [ $feature == "BOOT_LOADER" ]; then IS_BOOTLOADER=1 fi - shift done if [ $IS_BOOTLOADER -eq 1 ]; then FLASH_OFFSET=0x0 - FILE_NAME=$BASENAME.elf.bin -else + FILE_NAME=$BIN_BASENAME.elf.bin +elif [ $IMAGE_SLOT -eq 0 ]; then FLASH_OFFSET=0x8000 - FILE_NAME=$BASENAME.img + 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/bmd300eval/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/bmd300eval/pkg.yml b/hw/bsp/bmd300eval/pkg.yml index 0035ce2..b363ce1 100644 --- a/hw/bsp/bmd300eval/pkg.yml +++ b/hw/bsp/bmd300eval/pkg.yml @@ -29,7 +29,7 @@ pkg.keywords: pkg.arch: cortex_m4 pkg.compiler: compiler/arm-none-eabi-m4 pkg.linkerscript: "bmd300eval.ld" -pkg.linkerscript.bootloader.OVERWRITE: "boot-bmd300eval.ld" +pkg.linkerscript.BOOT_LOADER.OVERWRITE: "boot-bmd300eval.ld" pkg.downloadscript: bmd300eval_download.sh pkg.debugscript: bmd300eval_debug.sh pkg.cflags: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/native/native_debug.sh ---------------------------------------------------------------------- diff --git a/hw/bsp/native/native_debug.sh b/hw/bsp/native/native_debug.sh index 41ed55c..f412408 100755 --- a/hw/bsp/native/native_debug.sh +++ b/hw/bsp/native/native_debug.sh @@ -16,20 +16,27 @@ # specific language governing permissions and limitations # under the License. # -# Called $0 <bsp_path> <binary> [identities ...] -# - 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. -# -# -if [ $# -lt 2 ]; then + +# Called with following variables set: +# - 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 "$BSP_PATH" ]; then + echo "Need binary to debug" + exit 1 +fi + +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to debug" exit 1 fi -GDB_SCRIPT_PATH=$1/sim.gdb -FILE_NAME=$2.elf +GDB_SCRIPT_PATH=$BSP_PATH/sim.gdb +FILE_NAME=$BIN_BASENAME.elf echo "Debugging" $FILE_NAME http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/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 d5464dd..db73ad3 100755 --- a/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_debug.sh +++ b/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_debug.sh @@ -16,20 +16,21 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 [ $# -lt 2 ]; then - echo "Need binary to download" +if [ -z "$BIN_BASENAME" ]; 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 @@ -40,6 +41,11 @@ 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 --tui -x $GDB_CMD_FILE $FILE_NAME rm $GDB_CMD_FILE http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/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 958ef1f..bad01d0 100755 --- a/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_download.sh +++ b/hw/bsp/nrf51-arduino_101/nrf51dk-16kbram_download.sh @@ -16,44 +16,47 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 +# - IMAGE_SLOT is the image slot to download to +# - FEATURES holds the target features string +# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software # -if [ $# -lt 2 ]; then + +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to download" exit 1 fi IS_BOOTLOADER=0 -BASENAME=$2 #JLINK_SCRIPT=.download.jlink GDB_CMD_FILE=.gdb_cmds -# Look for 'bootloader' from 2nd arg onwards -shift -shift -while [ $# -gt 0 ]; do - if [ $1 = "bootloader" ]; then - IS_BOOTLOADER=1 +# Look for 'bootloader' in FEATURES +for feature in $FEATURES; do + if [ $feature == "BOOT_LOADER" ]; then + IS_BOOTLOADER=1 fi - shift done if [ $IS_BOOTLOADER -eq 1 ]; then FLASH_OFFSET=0x0 - FILE_NAME=$BASENAME.elf.bin + FILE_NAME=$BIN_BASENAME.elf.bin else FLASH_OFFSET=0x8000 - FILE_NAME=$BASENAME.img + 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf51-arduino_101/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51-arduino_101/pkg.yml b/hw/bsp/nrf51-arduino_101/pkg.yml index 05ff47a..7719a9f 100644 --- a/hw/bsp/nrf51-arduino_101/pkg.yml +++ b/hw/bsp/nrf51-arduino_101/pkg.yml @@ -29,7 +29,7 @@ pkg.keywords: pkg.arch: cortex_m0 pkg.compiler: compiler/arm-none-eabi-m0 pkg.linkerscript: "nrf51-arduino_101.ld" -pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf51-arduino_101.ld" +pkg.linkerscript.BOOT_LOADER.OVERWRITE: "boot-nrf51-arduino_101.ld" pkg.downloadscript: nrf51dk-16kbram_download.sh pkg.debugscript: nrf51dk-16kbram_debug.sh pkg.cflags: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/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 f090129..4645336 100755 --- a/hw/bsp/nrf51-blenano/nrf51dk_debug.sh +++ b/hw/bsp/nrf51-blenano/nrf51dk_debug.sh @@ -16,30 +16,39 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features is the project identities string. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 [ $# -lt 2 ]; then - echo "Need binary to download" +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 -MYPATH=$1 -FILE_NAME=$2.elf +FILE_NAME=$BIN_BASENAME.elf GDB_CMD_FILE=.gdb_cmds echo "Debugging" $FILE_NAME set -m -openocd -s $MYPATH -f cmsis-dap.cfg -f nrf51.cfg -c "nrf51.cpu configure -event gdb-detach {shutdown}" -c init -c "reset halt" & +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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/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 7ba69f2..14ee3f4 100755 --- a/hw/bsp/nrf51-blenano/nrf51dk_download.sh +++ b/hw/bsp/nrf51-blenano/nrf51dk_download.sh @@ -16,50 +16,63 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features is the project features string. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 +# - IMAGE_SLOT is the image slot to download to +# - FEATURES holds the target features string +# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software # -if [ $# -lt 2 ]; then + +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to download" exit 1 fi +if [ -z "$IMAGE_SLOT" ]; then + echo "Need image slot to download" + exit 1 +fi + IS_BOOTLOADER=0 -MYPAH=$1 -BASENAME=$2 #JLINK_SCRIPT=.download.jlink GDB_CMD_FILE=.gdb_cmds -# Look for 'bootloader' from 3rd arg onwards -shift -shift -while [ $# -gt 0 ]; do - if [ $1 = "bootloader" ]; then - IS_BOOTLOADER=1 +# Look for 'bootloader' in FEATURES +for feature in $FEATURES; do + if [ $feature == "BOOT_LOADER" ]; then + IS_BOOTLOADER=1 fi - shift done if [ $IS_BOOTLOADER -eq 1 ]; then FLASH_OFFSET=0x0 - FILE_NAME=$BASENAME.elf.bin -else + FILE_NAME=$BIN_BASENAME.elf.bin +elif [ $IMAGE_SLOT -eq 0 ]; then FLASH_OFFSET=0x8000 - FILE_NAME=$BASENAME.img + 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 $MYPAH -f cmsis-dap.cfg -f nrf51.cfg' &" > $GDB_CMD_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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf51-blenano/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51-blenano/pkg.yml b/hw/bsp/nrf51-blenano/pkg.yml index 1914ca9..8eb7ba5 100644 --- a/hw/bsp/nrf51-blenano/pkg.yml +++ b/hw/bsp/nrf51-blenano/pkg.yml @@ -30,7 +30,7 @@ pkg.keywords: pkg.arch: cortex_m0 pkg.compiler: compiler/arm-none-eabi-m0 pkg.linkerscript: "nrf51dk.ld" -pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf51dk.ld" +pkg.linkerscript.BOOT_LOADER.OVERWRITE: "boot-nrf51dk.ld" pkg.downloadscript: nrf51dk_download.sh pkg.debugscript: nrf51dk_debug.sh pkg.cflags: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/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 04e3f79..dadc91f 100755 --- a/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh +++ b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_debug.sh @@ -16,20 +16,21 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 [ $# -lt 2 ]; then - echo "Need binary to download" +if [ -z "$BIN_BASENAME" ]; 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 @@ -39,6 +40,10 @@ JLinkGDBServer -device nRF51422_xxAC -speed 4000 -if SWD -port 3333 -singlerun > 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/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 46b2481..c6a1ef6 100755 --- a/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh +++ b/hw/bsp/nrf51dk-16kbram/nrf51dk-16kbram_download.sh @@ -16,44 +16,58 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 +# - IMAGE_SLOT is the image slot to download to +# - FEATURES holds the target features string +# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software # -if [ $# -lt 2 ]; then + +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to download" exit 1 fi +if [ -z "$IMAGE_SLOT" ]; then + echo "Need image slot to download" + exit 1 +fi + IS_BOOTLOADER=0 -BASENAME=$2 #JLINK_SCRIPT=.download.jlink GDB_CMD_FILE=.gdb_cmds -# Look for 'bootloader' from 2nd arg onwards -shift -shift -while [ $# -gt 0 ]; do - if [ $1 = "bootloader" ]; then - IS_BOOTLOADER=1 +# Look for 'bootloader' in FEATURES +for feature in $FEATURES; do + if [ $feature == "BOOT_LOADER" ]; then + IS_BOOTLOADER=1 fi - shift done if [ $IS_BOOTLOADER -eq 1 ]; then FLASH_OFFSET=0x0 - FILE_NAME=$BASENAME.elf.bin -else + FILE_NAME=$BIN_BASENAME.elf.bin +elif [ $IMAGE_SLOT -eq 0 ]; then FLASH_OFFSET=0x8000 - FILE_NAME=$BASENAME.img + 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf51dk-16kbram/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk-16kbram/pkg.yml b/hw/bsp/nrf51dk-16kbram/pkg.yml index c9c11d2..07506db 100644 --- a/hw/bsp/nrf51dk-16kbram/pkg.yml +++ b/hw/bsp/nrf51dk-16kbram/pkg.yml @@ -29,7 +29,7 @@ pkg.keywords: pkg.arch: cortex_m0 pkg.compiler: compiler/arm-none-eabi-m0 pkg.linkerscript: "nrf51dk-16kbram.ld" -pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf51dk-16kbram.ld" +pkg.linkerscript.BOOT_LOADER.OVERWRITE: "boot-nrf51dk-16kbram.ld" pkg.downloadscript: nrf51dk-16kbram_download.sh pkg.debugscript: nrf51dk-16kbram_debug.sh pkg.cflags: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf51dk/nrf51dk_debug.sh ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk/nrf51dk_debug.sh b/hw/bsp/nrf51dk/nrf51dk_debug.sh index 6348a48..dadc91f 100755 --- a/hw/bsp/nrf51dk/nrf51dk_debug.sh +++ b/hw/bsp/nrf51dk/nrf51dk_debug.sh @@ -16,20 +16,21 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features is the project identities string. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 [ $# -lt 2 ]; then - echo "Need binary to download" +if [ -z "$BIN_BASENAME" ]; 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 @@ -39,6 +40,10 @@ JLinkGDBServer -device nRF51422_xxAC -speed 4000 -if SWD -port 3333 -singlerun > 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf51dk/nrf51dk_download.sh ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk/nrf51dk_download.sh b/hw/bsp/nrf51dk/nrf51dk_download.sh index 2ee17e9..ee3fc3f 100755 --- a/hw/bsp/nrf51dk/nrf51dk_download.sh +++ b/hw/bsp/nrf51dk/nrf51dk_download.sh @@ -16,48 +16,63 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features is the project features string. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 +# - IMAGE_SLOT is the image slot to download to +# - FEATURES holds the target features string +# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software # -if [ $# -lt 2 ]; then + +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to download" exit 1 fi +if [ -z "$IMAGE_SLOT" ]; then + echo "Need image slot to download" + exit 1 +fi + IS_BOOTLOADER=0 -BASENAME=$2 #JLINK_SCRIPT=.download.jlink GDB_CMD_FILE=.gdb_cmds -# Look for 'bootloader' from 3rd arg onwards -shift -shift -while [ $# -gt 0 ]; do - if [ $1 = "bootloader" ]; then - IS_BOOTLOADER=1 +# Look for 'bootloader' in FEATURES +for feature in $FEATURES; do + if [ $feature == "BOOT_LOADER" ]; then + IS_BOOTLOADER=1 fi - shift done if [ $IS_BOOTLOADER -eq 1 ]; then FLASH_OFFSET=0x0 - FILE_NAME=$BASENAME.elf.bin -else + FILE_NAME=$BIN_BASENAME.elf.bin +elif [ $IMAGE_SLOT -eq 0 ]; then FLASH_OFFSET=0x8000 - FILE_NAME=$BASENAME.img + 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf51dk/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf51dk/pkg.yml b/hw/bsp/nrf51dk/pkg.yml index 2ce5123..a6c12fa 100644 --- a/hw/bsp/nrf51dk/pkg.yml +++ b/hw/bsp/nrf51dk/pkg.yml @@ -29,7 +29,7 @@ pkg.keywords: pkg.arch: cortex_m0 pkg.compiler: compiler/arm-none-eabi-m0 pkg.linkerscript: "nrf51dk.ld" -pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf51dk.ld" +pkg.linkerscript.BOOT_LOADER.OVERWRITE: "boot-nrf51dk.ld" pkg.downloadscript: nrf51dk_download.sh pkg.debugscript: nrf51dk_debug.sh pkg.cflags: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf52dk/nrf52dk_debug.sh ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52dk/nrf52dk_debug.sh b/hw/bsp/nrf52dk/nrf52dk_debug.sh index 469bbaa..56b009f 100755 --- a/hw/bsp/nrf52dk/nrf52dk_debug.sh +++ b/hw/bsp/nrf52dk/nrf52dk_debug.sh @@ -16,20 +16,28 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 [ $# -lt 1 ]; then - echo "Need binary to download" +if [ -z "$BIN_BASENAME" ]; then + echo "Need binary to debug" exit 1 fi -FILE_NAME=$2.elf +FILE_NAME=$BIN_BASENAME.elf + +SPLIT_ELF_PRESENT=0 +if [ $# -gt 2 ]; then + SPLIT_ELF_PRESENT=1 + SPLIT_ELF_NAME=$3.elf +fi + GDB_CMD_FILE=.gdb_cmds echo "Debugging" $FILE_NAME @@ -40,6 +48,15 @@ JLinkGDBServer -device nRF52 -speed 4000 -if SWD -port 3333 -singlerun > /dev/nu 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 +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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf52dk/nrf52dk_download.sh ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52dk/nrf52dk_download.sh b/hw/bsp/nrf52dk/nrf52dk_download.sh index 028a5aa..6c25243 100755 --- a/hw/bsp/nrf52dk/nrf52dk_download.sh +++ b/hw/bsp/nrf52dk/nrf52dk_download.sh @@ -16,44 +16,56 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# +# Called with following variables set: +# - 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 +# - IMAGE_SLOT is the image slot to download to +# - FEATURES holds the target features string +# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software # -if [ $# -lt 2 ]; then +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to download" exit 1 fi +if [ -z "$IMAGE_SLOT" ]; then + echo "Need image slot to download" + exit 1 +fi + IS_BOOTLOADER=0 -BASENAME=$2 GDB_CMD_FILE=.gdb_cmds -# Look for 'bootloader' from 3rd arg onwards -shift -shift -while [ $# -gt 0 ]; do - if [ $1 = "bootloader" ]; then +# Look for 'bootloader' in FEATURES +for feature in $FEATURES; do + if [ $feature == "BOOT_LOADER" ]; then IS_BOOTLOADER=1 fi - shift done if [ $IS_BOOTLOADER -eq 1 ]; then FLASH_OFFSET=0x0 - FILE_NAME=$BASENAME.elf.bin -else + FILE_NAME=$BIN_BASENAME.elf.bin +elif [ $IMAGE_SLOT -eq 0 ]; then FLASH_OFFSET=0x8000 - FILE_NAME=$BASENAME.img + 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf52dk/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52dk/pkg.yml b/hw/bsp/nrf52dk/pkg.yml index fc7c774..9c1ded3 100644 --- a/hw/bsp/nrf52dk/pkg.yml +++ b/hw/bsp/nrf52dk/pkg.yml @@ -29,7 +29,7 @@ pkg.keywords: pkg.arch: cortex_m4 pkg.compiler: compiler/arm-none-eabi-m4 pkg.linkerscript: "nrf52dk.ld" -pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf52dk.ld" +pkg.linkerscript.BOOT_LOADER.OVERWRITE: "boot-nrf52dk.ld" pkg.downloadscript: nrf52dk_download.sh pkg.debugscript: nrf52dk_debug.sh pkg.cflags: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf52pdk/nrf52pdk_debug.sh ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52pdk/nrf52pdk_debug.sh b/hw/bsp/nrf52pdk/nrf52pdk_debug.sh index 469bbaa..f74fb55 100755 --- a/hw/bsp/nrf52pdk/nrf52pdk_debug.sh +++ b/hw/bsp/nrf52pdk/nrf52pdk_debug.sh @@ -16,20 +16,21 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 [ $# -lt 1 ]; then - echo "Need binary to download" +if [ -z "$BIN_BASENAME" ]; 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 @@ -40,6 +41,10 @@ JLinkGDBServer -device nRF52 -speed 4000 -if SWD -port 3333 -singlerun > /dev/nu 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf52pdk/nrf52pdk_download.sh ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52pdk/nrf52pdk_download.sh b/hw/bsp/nrf52pdk/nrf52pdk_download.sh index a8e4ebe..a3d8b05 100755 --- a/hw/bsp/nrf52pdk/nrf52pdk_download.sh +++ b/hw/bsp/nrf52pdk/nrf52pdk_download.sh @@ -16,44 +16,45 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features is the project features string. So you can have e.g. different -# flash offset for bootloader 'feature' -# +# Called with following variables set: +# - 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 +# - IMAGE_SLOT is the image slot to download to +# - FEATURES holds the target features string +# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software # -if [ $# -lt 2 ]; then +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to download" exit 1 fi IS_BOOTLOADER=0 -BASENAME=$2 GDB_CMD_FILE=.gdb_cmds -# Look for 'bootloader' from 3rd arg onwards -shift -shift -while [ $# -gt 0 ]; do - if [ $1 = "bootloader" ]; then +# Look for 'bootloader' in FEATURES +for feature in $FEATURES; do + if [ $feature == "BOOT_LOADER" ]; then IS_BOOTLOADER=1 fi - shift done if [ $IS_BOOTLOADER -eq 1 ]; then FLASH_OFFSET=0x0 - FILE_NAME=$BASENAME.elf.bin + FILE_NAME=$BIN_BASENAME.elf.bin else FLASH_OFFSET=0x8000 - FILE_NAME=$BASENAME.img + 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 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/nrf52pdk/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/nrf52pdk/pkg.yml b/hw/bsp/nrf52pdk/pkg.yml index d57f7e2..7779c4b 100644 --- a/hw/bsp/nrf52pdk/pkg.yml +++ b/hw/bsp/nrf52pdk/pkg.yml @@ -29,7 +29,7 @@ pkg.keywords: pkg.arch: cortex_m4 pkg.compiler: compiler/arm-none-eabi-m4 pkg.linkerscript: "nrf52pdk.ld" -pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf52pdk.ld" +pkg.linkerscript.BOOT_LOADER.OVERWRITE: "boot-nrf52pdk.ld" pkg.downloadscript: nrf52pdk_download.sh pkg.debugscript: nrf52pdk_debug.sh pkg.cflags: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh ---------------------------------------------------------------------- diff --git a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh index 2f30773..f02dfec 100755 --- a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh +++ b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh @@ -16,20 +16,26 @@ # specific language governing permissions and limitations # under the License. # -# Called: $0 <bsp_path> <binary> [identities...] -# - 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: +# - 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 [ $# -lt 2 ]; then +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to debug" exit 1 fi -MY_PATH=$1 -FILE_NAME=$2.elf +if [ -z "$BSP_PATH" ]; then + echo "Need BSP path for openocd script location" + exit 1 +fi + +FILE_NAME=$BIN_BASENAME.elf GDB_CMD_FILE=.gdb_cmds echo "Debugging" $FILE_NAME @@ -39,9 +45,14 @@ echo "Debugging" $FILE_NAME # Exit openocd when gdb detaches. # set -m -openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -s $MY_PATH -f f407.cfg -c "gdb_port 3333; telnet_port 4444; stm32f4x.cpu configure -event gdb-detach {shutdown}" -c init -c "reset halt" & +openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -s $BSP_PATH -f f407.cfg -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" >> $GDB_CMD_FILE +fi + arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME rm $GDB_CMD_FILE http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/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 e48aa35..dd5b783 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 @@ -16,41 +16,39 @@ # 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.bin appended to this -# name is the raw binary format of the binary. -# - features are the target features. So you can have e.g. different -# flash offset for bootloader 'feature' -# + +# Called with following variables set: +# - 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 +# - IMAGE_SLOT is the image slot to download to +# - FEATURES holds the target features string +# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software # -if [ $# -lt 2 ]; then + +if [ -z "$BIN_BASENAME" ]; then echo "Need binary to download" exit 1 fi -MYPATH=$1 -BASENAME=$2 IS_BOOTLOADER=0 -# Look for 'bootloader' from 3rd arg onwards -shift -shift -while [ $# -gt 0 ]; do - if [ $1 = "bootloader" ]; then - IS_BOOTLOADER=1 +# Look for 'bootloader' in FEATURES +for feature in $FEATURES; do + if [ $feature == "BOOT_LOADER" ]; then + IS_BOOTLOADER=1 fi - shift done if [ $IS_BOOTLOADER -eq 1 ]; then FLASH_OFFSET=0x08000000 - FILE_NAME=$BASENAME.elf.bin + FILE_NAME=$BIN_BASENAME.elf.bin else FLASH_OFFSET=0x08020000 - FILE_NAME=$BASENAME.img + FILE_NAME=$BIN_BASENAME.img fi + echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET -openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -s $MYPATH -f f407.cfg -c init -c "reset halt" -c "flash write_image erase $FILE_NAME $FLASH_OFFSET" -c "reset run" -c shutdown +openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -s $BSP_PATH -f f407.cfg -c "$EXTRA_JTAG_CMD" -c init -c "reset halt" -c "flash write_image erase $FILE_NAME $FLASH_OFFSET" -c "reset run" -c shutdown http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/hw/bsp/olimex_stm32-e407_devboard/pkg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml index 3b23131..1842a85 100644 --- a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml +++ b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml @@ -30,7 +30,7 @@ pkg.keywords: pkg.arch: cortex_m4 pkg.compiler: compiler/arm-none-eabi-m4 pkg.linkerscript: "olimex_stm32-e407_devboard.ld" -pkg.linkerscript.bootloader.OVERWRITE: "boot-olimex_stm32-e407_devboard.ld" +pkg.linkerscript.BOOT_LOADER.OVERWRITE: "boot-olimex_stm32-e407_devboard.ld" pkg.downloadscript: "olimex_stm32-e407_devboard_download.sh" pkg.debugscript: "olimex_stm32-e407_devboard_debug.sh" pkg.cflags: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1540d5b0/sys/config/pkg.yml ---------------------------------------------------------------------- diff --git a/sys/config/pkg.yml b/sys/config/pkg.yml index e005530..2d7c83d 100644 --- a/sys/config/pkg.yml +++ b/sys/config/pkg.yml @@ -41,7 +41,7 @@ pkg.init_stage: 5 pkg.syscfg_defs: CONFIG_FCB: description: 'TBD' - value: 1 + value: 0 CONFIG_FCB_MAGIC: description: 'TBD' value: 0xc09f6e5e
