Skip to content

Commit 25abc6a

Browse files
committed
Fix C++ debugger use
Add Flash task, tidy up configuration of openocd, and increase adapter speed Signed-off-by: William Vinnicombe <[email protected]>
1 parent 46bbb3f commit 25abc6a

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

scripts/pico_project.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -746,9 +746,10 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
746746
use_home_var = f"{user_home}/.pico-sdk" in ninjaPath
747747

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

753754
for p in projects :
754755
if p == 'vscode':
@@ -761,7 +762,8 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
761762
"executable": "${{command:raspberry-pi-pico.launchTargetPath}}",
762763
"request": "launch",
763764
"type": "cortex-debug",
764-
"servertype": "openocd",{openocd_path}
765+
"servertype": "openocd",\
766+
{f'{server_path}: "{openocd_path}",' if openocd_path else ""}
765767
"gdbPath": "{gdbPath}",
766768
"device": "RP2040",
767769
"configFiles": [
@@ -776,7 +778,7 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
776778
"continue"
777779
],
778780
"openOCDLaunchCommands": [
779-
"adapter speed 1000"
781+
"adapter speed 5000"
780782
],
781783
"preLaunchTask": "Compile Project"
782784
}},
@@ -808,11 +810,10 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
808810
"MIMode": "gdb",
809811
"miDebuggerPath": "{gdbPath}",
810812
"miDebuggerServerAddress": "localhost:3333",
811-
"debugServerPath": "openocd",
812-
"debugServerArgs": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \\"adapter speed 1000\\"",
813+
"debugServerPath": "{openocd_path if openocd_path else "openocd"}",
814+
"debugServerArgs": "-f {debugger} -f target/rp2040.cfg -c \\"adapter speed 5000\\"",
813815
"serverStarted": "Listening on port .* for gdb connections",
814816
"filterStderr": true,
815-
"stopAtEntry": true,
816817
"hardwareBreakpoints": {{
817818
"require": true,
818819
"limit": 4
@@ -923,6 +924,21 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
923924
"windows": {{
924925
"command": "{ninjaPath.replace(user_home, "${env:USERPROFILE}") if use_home_var else ninjaPath}.exe"
925926
}}
927+
}},
928+
{{
929+
"label": "Flash",
930+
"type": "process",
931+
"dependsOn": "Compile Project",
932+
"command": "{openocd_path if openocd_path else "openocd"}",
933+
"args": [
934+
"-f",
935+
"{debugger}",
936+
"-f",
937+
"target/rp2040.cfg",
938+
"-c",
939+
"adapter speed 5000; program ${{command:raspberry-pi-pico.launchTargetPath}} verify reset exit"
940+
],
941+
"problemMatcher": []
926942
}}
927943
]
928944
}}

src/commands/launchTargetPath.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export default class LaunchTargetPathCommand extends CommandWithResult<string> {
6969
return "";
7070
}
7171

72-
return join(fsPathFolder, "build", projectName + ".elf");
72+
return join(fsPathFolder, "build", projectName + ".elf")
73+
.replaceAll("\\", "/");
7374
}
7475
}

0 commit comments

Comments
 (0)