Coding for the pi pico 2 w within VSCode¶
Steps to code using the pico-sdk (no Arduino framework) for the RP2040 or RP2350 (in the pi pico 2 w, for example) within VSCode.
As per “Getting started with Raspberry Pi Pico-series”, Chapter 3.
Install VSCode¶
Easy.
Install Raspberry Pi Pico VS Code Extension¶
This is the official extension by the Raspberry Pi foundation.
Create a “new project from example”¶
From the new section in the left sidebar.
Choose, for example, the blink example.
Run CMake: configure¶
You might need to do this the first time you compile your proyect.
Compile and run¶
Do it from the “run project” button in the left sidebar.
Gotcha!¶
If you can upload your code after connecting the pico for the first time to the computer, but not after, you need to put it into BOOTSEL mode. You can do this by uplugging, holding the BOOTSEL button, and plugging it again, but it’s a pain. To be able to do it with software:
- Add at the end of your
CMakeLists.txt:
- Add within your code (in
main(), for example):
This will make the pi pico present itself as a usb device even while it’s running code. You can verify by finding it within the list of tty devices (in linux/mac):
That allows VSCode to reset the pico into BOOTSEL mode by itself, so that it can upload the code again.
Debugging¶
You can use a second pico or pico 2 to debug the first.
Flashing debugprobe_on_pico2¶
For that, download debugprobe_on_pico2.uf2 from [https://github.com/raspberrypi/debugprobe/releases].
- Hold BOOTSEL on the Pico 2 debugger
- Plug it into USB
- Copy the debug probe UF2 to the RPI-RP2 drive
- It reboots as a CMSIS-DAP debugger
Connect the two boards¶

Gotcha! openocd Error: Can't find target/rp2350.cfg¶
You need to use Raspberry Pi’s openocd, which has support for the RP2350.
Gotcha! Error: Error connecting DP: cannot read IDR¶
Review your cabling! You might have something wrong. I connected my boards header to header and it didn’t work: I had to connect the header pins in the target to pins 4 and 5 in the debugger.