Skip to content

Commit b2c8bdc

Browse files
committed
Add semihosting to pico_project.py
1 parent 9584908 commit b2c8bdc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

scripts/pico_project.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,12 @@ def ParseCommandLine():
571571
action="store_true",
572572
help="Console output to USB (disables other USB functionality",
573573
)
574+
parser.add_argument(
575+
"-semihosting",
576+
"--semihosting",
577+
action="store_true",
578+
help="Console output to semihosting",
579+
)
574580
parser.add_argument(
575581
"-cpp", "--cpp", action="store_true", default=0, help="Generate C++ code"
576582
)
@@ -905,6 +911,11 @@ def GenerateCMake(folder, params):
905911
else:
906912
file.write(f"pico_enable_stdio_usb({projectName} 0)\n\n")
907913

914+
if params["wantSemiHosting"]:
915+
file.write(f"pico_enable_stdio_semihosting({projectName} 1)\n\n")
916+
else:
917+
file.write(f"pico_enable_stdio_semihosting({projectName} 0)\n\n")
918+
908919
# If we need wireless, check for SSID and password
909920
# removed for the moment as these settings are currently only needed for the pico-examples
910921
# but may be required in here at a later date.
@@ -1030,7 +1041,10 @@ def generateProjectFiles(
10301041
"overrideLaunchCommands": [
10311042
"monitor reset init",
10321043
"load \\"${{command:raspberry-pi-pico.launchTargetPath}}\\""
1033-
],
1044+
],{f"""
1045+
"postLaunchCommands": [
1046+
"monitor arm semihosting enable"
1047+
],""" if params["wantSemiHosting"] else ""}
10341048
"openOCDLaunchCommands": [
10351049
"adapter speed 5000"
10361050
]
@@ -1518,6 +1532,7 @@ def DoEverything(params):
15181532
"wantUARTExample": args.uartExample,
15191533
"wantUART": args.uart,
15201534
"wantUSB": args.usb,
1535+
"wantSemiHosting": args.semihosting,
15211536
"wantCPP": args.cpp,
15221537
"debugger": args.debugger,
15231538
"exceptions": args.cppexceptions,

0 commit comments

Comments
 (0)