mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
ca15b1e1f8
The semantics of `make debug` and `make debugserver` have changed in the years since the MSP430 integration. This brings the implementation back into line with the current semantics - `make debug` now starts both mspdebug and GDB, no need to run `make debugserver` prior to `make debug` anymore - `make debug` no longer flashes the target to not waste flash erase cycles - GDB mutliarch support is added - support for selecting a debug adapter by its serial is added
54 lines
1.3 KiB
Bash
Executable File
54 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
MSPDEBUG="$1"
|
|
MSPDEBUG_PROGRAMMER="$2"
|
|
PROTOCOL="$3"
|
|
MSPDEBUG_TTY="$4"
|
|
DEBUG_ADAPTER_ID="$5"
|
|
GDBPORT="$6"
|
|
ELFFILE="$7"
|
|
PREFIX="$8"
|
|
RIOTBASE="$9"
|
|
|
|
# The setsid command is needed so that Ctrl+C in GDB doesn't kill mspdebug
|
|
: "${SETSID:=setsid}"
|
|
|
|
if "${PREFIX}-gdb" -v > /dev/null 2>&1; then
|
|
GDB="${PREFIX}-gdb"
|
|
elif gdb-multiarch -v > /dev/null 2>&1; then
|
|
GDB=gdb-multiarch
|
|
else
|
|
echo "Couldn't find GDB (tried ${PREFIX}-gdb and gdb-multiarch). Check \$PATH."
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "${MSPDEBUG_PROGRAMMER}" ]; then
|
|
echo "MSPDEBUG_PROGRAMMER unset, cannot use mspdebug"
|
|
fi
|
|
|
|
sleep 2
|
|
args=()
|
|
if [ "JTAG" = "${PROTOCOL}" ]; then
|
|
args+=("-j")
|
|
elif [ "Spy-Bi-Wire" != "${PROTOCOL}" ]; then
|
|
echo "Debugger protocol \"${PROTOCOL}\" not supported, use JTAG or Spy-Bi-Wire"
|
|
exit 1
|
|
fi
|
|
args+=("${MSPDEBUG_PROGRAMMER}")
|
|
if [ -n "${DEBUG_ADAPTER_ID}" ]; then
|
|
args+=("s" "{$DEBUG_ADAPTER_ID}")
|
|
fi
|
|
if [ -n "${MSPDEBUG_TTY}" ]; then
|
|
args+=("-d" "${MSPDEBUG_TTY}")
|
|
fi
|
|
args+=("gdb ${GDBPORT}")
|
|
|
|
${SETSID} -w "${MSPDEBUG}" "${args[@]}" > /dev/null 2>&1 &
|
|
echo "Please wait..."
|
|
|
|
sleep 3
|
|
exec "$GDB" \
|
|
-ex "target remote localhost:${GDBPORT}" \
|
|
-ex "monitor reset halt" "$ELFFILE" \
|
|
-ex "set substitute-path /data/riotbuild/riotbase $RIOTBASE"
|