| # This script is loosly based on a script with same purpose provided |
| # by RIOT-OS (https://github.com/RIOT-OS/RIOT) |
| JLINK_GDBSERVER=${JLINK_GDBSERVER:-JLinkGDBServer} |
| JLINK_IF=${JLINK_IF:-swd} |
| BIN_NAME=${O}/${KERNEL_BIN_NAME} |
| ELF_NAME=${O}/${KERNEL_ELF_NAME} |
| GDB_PORT=${GDB_PORT:-2331} |
| if ! which ${JLINK_GDBSERVER} >/dev/null 2>&1; then |
| echo "Error: Unable to locate JLink GDB server: ${JLINK_GDBSERVER}" |
| if [ ! -f "${BIN_NAME}" ]; then |
| echo "Error: Unable to locate image binary: ${BIN_NAME}" |
| # connect to the GDB server |
| ${GDB} ${TUI} ${ELF_NAME} \ |
| -ex "target remote :${GDB_PORT}" \ |
| # Calling with an arg will result in setsid being used, which will prevent |
| # Ctrl-C in GDB from killing the server. The server automatically exits |
| # when the remote GDB disconnects. |
| echo "JLink GDB server running on port ${GDB_PORT}" |
| ${SETSID} ${JLINK_GDBSERVER} \ |
| -device ${JLINK_DEVICE} \ |