-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Hi,
I work on Windows 11 using latest vs code (v1.95.3) and your latest plugin (v0.17.2)
I am new to using VS Code for Raspberry Pi Pico development.
I usually work with VisualGDB in VS2022. I followed the tutorials available at the following links:
In Chapter 3 ("Install the Raspberry Pi Pico VS Code Extension") of the PDF, there is no mention of defining the PICO_SDK_PATH or adding the compiler's bin folder to the PATH system variable.
The Problem
I followed all the steps but encountered issues:
- I couldn't create a new project or example.
- After some investigation, I discovered that the problem was in the
pico_project.pyscript.
The script calls the CheckPrerequisites function, which looks for the compiler in the PATH. However, this PATH is not set and is eventually overridden by the following line:
compilerPath = Path(codeToolchainPath(args.toolchainVersion) + "/bin/" + COMPILER_NAME())The Fix
Fix 1: Update CheckPrerequisites
I added a check for args.toolchainVersion in the CheckPrerequisites function. If this value is set, I return "FOUND" without further checks.
Here’s the updated function:
def CheckPrerequisites():
global isMac, isWindows, isx86
isMac = platform.system() == "Darwin"
isWindows = platform.system() == "Windows"
isx86 = platform.machine().lower() in ["x86_64", "amd64"]
# Do we have a compiler?
if args.toolchainVersion: # Check if toolchainVersion is set
return "FOUND"
return shutil.which(COMPILER_NAME(), 1, os.environ["Path" if isWindows else "PATH"])Fix 2: Update CheckSDKPath
The script checks for the PICO_SDK_PATH environment variable in the CheckSDKPath function. If the variable is not set, the script aborts. I modified this function to try to locate the SDK using sdkVersion if PICO_SDK_PATH is not defined.
Here’s the updated function:
def CheckSDKPath(gui):
sdkPath = os.getenv("PICO_SDK_PATH")
if sdkPath is None:
sdkPath = propertiesSdkPath(sdkVersion, force_windows=False)
if sdkPath is None:
m = "Unable to locate the Raspberry Pi Pico SDK, PICO_SDK_PATH is not set"
print(m)
elif not os.path.isdir(sdkPath):
m = "Unable to locate the Raspberry Pi Pico SDK, PICO_SDK_PATH does not point to a directory"
print(m)
sdkPath = None
return sdkPathOutcome
After applying these fixes, everything worked as expected.