diff --git a/platforms/nuttx/Debug/jlink_debug_gdb.sh.in b/platforms/nuttx/Debug/jlink_debug_gdb.sh.in index 26bd2efec5..f27d0065eb 100755 --- a/platforms/nuttx/Debug/jlink_debug_gdb.sh.in +++ b/platforms/nuttx/Debug/jlink_debug_gdb.sh.in @@ -1,7 +1,5 @@ #! /bin/sh -set -o xtrace - @JLinkGDBServerExe_PATH@ -device @DEBUG_DEVICE@ -select usb -endian little -if SWD -speed auto -ir -LocalhostOnly 1 -strict -vd -singlerun & cd @PX4_BINARY_DIR@ && @CMAKE_GDB@ -silent -nh \ @@ -12,3 +10,6 @@ cd @PX4_BINARY_DIR@ && @CMAKE_GDB@ -silent -nh \ -ex "monitor reset 0" \ -ex "continue" \ @PX4_CONFIG@.elf + +# exit with status of last command +exit $? diff --git a/platforms/nuttx/Debug/jlink_gdb_start.sh.in b/platforms/nuttx/Debug/jlink_gdb_start.sh.in index 855686a73a..404b210501 100755 --- a/platforms/nuttx/Debug/jlink_gdb_start.sh.in +++ b/platforms/nuttx/Debug/jlink_gdb_start.sh.in @@ -1,7 +1,11 @@ #! /bin/sh -set -o xtrace - killall JLinkGDBServerCLExe -JLinkGDBServerCLExe -silent -device @DEBUG_DEVICE@ -select usb -if SWD -speed auto -LocalhostOnly 1 -strict -vd -singlerun & +@JLinkGDBServerCLExe_PATH@ -silent -device @DEBUG_DEVICE@ -select usb -if SWD -speed auto -LocalhostOnly 1 -strict -vd -singlerun -timeout 3000 -powertarget 0 -nogui & +sleep 2 + +pgrep -i JLinkGDBServer + +# exit with status of last command +exit $? diff --git a/platforms/nuttx/Debug/upload_jlink_gdb.sh b/platforms/nuttx/Debug/upload_jlink_gdb.sh index 81e52da0ac..e1547013d3 100755 --- a/platforms/nuttx/Debug/upload_jlink_gdb.sh +++ b/platforms/nuttx/Debug/upload_jlink_gdb.sh @@ -1,14 +1,41 @@ #! /bin/sh -set -o xtrace - -gdb-multiarch -silent -nx -batch \ - -ex "target remote localhost:2331" \ - -ex "monitor reset 0" \ - -ex "load" \ - -ex "monitor reset 0" \ - -ex "monitor go" \ - -ex "monitor sleep 3000" \ - -ex "disconnect" \ - -ex "quit" \ - ${1} +if command -v gdb-multiarch &> /dev/null +then + GDB_CMD=$(command -v gdb-multiarch) + +elif command -v arm-none-eabi-gdb &> /dev/null +then + GDB_CMD=$(command -v arm-none-eabi-gdb) + +else + echo "gdb arm-none-eabi or multi-arch not found" + exit 1 +fi + +file ${1} + +gdb_cmd_file=$(mktemp) + +cat >"${gdb_cmd_file}" <