-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scripts: Add support for 'make debug' using Segger JLink on NXP boards #31
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DEBUG_SCRIPT = jlink.sh | ||
|
||
JLINK_DEVICE = MKL25Z128xxx4 | ||
|
||
export JLINK_DEVICE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DEBUG_SCRIPT = jlink.sh | ||
|
||
JLINK_DEVICE = MKW41Z512xxx4 | ||
|
||
export JLINK_DEVICE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DEBUG_SCRIPT = jlink.sh | ||
|
||
JLINK_DEVICE = MK64FN1M0xxx12 | ||
|
||
export JLINK_DEVICE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DEBUG_SCRIPT = jlink.sh | ||
|
||
JLINK_DEVICE = MKW40Z160xxx4 | ||
|
||
export JLINK_DEVICE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/sh | ||
|
||
# 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} | ||
|
||
test_config() { | ||
if ! which ${JLINK_GDBSERVER} >/dev/null 2>&1; then | ||
echo "Error: Unable to locate JLink GDB server: ${JLINK_GDBSERVER}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
test_bin() { | ||
if [ ! -f "${BIN_NAME}" ]; then | ||
echo "Error: Unable to locate image binary: ${BIN_NAME}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
do_debug() { | ||
do_debugserver 1 & | ||
|
||
# connect to the GDB server | ||
${GDB} ${TUI} ${ELF_NAME} \ | ||
-ex "target remote :${GDB_PORT}" \ | ||
-ex 'monitor halt' \ | ||
-ex 'load' \ | ||
-ex 'monitor reset' | ||
} | ||
|
||
do_debugserver() { | ||
test_config | ||
|
||
# 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. | ||
if [ -n "$1" ]; then | ||
SETSID=/usr/bin/setsid | ||
else | ||
SETSID= | ||
fi | ||
|
||
echo "JLink GDB server running on port ${GDB_PORT}" | ||
${SETSID} ${JLINK_GDBSERVER} \ | ||
-port ${GDB_PORT} \ | ||
-if ${JLINK_IF} \ | ||
-device ${JLINK_DEVICE} \ | ||
-singlerun | ||
} | ||
|
||
CMD="$1" | ||
shift | ||
|
||
case "${CMD}" in | ||
debugserver) | ||
do_debugserver "$@" | ||
;; | ||
debug) | ||
do_debug "$@" | ||
;; | ||
esac |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to make this jlink only? OpenOCD does not seem to work with current SDK and only works with latest openocd. If it works with Jlink we might want to switch to that and document it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see a reason to remove the OpenOCD support. I presume we'll update the OpenOCD version in a future SDK? I've also been looking at pyOCD as another option, since that is being actively maintained for NXP devices and is open source.
About documentation, this is something I plan to work on next after these scripts are cleaned up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to add support for different flashing methods via 'make flash', right now only one is supported...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Segger flash tool is Windows only. I've had some success getting 'make flash' to work with pyOCD on k64 and kl25z, but I'm looking into when pyOCD can support kw41 before submitting a PR for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a PR for pyOCD for kw41 support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pyocd/pyOCD#302