aboutsummaryrefslogtreecommitdiff
path: root/.local/share/bin/dbg
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2026-07-03 18:37:53 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2026-07-03 18:37:53 +0200
commit31b2d83b8703971452a5200abf02a1353bef2a81 (patch)
treebec103a73d283eddd47824e9a3911ff4f2a05ee2 /.local/share/bin/dbg
parent38a2ee83e398bfe63328b5ac38fca69f032cde0d (diff)
work updateHEADmaster
Diffstat (limited to '.local/share/bin/dbg')
-rwxr-xr-x.local/share/bin/dbg53
1 files changed, 20 insertions, 33 deletions
diff --git a/.local/share/bin/dbg b/.local/share/bin/dbg
index 424110b..d042ba5 100755
--- a/.local/share/bin/dbg
+++ b/.local/share/bin/dbg
@@ -1,40 +1,27 @@
#!/bin/sh
-progname="$(basename "$(readlink -f "$0")")"
-die() {
- ec="$1"
- shift
- echo "$@"
- exit "$ec"
-}
-
GDB="arm-none-eabi-gdb"
-[ $# -lt 1 ] && die 1 "usage: $progname DEVICE [gdb args...]"
-DEVICE="$1"
-shift
+found_executable=false
+
+while ! $found_executable ; do
+ [ ! -e build/zephyr ] && break
+ [ ! -e build/zephyr/zephyr.elf ] && break
+ set -- --se="build/zephyr/zephyr.elf" "$@"
+
+ [ -e build/tfm/bin/tfm_s.elf ] && set -- "$@" --eval-command="add-symbol-file build/tfm/bin/tfm_s.elf"
-if [ $# -eq 0 ] ; then
- # automatically add --se flag if executable can be found
+ found_executable=true
+done
+
+while ! $found_executable ; do
exec="$(find . -maxdepth 3 -name '*.elf' | head -n1)"
- [ -n "$exec" ] && set -- --se="$exec"
-fi
-
-[ -n "$(echo "$*" | grep -i zephyr)" ] && GDB="arm-zephyr-eabi-gdb"
-
-fork JLinkGDBServerCLExe \
- -device "$DEVICE" \
- -select USB \
- -endian little \
- -if SWD \
- -speed auto \
- -singlerun \
- -noir \
- -nologtofile \
- -silent
-
-# append startup attach command to args
-set -- --eval-command="target extended-remote :2331" "$@"
-
-# launch gdb and forward any other args to it
+ [ -n "$exec" ] && set -- "$@" --se="$exec"
+ found_executable=true
+ break
+done
+
+set -- "$@" --eval-command="set jlink autoconnect on"
+set -- "$@" --eval-command="set jlink watchdog on"
+
exec "$GDB" "$@"