Raspberry Pi Pico Survival Guide

Here are tips on how to get started developing for Raspberry Pi Pico boards on Windows using the Pico C SDK.

Windows setup

Just use the Windows installer which is available on GitHub. At the end it will ask for a path to put the examples code. As you proceed it will open a terminal window to setup the examples. Make sure you wait for it to complete. Then from the Windows start menu search for Pico and launch Pico - Visual Studio Code. If you are using the Pico W board edit .vscode\settings.json to specify the board model as explained in those FAQ.

.vscode/settings.json:
  "cmake.configureSettings": {
    …
    "PICO_BOARD": "pico_w"
    …
  }

Click on the CMake icon in the side panel and make sure Configure specifies Pico ARM GCC as shown below.
1717969210974.png


I'm not quite sure now at which stage the CMake configuration occurs but you can trigger it from the context menu of any CMakeList.txt file in the project explorer. When you modify a CMake file the configuration will run automatically.

1717969685681.png


Build your code

Back to the CMake panel you can build individual examples using the build icon next to its name.

1717969982942.png


The build output you find in the corresponding build subfolder. For our Pico W blink example that will be \pico-examples\build\pico_w\wifi\blink. Note that the basic Pico blink example does not work on the Pico W board as the LED is attached to the Wi-Fi controller.

Flashing your board

Plug the Pico into your PC USB while holding down the BOOTSEL button it will be mounted as a removable drive. You can then copy that .uf2 file from your build output folder to that Pico drive. As soon as the .uf2 file is copied the board will reboot and execute your program.
1718013146127.png

By loading a special UF2 file you can also just reset your Pico.

Logs over USB serial emulation

Now that we can execute our program we need to be able to monitor it. That's typically done over USB serial COM port. Here again on Arduino or ESP-IDF that's just working out-of-the-box but not on Raspberry Pi Pico. I'm assuming the default configuration on Pico is to output to an actual UART serial port you can typically hook to using a Raspberry Pi Debug Probe. If you want to use the USB port for that you'll have to add the following to your CMakeLists.txt:

CMakeLists.txt inserts for picow_blink project:
pico_enable_stdio_usb(picow_blink 1)
pico_enable_stdio_uart(picow_blink 0)

With this enabled you should see the COM port being created in Windows Device Manager and your printf output should end up in Visual Studio Code serial monitor. Much of that is also explained there. Take a look at that hellow_usb Pico example.
1718020066649.png


Create your own project

At this stage you may want to create your own project instead of just modifying the examples.

Build and flash

Eventually, you will want to use the Raspberry Pi Debug Probe as it will enable you to flash your board without having to unplug it and manually copy the image. There is indeed a trick to conveniently build and flash from Visual Studio Code by just doing Ctrl + Shift + B.
.vscode/tasks.json:
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Flash",
      "type": "shell",
      "command": "openocd",
      "args": [
        "-f",
        "interface/cmsis-dap.cfg",
        "-f",
        "target/rp2040.cfg",
        "-c",
        "adapter speed 5000; program {${command:cmake.launchTargetPath}} verify reset exit"
      ],
      "problemMatcher": [],       
      "dependsOn": ["Build"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "Build",
      "type": "cmake",
      "command": "build",
      "problemMatcher": "$gcc",
    }
  ]
}
Though you may want to do it slightly differently using launch configurations instead of modifying the Tasks.

Resources

Here are links to other resources that could be useful:
 
Last edited:
Back
Top