Skip to content

Commit

Permalink
Fix C++ debugger use
Browse files Browse the repository at this point in the history
Add Flash task, tidy up configuration of openocd, and increase adapter speed

Signed-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com>
  • Loading branch information
will-v-pi committed Apr 5, 2024
1 parent 46bbb3f commit 25abc6a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
28 changes: 22 additions & 6 deletions scripts/pico_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,10 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
use_home_var = f"{user_home}/.pico-sdk" in ninjaPath

openocd_path = ""
server_path = "\n \"serverpath\"" # Because no \ in f-strings
openocd_path_os = Path(user_home, relativeOpenOCDPath(openOCDVersion).replace("/", "", 1), "bin", "openocd.exe")
if os.path.exists(openocd_path_os):
openocd_path = f'\n"serverpath": "{codeOpenOCDPath(openOCDVersion)}/bin/openocd.exe",'
openocd_path = f'{codeOpenOCDPath(openOCDVersion)}/bin/openocd.exe'

for p in projects :
if p == 'vscode':
Expand All @@ -761,7 +762,8 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
"executable": "${{command:raspberry-pi-pico.launchTargetPath}}",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",{openocd_path}
"servertype": "openocd",\
{f'{server_path}: "{openocd_path}",' if openocd_path else ""}
"gdbPath": "{gdbPath}",
"device": "RP2040",
"configFiles": [
Expand All @@ -776,7 +778,7 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
"continue"
],
"openOCDLaunchCommands": [
"adapter speed 1000"
"adapter speed 5000"
],
"preLaunchTask": "Compile Project"
}},
Expand Down Expand Up @@ -808,11 +810,10 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
"MIMode": "gdb",
"miDebuggerPath": "{gdbPath}",
"miDebuggerServerAddress": "localhost:3333",
"debugServerPath": "openocd",
"debugServerArgs": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \\"adapter speed 1000\\"",
"debugServerPath": "{openocd_path if openocd_path else "openocd"}",
"debugServerArgs": "-f {debugger} -f target/rp2040.cfg -c \\"adapter speed 5000\\"",
"serverStarted": "Listening on port .* for gdb connections",
"filterStderr": true,
"stopAtEntry": true,
"hardwareBreakpoints": {{
"require": true,
"limit": 4
Expand Down Expand Up @@ -923,6 +924,21 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
"windows": {{
"command": "{ninjaPath.replace(user_home, "${env:USERPROFILE}") if use_home_var else ninjaPath}.exe"
}}
}},
{{
"label": "Flash",
"type": "process",
"dependsOn": "Compile Project",
"command": "{openocd_path if openocd_path else "openocd"}",
"args": [
"-f",
"{debugger}",
"-f",
"target/rp2040.cfg",
"-c",
"adapter speed 5000; program ${{command:raspberry-pi-pico.launchTargetPath}} verify reset exit"
],
"problemMatcher": []
}}
]
}}
Expand Down
3 changes: 2 additions & 1 deletion src/commands/launchTargetPath.mts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default class LaunchTargetPathCommand extends CommandWithResult<string> {
return "";
}

return join(fsPathFolder, "build", projectName + ".elf");
return join(fsPathFolder, "build", projectName + ".elf")
.replaceAll("\\", "/");
}
}

0 comments on commit 25abc6a

Please sign in to comment.