-
Notifications
You must be signed in to change notification settings - Fork 72
Integrate cortex debugger #398
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
Open
wxyyy0117
wants to merge
9
commits into
4.0.0-pre-release
Choose a base branch
from
integrate_cortex_debugger
base: 4.0.0-pre-release
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0b84add
tools: Integrate cortex debugger.
wxyyy0117 20e93fe
tools: Change sh address.
wxyyy0117 8486d4f
tools: Add optional parameters.
wxyyy0117 398e5b8
tools: Configure build elf and json path.
wxyyy0117 9abae43
docs: Update documentation.
wxyyy0117 04330f5
tools: Change to Lowercase.
wxyyy0117 b2d60c4
tools: Make gen_launch.sh generic.
wxyyy0117 ebcfced
tools: Make gen_launch.sh generic.
wxyyy0117 df4b74f
tools: Modify gen_launch.sh.
wxyyy0117 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 hidden or 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,79 @@ | ||
| #!/bin/bash | ||
| # gen_launch.sh: Compile and generate launch.json for XMC boards | ||
| # Usage: ./gen_launch.sh <fqbn> <build_path> <sketch_path> | ||
| # Example: ./gen_launch.sh kit_xmc47_relax ~/output ~/build/build.ino | ||
|
|
||
| set -e | ||
|
|
||
|
|
||
|
|
||
| FQBN_FULL="$1" | ||
| BUILD_PATH="$2" | ||
| SKETCH_PATH="$3" | ||
| BOARDS_TXT="$HOME/Arduino/hardware/arduino-git/xmc/boards.txt" | ||
|
|
||
| # Extract board name from FQBN (e.g. arduino-git:xmc:kit_xmc47_relax -> kit_xmc47_relax) | ||
| BOARD_NAME=$(echo "$FQBN_FULL" | awk -F: '{print $NF}') | ||
|
|
||
| # Find arm-none-eabi-gdb | ||
| GDB_PATH=$(command -v arm-none-eabi-gdb) | ||
| if [ -z "$GDB_PATH" ]; then | ||
| # Try to find it under home directory only | ||
| GDB_PATH=$(find "$HOME" -type f -name arm-none-eabi-gdb 2>/dev/null | head -n 1) | ||
LinjingZhang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi | ||
| if [ -z "$GDB_PATH" ]; then | ||
| echo "arm-none-eabi-gdb not found in PATH or under your home directory." | ||
| exit 3 | ||
| fi | ||
|
|
||
| if [[ -z "$FQBN_FULL" || -z "$BUILD_PATH" || -z "$SKETCH_PATH" ]]; then | ||
| echo "Usage: $0 <fqbn> <build_path> <sketch_path>" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # 1. Compile | ||
| arduino-cli compile -b "${FQBN_FULL}" --build-path "${BUILD_PATH}" "${SKETCH_PATH}" || exit 1 | ||
|
|
||
| # 2. Parse boards.txt for variant and board.v using board name | ||
| VARIANT=$(grep "^${BOARD_NAME}\.build\.variant=" "$BOARDS_TXT" | cut -d= -f2) | ||
| BOARD_V=$(grep "^${BOARD_NAME}\.build\.board\.v=" "$BOARDS_TXT" | cut -d= -f2) | ||
|
|
||
| if [[ -z "$VARIANT" || -z "$BOARD_V" ]]; then | ||
| echo "Could not find variant or board.v for $BOARD_NAME in $BOARDS_TXT" | ||
| exit 2 | ||
| fi | ||
|
|
||
| DEVICE="${VARIANT}-${BOARD_V}" | ||
| EXECUTABLE="${BUILD_PATH}/build.ino.elf" | ||
|
|
||
| # 3. Generate launch.json in xmc/.vscode | ||
| LAUNCH_DIR="../../.vscode" | ||
| if [ ! -d "$LAUNCH_DIR" ]; then | ||
| mkdir "$LAUNCH_DIR" | ||
| fi | ||
| if [ -f "$LAUNCH_DIR/launch.json" ]; then | ||
| rm "$LAUNCH_DIR/launch.json" | ||
| fi | ||
| cat > "$LAUNCH_DIR/launch.json" <<EOF | ||
| { | ||
| "version": "0.2.0", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a better way to separate the JSON format from the shell script? |
||
| "configurations": [ | ||
| { | ||
| "name": "Cortex-Debug: Debug ${DEVICE}", | ||
| "type": "cortex-debug", | ||
| "request": "launch", | ||
| "servertype": "jlink", | ||
| "device": "${DEVICE}", | ||
| "executable": "${EXECUTABLE}", | ||
| "cwd": "\${workspaceFolder}", | ||
| "interface": "swd", | ||
| "gdbPath": "${GDB_PATH}", | ||
| "showDevDebugOutput": "info" | ||
| } | ||
| ] | ||
| } | ||
| EOF | ||
|
|
||
| echo "launch.json generated for device ${DEVICE} at $LAUNCH_DIR." | ||
|
|
||
|
|
||
This file contains hidden or 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,106 @@ | ||
| { | ||
| "version": "2.0.0", | ||
| "tasks": [ | ||
| { | ||
| "label": "Arduino Build", | ||
| "type": "shell", | ||
| "command": "arduino-cli", | ||
| "args": [ | ||
| "compile", | ||
| "--fqbn", "${input:boardFqbn}", | ||
| "${input:examplePath}" | ||
| ], | ||
| "group": { | ||
| "kind": "build", | ||
| "isDefault": false | ||
| }, | ||
| "problemMatcher": [] | ||
| }, | ||
| { | ||
| "label": "Arduino Upload", | ||
| "type": "shell", | ||
| "command": "arduino-cli", | ||
| "args": [ | ||
| "upload", | ||
| // "--verbose", | ||
| "-p", "${input:port}", | ||
| "--fqbn", "${input:boardFqbn}", | ||
| "${input:examplePath}" | ||
| ], | ||
| "dependsOn": "Arduino Build", | ||
| "group": { | ||
| "kind": "build", | ||
| "isDefault": true | ||
| }, | ||
| "problemMatcher": [] | ||
| }, | ||
| { | ||
| "label": "Arduino Debug", | ||
LinjingZhang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "type": "shell", | ||
| "command": "${workspaceFolder}/tools/gen_launch.sh", | ||
| "args": [ | ||
| "${input:boardFqbn}", | ||
| "${input:debugBuildPath}", | ||
| "${input:examplePath}" | ||
| ], | ||
| "group": { | ||
| "kind": "build", | ||
| "isDefault": false | ||
| }, | ||
| "problemMatcher": [], | ||
| "presentation": { | ||
| "echo": true, | ||
| "reveal": "always", | ||
| "focus": false, | ||
| "panel": "shared" | ||
| } | ||
| }, | ||
| { | ||
| "label": "Arduino Monitor", | ||
| "type": "shell", | ||
| "command": "arduino-cli", | ||
| "args": [ | ||
| "monitor", | ||
| "-p", "${input:port}", | ||
| "-c", "baudrate=115200" | ||
| ], | ||
| "group": { | ||
| "kind": "build", | ||
| "isDefault": false | ||
| }, | ||
| "problemMatcher": [] | ||
| } | ||
| ], | ||
| "inputs": [ | ||
| { | ||
| "id": "boardFqbn", | ||
| "type": "promptString", | ||
| "description": "Enter the FQBN (Fully Qualified Board Name) for the Arduino board", | ||
| "default": "arduino-git:xmc:kit_xmc47_relax" | ||
| }, | ||
| { | ||
| "id": "debugBuildPath", | ||
| "type": "promptString", | ||
| "description": "Enter the build path for gen_launch.sh", | ||
| "default": "${workspaceFolder}/extras/arduino-core-tests/build/output" | ||
| }, | ||
| { | ||
| "id": "examplePath", | ||
| "type": "promptString", | ||
| "description": "Enter the path to the Arduino example sketch", | ||
| "default": "${workspaceFolder}/examples/bug/bug.ino" | ||
| }, | ||
| { | ||
| "id": "port", | ||
| "type": "promptString", | ||
| "description": "Enter the port for the Arduino board", | ||
| "default": "/dev/ttyACM0" | ||
| }, | ||
| ] | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.